1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! Inventory mechanic - Physical possession management.
//!
//! This module provides a policy-based inventory system for managing
//! physical possession of items. It focuses purely on **who holds what**,
//! not on legal ownership or rights (which would be a separate mechanic).
//!
//! # Core Concept
//!
//! The inventory mechanic models **physical occupation** of items:
//! - Adding/removing items from containers
//! - Capacity constraints (slots, weight)
//! - Stacking behavior
//! - Holding costs over time
//!
//! # Policy Dimensions
//!
//! The inventory mechanic composes three orthogonal policies:
//!
//! 1. **CapacityPolicy**: How capacity is evaluated
//! - `FixedSlotCapacity`: Limited by number of slots
//! - `WeightBasedCapacity`: Limited by total weight
//! - `UnlimitedCapacity`: No limits
//!
//! 2. **StackingPolicy**: How items are organized
//! - `AlwaysStack`: Items of same type combine
//! - `NeverStack`: Each item occupies separate slot
//! - `LimitedStack`: Stack up to configured maximum
//!
//! 3. **CostPolicy**: How holding costs are calculated
//! - `NoCost`: Free storage
//! - `SlotBasedCost`: Cost per occupied slot
//! - `WeightBasedCost`: Cost per unit weight
//!
//! # Examples
//!
//! ## Basic RPG Inventory
//!
//! ```
//! use issun_core::mechanics::inventory::prelude::*;
//! use issun_core::mechanics::{Mechanic, EventEmitter};
//!
//! // Define inventory type
//! type RPGInventory = InventoryMechanic<
//! FixedSlotCapacity,
//! AlwaysStack,
//! NoCost,
//! >;
//!
//! // Or use preset
//! type RPGInventory2 = BasicInventory;
//!
//! // Configure
//! let config = InventoryConfig {
//! max_slots: Some(20),
//! max_weight: None,
//! max_stack_size: Some(99),
//! holding_cost_per_slot: 0.0,
//! holding_cost_per_weight: 0.0,
//! };
//!
//! // Create state
//! let mut state = InventoryState::new();
//!
//! // Add items
//! # struct TestEmitter;
//! # impl EventEmitter<InventoryEvent> for TestEmitter {
//! # fn emit(&mut self, _event: InventoryEvent) {}
//! # }
//! let mut emitter = TestEmitter;
//! let input = InventoryInput {
//! operation: InventoryOperation::Add {
//! stack: ItemStack::new(1, 10),
//! weight_per_item: 1.0,
//! },
//! elapsed_time: 0,
//! };
//!
//! RPGInventory::step(&config, &mut state, input, &mut emitter);
//! ```
//!
//! ## Weight-Limited Inventory (Survival Game)
//!
//! ```
//! use issun_core::mechanics::inventory::prelude::*;
//!
//! type SurvivalInventory = WeightLimitedInventory;
//!
//! let config = InventoryConfig {
//! max_slots: None, // No slot limit
//! max_weight: Some(100.0), // 100kg carry capacity
//! ..Default::default()
//! };
//! ```
//!
//! ## Warehouse with Storage Fees
//!
//! ```
//! use issun_core::mechanics::inventory::prelude::*;
//!
//! type Warehouse = WarehouseInventory;
//!
//! let config = InventoryConfig {
//! max_slots: Some(1000),
//! holding_cost_per_slot: 5.0, // 5 gold per slot per day
//! ..Default::default()
//! };
//! ```
//!
//! # Design Philosophy
//!
//! ## Separation of Concerns
//!
//! This mechanic handles **physical possession only**. Related but separate concepts:
//! - **Ownership rights**: Should be handled by a separate Rights/Claim mechanic
//! - **Item properties**: Defined by game logic, not inventory system
//! - **Transfer between entities**: Coordinated by game logic using Add/Remove
//!
//! ## Composition over Inheritance
//!
//! Different inventory systems are created by composing policies, not by
//! subclassing. This provides:
//! - Zero-cost abstraction (compile-time composition)
//! - Type safety (invalid combinations caught by compiler)
//! - Flexibility (any valid combination of policies)
// Re-export core types at module level
pub use InventoryMechanic;
pub use ;