Context
Actions currently hardcode crossedCriticalThreshold: false when creating NeedChangedEvents. This prevents the system from detecting when actions push needs across critical thresholds, which is essential for triggering urgency behaviors.
Current Implementation
events.Add(new NeedChangedEvent(
currentTime,
character.Id,
needType,
oldValue,
newValue,
crossedCriticalThreshold: false // Always false
));
Proposed Solution
Calculate whether the need crossed a critical threshold:
var threshold = needType switch
{
NeedType.Stamina => 20,
NeedType.Hunger => 30,
NeedType.Rest => 20,
NeedType.Social => 20,
NeedType.Safety => 20,
_ => 0
};
var oldCritical = oldValue < threshold;
var newCritical = newValue < threshold;
var crossedCriticalThreshold = oldCritical != newCritical;
Better approach: Add this logic to NeedsState or NeedValue to avoid duplication across actions.
Implementation Options
Option 1: Add to NeedValue
// In NeedValue.cs
public bool CrossesCriticalThreshold(int newValue)
{
var oldCritical = Value < CriticalThreshold;
var newCritical = newValue < CriticalThreshold;
return oldCritical != newCritical;
}
Option 2: Add to NeedsState
// In NeedsState.cs
public bool CheckCriticalThresholdCrossing(NeedType needType, int oldValue, int newValue)
{
// Implementation
}
Acceptance Criteria
Test Cases Needed
[Fact]
public void Execute_WhenCrossingCriticalThreshold_ReturnsEventWithCrossedTrue()
{
// Start above threshold (30), action brings below (15)
// crossedCriticalThreshold should be true
}
[Fact]
public void Execute_WhenNotCrossingThreshold_ReturnsEventWithCrossedFalse()
{
// Both old and new values are above or both below threshold
// crossedCriticalThreshold should be false
}
Related
Identified in PR #112 review by .NET Specialist
Part of Epic 3: NPC Decision Making
Labels
- type:feature
- priority:high
- area:game-logic
Context
Actions currently hardcode
crossedCriticalThreshold: falsewhen creating NeedChangedEvents. This prevents the system from detecting when actions push needs across critical thresholds, which is essential for triggering urgency behaviors.Current Implementation
Proposed Solution
Calculate whether the need crossed a critical threshold:
Better approach: Add this logic to
NeedsStateorNeedValueto avoid duplication across actions.Implementation Options
Option 1: Add to NeedValue
Option 2: Add to NeedsState
Acceptance Criteria
Test Cases Needed
Related
Identified in PR #112 review by .NET Specialist
Part of Epic 3: NPC Decision Making
Labels