0f9b162061
- Add abstract dice system (IDie interface, DieDefinitionSO, StandardDieSO, DieInstance) to support future custom dice types while keeping backward compat via int[] DiceValues - Replace YachtCategory enum and CategoryScorer switch with CategoryDefinitionSO hierarchy: SumOfValueCategorySO, NOfAKindCategorySO, FullHouseCategorySO, StraightCategorySO, SumAllCategorySO - Add CategoryCatalogSO for ordered category collections and DiceCheckUtility for shared logic - Refactor ScoringSystem, Views, GameManager, GameController to use SO references - Update CategoryCondition modifier to use SO reference instead of enum - Update all editor tests to use SO-based categories and DieInstance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using YachtDice.Categories;
|
|
using YachtDice.Dice;
|
|
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;
|
|
|
|
/// <summary>Абстрактные дайсы (основной API).</summary>
|
|
public IReadOnlyList<IDie> Dice;
|
|
|
|
/// <summary>Значения дайсов (обратная совместимость с существующими модификаторами).</summary>
|
|
public int[] DiceValues;
|
|
|
|
/// <summary>Категория, в которую записывается результат.</summary>
|
|
public CategoryDefinitionSO 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,
|
|
IReadOnlyList<IDie> dice,
|
|
CategoryDefinitionSO category,
|
|
int currentRoll,
|
|
int currentTurn,
|
|
int playerCurrency,
|
|
IReadOnlyList<ModifierInstance> activeModifiers)
|
|
{
|
|
return new ModifierContext
|
|
{
|
|
BaseScore = baseScore,
|
|
Dice = dice,
|
|
DiceValues = DiceCheckUtility.ExtractValues(dice),
|
|
Category = category,
|
|
CurrentRoll = currentRoll,
|
|
CurrentTurn = currentTurn,
|
|
PlayerCurrency = playerCurrency,
|
|
AllActiveModifiers = activeModifiers,
|
|
};
|
|
}
|
|
}
|
|
}
|