[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
+6 -5
View File
@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using YachtDice.Categories;
using YachtDice.Scoring;
namespace YachtDice.Game
@@ -22,7 +23,7 @@ namespace YachtDice.Game
public event Action<int> OnTurnStarted;
public event Action<int> OnRollComplete;
public event Action<YachtCategory, int> OnScored;
public event Action<CategoryDefinitionSO, int> OnScored;
public event Action<int> OnGameOver;
private void Start()
@@ -75,15 +76,15 @@ namespace YachtDice.Game
Debug.Log($"Dice {index + 1} (value={diceManager.GetValue(index)}): {(isLocked ? "LOCKED" : "UNLOCKED")}");
}
public void ScoreInCategory(YachtCategory category)
public void ScoreInCategory(CategoryDefinitionSO category)
{
if (!CanScore) return;
if (scoringSystem.IsCategoryUsed(category)) return;
int[] values = diceManager.GetCurrentValues();
ScoreResult result = scoringSystem.ScoreCategory(values, category);
var dice = diceManager.GetDice();
ScoreResult result = scoringSystem.ScoreCategory(dice, category);
Debug.Log($"Scored {category}: base={result.BaseScore}, " +
Debug.Log($"Scored {category.DisplayName}: base={result.BaseScore}, " +
$"bonus=+{result.FlatBonus}, mult=x{result.Multiplier:F1}, " +
$"FINAL={result.FinalScore} | Total={scoringSystem.TotalScore}");