68c4abace3
Replace the entire static, enum-based modifier pipeline with a composition-based, data-driven architecture using ScriptableObject polymorphism. New modifiers can now be created by assembling SO building blocks (Conditions + Effects + Behaviors) — no core code edits needed. New architecture: - Core/: TriggerType, ModifierPhase, ModifierContext, ICondition, IEffect - Definition/: ModifierDefinitionSO, ModifierBehaviorSO, ConditionSO, EffectSO, ModifierCatalogSO - Conditions/: DieValueCondition, CategoryCondition, MinScoreCondition, DiceCountCondition - Effects/: AddFlat, AddPerDie, Multiply, MultiplyPerDie, PostMultiply, AddCurrency, ConsumeCharge - Runtime/: ModifierInstance, ModifierRegistry (non-static service) - Pipeline/: async ModifierPipeline with phase ordering, tracing, anti-recursion - Editor/: ModifierDefinitionValidator with menu items - Events/: GameEventBus (non-static typed dispatcher) - DI/: GameLifetimeScope (VContainer composition root) Deleted old system: ModifierData, ModifierEffect, ModifierEnums, ModifierPipeline (static), ModifierRuntime, ModifierTarget, ShopCatalog, ModifierAssetCreator. Updated: ScoringSystem (VContainer + async), InventoryModel (delegates to ModifierRegistry), ShopModel (uses ModifierDefinitionSO), GameController (VContainer injection), SaveData (uses Runtime.ModifierSaveEntry), all views/controllers, and all test files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using YachtDice.Modifiers.Runtime;
|
|
using YachtDice.Scoring;
|
|
|
|
namespace YachtDice.Modifiers.Core
|
|
{
|
|
public class ModifierContext
|
|
{
|
|
// Scoring data
|
|
public int BaseScore;
|
|
public int FlatBonus;
|
|
public float Multiplier = 1f;
|
|
public float PostMultiplier = 1f;
|
|
public int[] DiceValues;
|
|
public YachtCategory Category;
|
|
|
|
// Game state (read-only snapshot)
|
|
public int CurrentRoll;
|
|
public int CurrentTurn;
|
|
public int PlayerCurrency;
|
|
public IReadOnlyList<ModifierInstance> AllActiveModifiers;
|
|
|
|
// Trigger info
|
|
public TriggerType Trigger;
|
|
|
|
// Side-effect accumulators
|
|
public int CurrencyDelta;
|
|
|
|
// Debug trace (populated when tracing is enabled)
|
|
public List<string> DebugLog;
|
|
|
|
public int FinalScore => Mathf.FloorToInt((BaseScore + FlatBonus) * Multiplier * PostMultiplier);
|
|
|
|
public ScoreResult ToScoreResult()
|
|
{
|
|
return new ScoreResult
|
|
{
|
|
BaseScore = BaseScore,
|
|
FlatBonus = FlatBonus,
|
|
Multiplier = Multiplier * PostMultiplier,
|
|
DiceValues = DiceValues,
|
|
Category = Category,
|
|
};
|
|
}
|
|
|
|
public static ModifierContext CreateForScoring(
|
|
int baseScore,
|
|
int[] diceValues,
|
|
YachtCategory category,
|
|
int currentRoll,
|
|
int currentTurn,
|
|
int playerCurrency,
|
|
IReadOnlyList<ModifierInstance> activeModifiers)
|
|
{
|
|
return new ModifierContext
|
|
{
|
|
BaseScore = baseScore,
|
|
DiceValues = diceValues,
|
|
Category = category,
|
|
CurrentRoll = currentRoll,
|
|
CurrentTurn = currentTurn,
|
|
PlayerCurrency = playerCurrency,
|
|
AllActiveModifiers = activeModifiers,
|
|
};
|
|
}
|
|
}
|
|
}
|