[Refactor] Replace hardcoded categories with data-driven SO system and abstract dice

- 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>
This commit is contained in:
2026-03-01 11:46:50 +07:00
parent 6a48d68f75
commit 0f9b162061
31 changed files with 845 additions and 298 deletions
@@ -1,15 +1,15 @@
using UnityEngine;
using YachtDice.Categories;
using YachtDice.Modifiers.Core;
using YachtDice.Modifiers.Definition;
using YachtDice.Modifiers.Runtime;
using YachtDice.Scoring;
namespace YachtDice.Modifiers.Conditions
{
[CreateAssetMenu(fileName = "CategoryCondition", menuName = "YachtDice/Modifiers/Conditions/Category")]
public class CategoryCondition : ConditionSO
{
[SerializeField] private YachtCategory requiredCategory;
[SerializeField] private CategoryDefinitionSO requiredCategory;
public override bool Evaluate(ModifierContext context, ModifierInstance instance)
{
@@ -17,7 +17,7 @@ namespace YachtDice.Modifiers.Conditions
}
#if UNITY_EDITOR
public static CategoryCondition CreateForTest(YachtCategory category)
public static CategoryCondition CreateForTest(CategoryDefinitionSO category)
{
var so = CreateInstance<CategoryCondition>();
so.requiredCategory = category;
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Categories;
using YachtDice.Dice;
using YachtDice.Modifiers.Runtime;
using YachtDice.Scoring;
@@ -12,8 +14,15 @@ namespace YachtDice.Modifiers.Core
public int FlatBonus;
public float Multiplier = 1f;
public float PostMultiplier = 1f;
/// <summary>Абстрактные дайсы (основной API).</summary>
public IReadOnlyList<IDie> Dice;
/// <summary>Значения дайсов (обратная совместимость с существующими модификаторами).</summary>
public int[] DiceValues;
public YachtCategory Category;
/// <summary>Категория, в которую записывается результат.</summary>
public CategoryDefinitionSO Category;
// Game state (read-only snapshot)
public int CurrentRoll;
@@ -46,8 +55,8 @@ namespace YachtDice.Modifiers.Core
public static ModifierContext CreateForScoring(
int baseScore,
int[] diceValues,
YachtCategory category,
IReadOnlyList<IDie> dice,
CategoryDefinitionSO category,
int currentRoll,
int currentTurn,
int playerCurrency,
@@ -56,7 +65,8 @@ namespace YachtDice.Modifiers.Core
return new ModifierContext
{
BaseScore = baseScore,
DiceValues = diceValues,
Dice = dice,
DiceValues = DiceCheckUtility.ExtractValues(dice),
Category = category,
CurrentRoll = currentRoll,
CurrentTurn = currentTurn,