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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! Temporal mechanic: Time management and action budget systems.
//!
//! This module provides a policy-based system for managing game time,
//! action points, and temporal mechanics across various game types.
//!
//! # Key Concepts
//!
//! ## DateTime vs Tick
//!
//! The temporal mechanic supports two time representations:
//!
//! - **GameDateTime**: Semantic calendar time (year/month/day/hour/minute)
//! - Useful for games with day/night cycles, seasons, schedules
//! - Supports Gregorian and 360-day calendars
//!
//! - **Tick**: Abstract counter
//! - Useful for pure turn-based systems
//! - Convertible to/from DateTime via `CalendarConfig`
//!
//! ## Action Budgets
//!
//! Two budget types for different game styles:
//!
//! - **ActionPoints**: Discrete budget for turn-based games
//! - Resets at configurable boundaries (per day, per turn)
//! - Example: 3 actions per day (Persona-style)
//!
//! - **ActionEnergy**: Continuous budget for real-time games
//! - Regenerates over time based on `regen_rate`
//! - Example: Stamina system in action RPGs
//!
//! # Architecture
//!
//! The temporal mechanic follows **Policy-Based Design**:
//! - The core `TemporalMechanic<P>` is generic over `TemporalPolicy`
//! - `P: TemporalPolicy` determines cost calculation and reset behavior
//! - All logic is resolved at compile time via static dispatch
//!
//! # Quick Start
//!
//! ```
//! use issun_core::mechanics::temporal::prelude::*;
//! use issun_core::mechanics::{Mechanic, EventEmitter};
//!
//! // Use default turn-based configuration
//! type GameTemporal = TemporalMechanic;
//!
//! let config = TemporalConfig::turn_based(3); // 3 actions per day
//! let mut state = TemporalState::with_points(3);
//!
//! // Request an action
//! let input = TemporalInput {
//! current_time: TemporalPoint::DateTime(GameDateTime::new(1, 1, 1, 10, 0)),
//! requested_action: Some(ActionRequest::new("move")),
//! ..Default::default()
//! };
//!
//! // Event collector
//! # struct TestEmitter { events: Vec<TemporalEvent> }
//! # impl EventEmitter<TemporalEvent> for TestEmitter {
//! # fn emit(&mut self, event: TemporalEvent) { self.events.push(event); }
//! # }
//! let mut emitter = TestEmitter { events: vec![] };
//!
//! // Execute
//! GameTemporal::step(&config, &mut state, input, &mut emitter);
//!
//! // Check remaining actions
//! if let ActionBudget::Points(ap) = &state.budget {
//! println!("Actions remaining: {}", ap.available);
//! }
//! ```
//!
//! # Calendar Systems
//!
//! Built-in calendar configurations:
//!
//! - **Gregorian**: Standard Earth calendar with leap years
//! - **Uniform 360**: 30 days × 12 months (common in simulations)
//! - **Custom**: Define your own month lengths and seasons
//!
//! ```
//! use issun_core::mechanics::temporal::types::CalendarConfig;
//!
//! let gregorian = CalendarConfig::gregorian();
//! let uniform = CalendarConfig::uniform_360();
//! let custom = CalendarConfig::custom(10, vec![36; 10]); // 10 months of 36 days
//! ```
//!
//! # Policy Strategies
//!
//! Available policy implementations:
//!
//! - `StandardTemporalPolicy`: Sensible defaults for most games
//! - `TurnBasedPolicy`: Optimized for turn-based RPGs
//! - `RealTimePolicy`: Optimized for action games with stamina
//! - `PersonaStylePolicy`: Calendar-focused with limited daily actions
//! - `StrategyGamePolicy`: Variable costs with season effects
//!
//! # Use Cases
//!
//! - **Turn-Based RPG**: Fixed actions per day, reset at midnight
//! - **Action RPG**: Stamina regeneration, continuous time
//! - **Strategy Game**: Variable costs, season modifiers
//! - **Life Sim**: Calendar events, time-slot activities
//! - **Roguelike**: Turn counting, hunger/time pressure
//!
//! # Global Time Interface
//!
//! For ECS integration, implement `GlobalTimeProvider` and `GlobalTimeController`:
//!
//! ```ignore
//! // In Bevy, back this with a Resource
//! impl GlobalTimeProvider for MyTimeResource {
//! fn current_tick(&self) -> u64 { self.tick }
//! fn time_flow_mode(&self) -> TimeFlowMode { self.mode }
//! }
//! ```
// Re-export core types
pub use ;
pub use TemporalPolicy;
pub use ;
/// Prelude module for convenient imports.
///
/// Import everything needed to use the temporal mechanic:
///
/// ```
/// use issun_core::mechanics::temporal::prelude::*;
/// ```