[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 -3
View File
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using YachtDice.Categories;
using YachtDice.Dice;
namespace YachtDice.Scoring
{
@@ -10,18 +13,18 @@ namespace YachtDice.Scoring
public int FlatBonus;
public float Multiplier;
public int[] DiceValues;
public YachtCategory Category;
public CategoryDefinitionSO Category;
public int FinalScore => Mathf.FloorToInt((BaseScore + FlatBonus) * Multiplier);
public static ScoreResult Create(int baseScore, int[] diceValues, YachtCategory category)
public static ScoreResult Create(int baseScore, IReadOnlyList<IDie> dice, CategoryDefinitionSO category)
{
return new ScoreResult
{
BaseScore = baseScore,
FlatBonus = 0,
Multiplier = 1f,
DiceValues = diceValues,
DiceValues = DiceCheckUtility.ExtractValues(dice),
Category = category
};
}