ba626acb9b
Replace hardcoded BonusForOnes/MultiplierForSixes with data-driven modifier system supporting 2 scopes (SelectedCategory, AnyCategoryClosed), 4 effect types, durability modes (Permanent, LimitedUses), and configurable targets via ScriptableObject (ModifierData). - Modifier domain: ModifierEnums, ModifierTarget, ModifierData, ModifierRuntime, ModifierEffect (dict-based strategy), ModifierPipeline (4-pass: cat-additive → cat-multiplicative → final-additive → final-multiplicative) - ScoringSystem: replaced old modifier list with ModifierPipeline integration, added OnCategoryConfirmed event - Shop MVC: ShopCatalog (SO), ShopModel, ShopView, ShopItemView, ShopController - Inventory MVC: InventoryModel (activate/deactivate/sell/durability), InventoryView, InventorySlotView, InventoryController - CurrencyBank: editor-adjustable balance with events - Persistence: SaveData + SaveSystem (Newtonsoft JSON + PlayerPrefs) - Editor: ModifierAssetCreator menu item to generate 6 example modifiers + catalog - Tests: 6 test classes covering effects, pipeline, scoring, shop, inventory, save - GameController: wired shop/inventory/save lifecycle - GameInfoView: added currency display, shop/inventory toggle buttons Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
|
|
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
|
|
|
|
public static class ModifierEffect
|
|
{
|
|
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
|
|
{
|
|
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
|
|
{ ModifierEffectType.AddFlatToFinalScore, ApplyAddFlat },
|
|
{ ModifierEffectType.MultiplyPerDieValue, ApplyMultiplyPerDieValue },
|
|
{ ModifierEffectType.MultiplyFinalScore, ApplyMultiplyFinal }
|
|
};
|
|
|
|
public static void Apply(ModifierData data, ref ScoreResult result)
|
|
{
|
|
if (Handlers.TryGetValue(data.EffectType, out var handler))
|
|
handler(data, ref result);
|
|
}
|
|
|
|
private static void ApplyAddPerDieValue(ModifierData data, ref ScoreResult result)
|
|
{
|
|
int targetValue = data.Target.DieValue;
|
|
int count = 0;
|
|
|
|
for (int i = 0; i < result.DiceValues.Length; i++)
|
|
{
|
|
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
|
count++;
|
|
}
|
|
|
|
result.FlatBonus += (int)(data.EffectValue * count);
|
|
}
|
|
|
|
private static void ApplyAddFlat(ModifierData data, ref ScoreResult result)
|
|
{
|
|
result.FlatBonus += (int)data.EffectValue;
|
|
}
|
|
|
|
private static void ApplyMultiplyPerDieValue(ModifierData data, ref ScoreResult result)
|
|
{
|
|
int targetValue = data.Target.DieValue;
|
|
|
|
for (int i = 0; i < result.DiceValues.Length; i++)
|
|
{
|
|
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
|
result.Multiplier *= data.EffectValue;
|
|
}
|
|
}
|
|
|
|
private static void ApplyMultiplyFinal(ModifierData data, ref ScoreResult result)
|
|
{
|
|
result.Multiplier *= data.EffectValue;
|
|
}
|
|
}
|