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
//! Reputation mechanic: Score/value management system.
//!
//! This module provides a policy-based reputation system that can model
//! various types of scalar value mechanics, from NPC favorability to
//! durability systems.
//!
//! # Architecture
//!
//! The reputation mechanic follows a **Policy-Based Design**:
//! - The core `ReputationMechanic<C, D, K>` is generic over three policies
//! - `C: ChangePolicy` determines how delta changes are applied
//! - `D: DecayPolicy` determines how values naturally degrade over time
//! - `K: ClampPolicy` determines how out-of-range values are handled
//! - All logic is resolved at compile time via static dispatch
//!
//! # Quick Start
//!
//! ```
//! use issun_core::mechanics::reputation::prelude::*;
//! use issun_core::mechanics::{Mechanic, EventEmitter};
//!
//! // Define your reputation type
//! type NPCFavor = ReputationMechanic<LinearChange, NoDecay, HardClamp>;
//!
//! // Create configuration
//! let config = ReputationConfig {
//! min: 0.0,
//! max: 100.0,
//! decay_rate: 1.0, // No decay
//! };
//! let mut state = ReputationState::new(50.0);
//!
//! // Prepare input for this frame
//! let input = ReputationInput {
//! delta: 10.0, // Player helped NPC
//! elapsed_time: 0,
//! };
//!
//! // Simple event collector
//! # struct TestEmitter { events: Vec<ReputationEvent> }
//! # impl EventEmitter<ReputationEvent> for TestEmitter {
//! # fn emit(&mut self, event: ReputationEvent) { self.events.push(event); }
//! # }
//! let mut emitter = TestEmitter { events: vec![] };
//!
//! // Execute one step
//! NPCFavor::step(&config, &mut state, input, &mut emitter);
//!
//! assert_eq!(state.value, 60.0);
//! ```
//!
//! # Module Organization
//!
//! ## Core Modules
//! - `types`: Basic data structures (Config, Input, Event, State)
//! - `policies`: Policy traits (ChangePolicy, DecayPolicy, ClampPolicy)
//! - `strategies`: Concrete implementations of policies
//! - `mechanic`: The `ReputationMechanic<C, D, K>` implementation
//! - `presets`: Ready-to-use type aliases for common configurations
//!
//! ## Convenience
//! - `prelude`: Convenient re-exports for common use
//!
//! # Common Use Cases
//!
//! ## NPC Favorability
//! ```
//! use issun_core::mechanics::reputation::presets::BasicReputation;
//! // LinearChange + NoDecay + HardClamp (0-100)
//! ```
//!
//! ## Item Durability
//! ```
//! use issun_core::mechanics::reputation::presets::DurabilitySystem;
//! // LinearChange + LinearDecay + ZeroClamp
//! ```
//!
//! ## Skill Progression
//! ```
//! use issun_core::mechanics::reputation::presets::SkillProgression;
//! // LogarithmicChange + ExponentialDecay + HardClamp
//! ```
//!
//! # Policy Combinations
//!
//! Mix and match policies to create custom systems:
//!
//! ```
//! use issun_core::mechanics::reputation::ReputationMechanic;
//! use issun_core::mechanics::reputation::strategies::*;
//!
//! // Custom: Temperature system
//! type Temperature = ReputationMechanic<LinearChange, LinearDecay, NoClamp>;
//!
//! // Custom: Debt system (can go negative)
//! type DebtSystem = ReputationMechanic<LinearChange, NoDecay, NoClamp>;
//!
//! // Custom: Rank with hard progression
//! type MilitaryRank = ReputationMechanic<ThresholdChange, NoDecay, HardClamp>;
//! ```
// Re-export core types for convenience
pub use ReputationMechanic;
pub use ;
pub use ;