[Rename] Unify Die → Dice naming across the entire project
Standardize all class, interface, file, method, event, field, and variable names from the inconsistent "Die" form to "Dice", matching the existing DiceManager/DiceCatalog/DiceCollection convention. Renamed files (7 + meta): IDie→IDice, DieInstance→DiceInstance, DieDefinitionSO→DiceDefinitionSO, StandardDieSO→StandardDiceSO, DieValueCondition→DiceValueCondition, AddPerDieEffect→AddPerDiceEffect, MultiplyPerDieEffect→MultiplyPerDiceEffect. Updated all 31 consumer and test files with matching reference changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ namespace YachtDice.Categories
|
||||
/// <summary>
|
||||
/// Вычисляет очки для данного набора дайсов.
|
||||
/// </summary>
|
||||
public abstract int Calculate(IReadOnlyList<IDie> dice);
|
||||
public abstract int Calculate(IReadOnlyList<IDice> dice);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SetTestData(string testId, string testDisplayName, bool upperSection = false)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace YachtDice.Categories
|
||||
[Tooltip("Фиксированное число очков за фулл-хаус")]
|
||||
[SerializeField] private int fixedScore = 25;
|
||||
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
public override int Calculate(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int[] values = DiceCheckUtility.ExtractValues(dice);
|
||||
return DiceCheckUtility.IsFullHouse(values) ? fixedScore : 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YachtDice.Categories
|
||||
[Tooltip("Фиксированное число очков (если useFixedScore = true)")]
|
||||
[SerializeField] private int fixedScore;
|
||||
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
public override int Calculate(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int[] values = DiceCheckUtility.ExtractValues(dice);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace YachtDice.Categories
|
||||
[Tooltip("Фиксированное число очков")]
|
||||
[SerializeField] private int fixedScore = 30;
|
||||
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
public override int Calculate(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int[] values = DiceCheckUtility.ExtractValues(dice);
|
||||
return DiceCheckUtility.HasStraightRun(values, runLength) ? fixedScore : 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace YachtDice.Categories
|
||||
[CreateAssetMenu(fileName = "SumAllCategory", menuName = "YachtDice/Categories/Sum All (Chance)")]
|
||||
public class SumAllCategory : CategoryDefinition
|
||||
{
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
public override int Calculate(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int i = 0; i < dice.Count; i++)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace YachtDice.Categories
|
||||
[field: Tooltip("Значение грани для суммирования (1-6)")]
|
||||
[field: SerializeField, Range(1, 6)] public int TargetValue { get; private set; } = 1;
|
||||
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
public override int Calculate(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int i = 0; i < dice.Count; i++)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace YachtDice.Categories
|
||||
public static class DiceCheckUtility
|
||||
{
|
||||
/// <summary>Извлекает массив значений из абстрактных дайсов.</summary>
|
||||
public static int[] ExtractValues(IReadOnlyList<IDie> dice)
|
||||
public static int[] ExtractValues(IReadOnlyList<IDice> dice)
|
||||
{
|
||||
int[] values = new int[dice.Count];
|
||||
for (int i = 0; i < dice.Count; i++)
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace YachtDice.Dice
|
||||
[CreateAssetMenu(fileName = "DiceCatalog", menuName = "YachtDice/Dice/Catalog")]
|
||||
public class DiceCatalog : ScriptableObject
|
||||
{
|
||||
[SerializeField] private List<DieDefinitionSO> dice = new();
|
||||
[SerializeField] private List<DiceDefinitionSO> dice = new();
|
||||
|
||||
public IReadOnlyList<DieDefinitionSO> All => dice;
|
||||
public IReadOnlyList<DiceDefinitionSO> All => dice;
|
||||
|
||||
public DieDefinitionSO FindById(string id)
|
||||
public DiceDefinitionSO FindById(string id)
|
||||
{
|
||||
for (int i = 0; i < dice.Count; i++)
|
||||
{
|
||||
@@ -21,10 +21,10 @@ namespace YachtDice.Dice
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static DiceCatalog CreateForTest(List<DieDefinitionSO> defs)
|
||||
public static DiceCatalog CreateForTest(List<DiceDefinitionSO> defs)
|
||||
{
|
||||
var catalog = CreateInstance<DiceCatalog>();
|
||||
catalog.dice = defs ?? new List<DieDefinitionSO>();
|
||||
catalog.dice = defs ?? new List<DiceDefinitionSO>();
|
||||
return catalog;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YachtDice.Dice
|
||||
/// Абстрактное определение типа дайса.
|
||||
/// Наследники описывают конкретные виды (стандартный d6, специальные и т.д.).
|
||||
/// </summary>
|
||||
public abstract class DieDefinitionSO : ScriptableObject, IShopItem
|
||||
public abstract class DiceDefinitionSO : ScriptableObject, IShopItem
|
||||
{
|
||||
[field: Header("Identity")]
|
||||
[field: SerializeField] public string Id { get; private set; }
|
||||
@@ -28,7 +28,7 @@ namespace YachtDice.Dice
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static T CreateForTest<T>(string id, string displayName = null,
|
||||
int shopPrice = 0, string description = null) where T : DieDefinitionSO
|
||||
int shopPrice = 0, string description = null) where T : DiceDefinitionSO
|
||||
{
|
||||
var so = CreateInstance<T>();
|
||||
so.Id = id;
|
||||
@@ -4,20 +4,20 @@ namespace YachtDice.Dice
|
||||
/// Рантайм-состояние одного дайса.
|
||||
/// Хранит текущее значение верхней грани и ссылку на определение типа.
|
||||
/// </summary>
|
||||
public class DieInstance : IDie
|
||||
public class DiceInstance : IDice
|
||||
{
|
||||
public DieDefinitionSO Definition { get; }
|
||||
public DiceDefinitionSO Definition { get; }
|
||||
public int Value { get; set; }
|
||||
public bool IsLocked { get; set; }
|
||||
|
||||
public DieInstance(DieDefinitionSO definition)
|
||||
public DiceInstance(DiceDefinitionSO definition)
|
||||
{
|
||||
Definition = definition;
|
||||
Value = 0;
|
||||
IsLocked = false;
|
||||
}
|
||||
|
||||
public DieInstance(DieDefinitionSO definition, int initialValue)
|
||||
public DiceInstance(DiceDefinitionSO definition, int initialValue)
|
||||
{
|
||||
Definition = definition;
|
||||
Value = initialValue;
|
||||
@@ -16,7 +16,7 @@ namespace YachtDice.Dice
|
||||
[SerializeField] private Rigidbody rb;
|
||||
|
||||
/// <summary>Определение типа дайса (назначается в инспекторе).</summary>
|
||||
[field: SerializeField] public DieDefinitionSO Definition { get; private set; }
|
||||
[field: SerializeField] public DiceDefinitionSO Definition { get; private set; }
|
||||
|
||||
[Header("Throw Settings")]
|
||||
[Tooltip("Сила подброса вверх")]
|
||||
|
||||
@@ -4,12 +4,12 @@ namespace YachtDice.Dice
|
||||
/// Минимальный контракт для любого дайса.
|
||||
/// Каждый дайс всегда имеет текущее значение (верхняя грань) и определение типа.
|
||||
/// </summary>
|
||||
public interface IDie
|
||||
public interface IDice
|
||||
{
|
||||
/// <summary>Текущее значение верхней грани.</summary>
|
||||
int Value { get; }
|
||||
|
||||
/// <summary>Определение типа дайса (ScriptableObject).</summary>
|
||||
DieDefinitionSO Definition { get; }
|
||||
DiceDefinitionSO Definition { get; }
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ namespace YachtDice.Dice
|
||||
/// Стандартный дайс с настраиваемыми значениями граней.
|
||||
/// По умолчанию — классический d6 (1-6).
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "StandardDie", menuName = "YachtDice/Dice/Standard Die")]
|
||||
public class StandardDieSO : DieDefinitionSO
|
||||
[CreateAssetMenu(fileName = "StandardDice", menuName = "YachtDice/Dice/Standard Dice")]
|
||||
public class StandardDiceSO : DiceDefinitionSO
|
||||
{
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private int[] faceValues = { 1, 2, 3, 4, 5, 6 };
|
||||
@@ -22,9 +22,9 @@ namespace YachtDice.Dice
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static StandardDieSO CreateStandardD6ForTest()
|
||||
public static StandardDiceSO CreateStandardD6ForTest()
|
||||
{
|
||||
var so = CreateForTest<StandardDieSO>("standard_d6", "Стандартный d6");
|
||||
var so = CreateForTest<StandardDiceSO>("standard_d6", "Стандартный d6");
|
||||
so.faceValues = new[] { 1, 2, 3, 4, 5, 6 };
|
||||
return so;
|
||||
}
|
||||
@@ -10,22 +10,22 @@ namespace YachtDice.Game
|
||||
[SerializeField] private List<DiceRoller> diceRollers = new();
|
||||
|
||||
public event Action OnAllDiceSettled;
|
||||
public event Action<int, int> OnDieSettled;
|
||||
public event Action<int, int> OnDiceSettled;
|
||||
|
||||
public int DiceCount => diceRollers.Count;
|
||||
|
||||
private DieInstance[] diceInstances;
|
||||
private DiceInstance[] diceInstances;
|
||||
private int pendingCount;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
int count = diceRollers.Count;
|
||||
diceInstances = new DieInstance[count];
|
||||
diceInstances = new DiceInstance[count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var definition = diceRollers[i].Definition;
|
||||
diceInstances[i] = new DieInstance(definition);
|
||||
diceInstances[i] = new DiceInstance(definition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace YachtDice.Game
|
||||
{
|
||||
diceRollers[capturedIndex].OnRollFinished -= Handler;
|
||||
diceInstances[capturedIndex].Value = value;
|
||||
OnDieSettled?.Invoke(capturedIndex, value);
|
||||
OnDiceSettled?.Invoke(capturedIndex, value);
|
||||
|
||||
pendingCount--;
|
||||
if (pendingCount <= 0)
|
||||
@@ -81,7 +81,7 @@ namespace YachtDice.Game
|
||||
}
|
||||
|
||||
/// <summary>Возвращает абстрактный список дайсов (основной API).</summary>
|
||||
public IReadOnlyList<IDie> GetDice() => diceInstances;
|
||||
public IReadOnlyList<IDice> GetDice() => diceInstances;
|
||||
|
||||
/// <summary>Возвращает копию текущих значений (обратная совместимость).</summary>
|
||||
public int[] GetCurrentValues()
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace YachtDice.Modifiers.Conditions
|
||||
[CreateAssetMenu(fileName = "DiceCountCondition", menuName = "YachtDice/Modifiers/Conditions/Dice Count")]
|
||||
public class DiceCountCondition : Condition
|
||||
{
|
||||
[Tooltip("Die face value to count (1-6). 0 = any value.")]
|
||||
[Tooltip("Dice face value to count (1-6). 0 = any value.")]
|
||||
[SerializeField, Range(0, 6)] private int targetValue;
|
||||
|
||||
[Tooltip("Minimum number of dice that must match.")]
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@ using YachtDice.Modifiers.Runtime;
|
||||
|
||||
namespace YachtDice.Modifiers.Conditions
|
||||
{
|
||||
[CreateAssetMenu(fileName = "DieValueCondition", menuName = "YachtDice/Modifiers/Conditions/Die Value")]
|
||||
public class DieValueCondition : Condition
|
||||
[CreateAssetMenu(fileName = "DiceValueCondition", menuName = "YachtDice/Modifiers/Conditions/Dice Value")]
|
||||
public class DiceValueCondition : Condition
|
||||
{
|
||||
[SerializeField, Range(1, 6)] private int targetValue = 1;
|
||||
[SerializeField] private int minCount = 1;
|
||||
@@ -25,9 +25,9 @@ namespace YachtDice.Modifiers.Conditions
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static DieValueCondition CreateForTest(int targetValue, int minCount = 1)
|
||||
public static DiceValueCondition CreateForTest(int targetValue, int minCount = 1)
|
||||
{
|
||||
var so = CreateInstance<DieValueCondition>();
|
||||
var so = CreateInstance<DiceValueCondition>();
|
||||
so.targetValue = targetValue;
|
||||
so.minCount = minCount;
|
||||
return so;
|
||||
@@ -16,7 +16,7 @@ namespace YachtDice.Modifiers.Core
|
||||
public float PostMultiplier = 1f;
|
||||
|
||||
/// <summary>Абстрактные дайсы (основной API).</summary>
|
||||
public IReadOnlyList<IDie> Dice;
|
||||
public IReadOnlyList<IDice> Dice;
|
||||
|
||||
/// <summary>Значения дайсов (обратная совместимость с существующими модификаторами).</summary>
|
||||
public int[] DiceValues;
|
||||
@@ -55,7 +55,7 @@ namespace YachtDice.Modifiers.Core
|
||||
|
||||
public static ModifierContext CreateForScoring(
|
||||
int baseScore,
|
||||
IReadOnlyList<IDie> dice,
|
||||
IReadOnlyList<IDice> dice,
|
||||
CategoryDefinition category,
|
||||
int currentRoll,
|
||||
int currentTurn,
|
||||
|
||||
+12
-12
@@ -6,14 +6,14 @@ using YachtDice.Modifiers.Runtime;
|
||||
|
||||
namespace YachtDice.Modifiers.Effects
|
||||
{
|
||||
[CreateAssetMenu(fileName = "AddPerDieEffect", menuName = "YachtDice/Modifiers/Effects/Add Per Die")]
|
||||
public class AddPerDieEffect : Effect
|
||||
[CreateAssetMenu(fileName = "AddPerDiceEffect", menuName = "YachtDice/Modifiers/Effects/Add Per Dice")]
|
||||
public class AddPerDiceEffect : Effect
|
||||
{
|
||||
[Tooltip("Points to add per matching die.")]
|
||||
[SerializeField] private int valuePerDie;
|
||||
[Tooltip("Points to add per matching dice.")]
|
||||
[SerializeField] private int valuePerDice;
|
||||
|
||||
[Tooltip("Die face value to match (1-6). 0 = any/all dice.")]
|
||||
[SerializeField, Range(0, 6)] private int targetDieValue;
|
||||
[Tooltip("Dice face value to match (1-6). 0 = any/all dice.")]
|
||||
[SerializeField, Range(0, 6)] private int targetDiceValue;
|
||||
|
||||
public override UniTask Apply(ModifierContext context, ModifierInstance instance)
|
||||
{
|
||||
@@ -22,21 +22,21 @@ namespace YachtDice.Modifiers.Effects
|
||||
int count = 0;
|
||||
for (int i = 0; i < context.DiceValues.Length; i++)
|
||||
{
|
||||
if (targetDieValue == 0 || context.DiceValues[i] == targetDieValue)
|
||||
if (targetDiceValue == 0 || context.DiceValues[i] == targetDiceValue)
|
||||
count++;
|
||||
}
|
||||
|
||||
context.FlatBonus += valuePerDie * count * instance.Stacks;
|
||||
context.FlatBonus += valuePerDice * count * instance.Stacks;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static AddPerDieEffect CreateForTest(int valuePerDie, int targetDieValue = 0,
|
||||
public static AddPerDiceEffect CreateForTest(int valuePerDice, int targetDiceValue = 0,
|
||||
ModifierPhase phase = ModifierPhase.Additive, int priority = 0)
|
||||
{
|
||||
var so = CreateInstance<AddPerDieEffect>();
|
||||
so.valuePerDie = valuePerDie;
|
||||
so.targetDieValue = targetDieValue;
|
||||
var so = CreateInstance<AddPerDiceEffect>();
|
||||
so.valuePerDice = valuePerDice;
|
||||
so.targetDiceValue = targetDiceValue;
|
||||
so.SetPhaseForTest(phase);
|
||||
so.SetPriorityForTest(priority);
|
||||
return so;
|
||||
@@ -0,0 +1,44 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using YachtDice.Modifiers.Core;
|
||||
using YachtDice.Modifiers.Definition;
|
||||
using YachtDice.Modifiers.Runtime;
|
||||
|
||||
namespace YachtDice.Modifiers.Effects
|
||||
{
|
||||
[CreateAssetMenu(fileName = "MultiplyPerDiceEffect", menuName = "YachtDice/Modifiers/Effects/Multiply Per Dice")]
|
||||
public class MultiplyPerDiceEffect : Effect
|
||||
{
|
||||
[Tooltip("Multiplier to apply per matching dice.")]
|
||||
[SerializeField] private float multiplierPerDice = 1f;
|
||||
|
||||
[Tooltip("Dice face value to match (1-6). 0 = any/all dice.")]
|
||||
[SerializeField, Range(0, 6)] private int targetDiceValue;
|
||||
|
||||
public override UniTask Apply(ModifierContext context, ModifierInstance instance)
|
||||
{
|
||||
if (context.DiceValues == null) return UniTask.CompletedTask;
|
||||
|
||||
for (int i = 0; i < context.DiceValues.Length; i++)
|
||||
{
|
||||
if (targetDiceValue == 0 || context.DiceValues[i] == targetDiceValue)
|
||||
context.Multiplier *= multiplierPerDice;
|
||||
}
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static MultiplyPerDiceEffect CreateForTest(float multiplierPerDice, int targetDiceValue = 0,
|
||||
ModifierPhase phase = ModifierPhase.Multiplicative, int priority = 0)
|
||||
{
|
||||
var so = CreateInstance<MultiplyPerDiceEffect>();
|
||||
so.multiplierPerDice = multiplierPerDice;
|
||||
so.targetDiceValue = targetDiceValue;
|
||||
so.SetPhaseForTest(phase);
|
||||
so.SetPriorityForTest(priority);
|
||||
return so;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using YachtDice.Modifiers.Core;
|
||||
using YachtDice.Modifiers.Definition;
|
||||
using YachtDice.Modifiers.Runtime;
|
||||
|
||||
namespace YachtDice.Modifiers.Effects
|
||||
{
|
||||
[CreateAssetMenu(fileName = "MultiplyPerDieEffect", menuName = "YachtDice/Modifiers/Effects/Multiply Per Die")]
|
||||
public class MultiplyPerDieEffect : Effect
|
||||
{
|
||||
[Tooltip("Multiplier to apply per matching die.")]
|
||||
[SerializeField] private float multiplierPerDie = 1f;
|
||||
|
||||
[Tooltip("Die face value to match (1-6). 0 = any/all dice.")]
|
||||
[SerializeField, Range(0, 6)] private int targetDieValue;
|
||||
|
||||
public override UniTask Apply(ModifierContext context, ModifierInstance instance)
|
||||
{
|
||||
if (context.DiceValues == null) return UniTask.CompletedTask;
|
||||
|
||||
for (int i = 0; i < context.DiceValues.Length; i++)
|
||||
{
|
||||
if (targetDieValue == 0 || context.DiceValues[i] == targetDieValue)
|
||||
context.Multiplier *= multiplierPerDie;
|
||||
}
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static MultiplyPerDieEffect CreateForTest(float multiplierPerDie, int targetDieValue = 0,
|
||||
ModifierPhase phase = ModifierPhase.Multiplicative, int priority = 0)
|
||||
{
|
||||
var so = CreateInstance<MultiplyPerDieEffect>();
|
||||
so.multiplierPerDie = multiplierPerDie;
|
||||
so.targetDieValue = targetDieValue;
|
||||
so.SetPhaseForTest(phase);
|
||||
so.SetPriorityForTest(priority);
|
||||
return so;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ namespace YachtDice.Player
|
||||
{
|
||||
public class DiceCollection
|
||||
{
|
||||
private readonly List<DieDefinitionSO> ownedDice = new();
|
||||
private readonly List<DiceDefinitionSO> ownedDice = new();
|
||||
|
||||
public event Action OnChanged;
|
||||
|
||||
public IReadOnlyList<DieDefinitionSO> OwnedDice => ownedDice;
|
||||
public IReadOnlyList<DiceDefinitionSO> OwnedDice => ownedDice;
|
||||
|
||||
public void Add(DieDefinitionSO definition)
|
||||
public void Add(DiceDefinitionSO definition)
|
||||
{
|
||||
if (definition == null) return;
|
||||
if (OwnsById(definition.Id)) return;
|
||||
@@ -21,7 +21,7 @@ namespace YachtDice.Player
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Remove(DieDefinitionSO definition)
|
||||
public void Remove(DiceDefinitionSO definition)
|
||||
{
|
||||
if (ownedDice.Remove(definition))
|
||||
OnChanged?.Invoke();
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace YachtDice.Scoring
|
||||
|
||||
public int FinalScore => Mathf.FloorToInt((BaseScore + FlatBonus) * Multiplier);
|
||||
|
||||
public static ScoreResult Create(int baseScore, IReadOnlyList<IDie> dice, CategoryDefinition category)
|
||||
public static ScoreResult Create(int baseScore, IReadOnlyList<IDice> dice, CategoryDefinition category)
|
||||
{
|
||||
return new ScoreResult
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace YachtDice.Scoring
|
||||
|
||||
public bool IsComplete => CategoriesFilledCount >= TotalCategoryCount;
|
||||
|
||||
public ScoreResult PreviewScore(IReadOnlyList<IDie> dice, CategoryDefinition category,
|
||||
public ScoreResult PreviewScore(IReadOnlyList<IDice> dice, CategoryDefinition category,
|
||||
int currentRoll = 0, int currentTurn = 0, int playerCurrency = 0)
|
||||
{
|
||||
int baseScore = category.Calculate(dice);
|
||||
@@ -75,7 +75,7 @@ namespace YachtDice.Scoring
|
||||
return context.ToScoreResult();
|
||||
}
|
||||
|
||||
public async UniTask<ScoreResult> ScoreCategoryAsync(IReadOnlyList<IDie> dice, CategoryDefinition category,
|
||||
public async UniTask<ScoreResult> ScoreCategoryAsync(IReadOnlyList<IDice> dice, CategoryDefinition category,
|
||||
int currentRoll, int currentTurn, int playerCurrency)
|
||||
{
|
||||
if (usedCategories.Contains(category))
|
||||
@@ -118,7 +118,7 @@ namespace YachtDice.Scoring
|
||||
return result;
|
||||
}
|
||||
|
||||
public ScoreResult ScoreCategory(IReadOnlyList<IDie> dice, CategoryDefinition category)
|
||||
public ScoreResult ScoreCategory(IReadOnlyList<IDice> dice, CategoryDefinition category)
|
||||
{
|
||||
if (usedCategories.Contains(category))
|
||||
throw new InvalidOperationException($"Category {category.DisplayName} has already been scored.");
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace YachtDice.Shop
|
||||
{
|
||||
/// <summary>
|
||||
/// Any item that can appear in the shop.
|
||||
/// Implemented by ScriptableObject definitions (ModifierDefinition, DieDefinitionSO).
|
||||
/// Implemented by ScriptableObject definitions (ModifierDefinition, DiceDefinitionSO).
|
||||
/// </summary>
|
||||
public interface IShopItem
|
||||
{
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace YachtDice.Shop
|
||||
case ModifierDefinition modifier:
|
||||
inventoryModel.AddModifier(modifier);
|
||||
break;
|
||||
case DieDefinitionSO die:
|
||||
diceCollection.Add(die);
|
||||
case DiceDefinitionSO dice:
|
||||
diceCollection.Add(dice);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Add_IncreasesCount()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Add_DuplicateId_Ignored()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Add(die);
|
||||
@@ -47,7 +47,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void OwnsById_ReturnsTrueWhenOwned()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Remove_DecreasesCount()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Remove(die);
|
||||
@@ -74,7 +74,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void GetSaveData_ReturnsIds()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
|
||||
@@ -86,8 +86,8 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void LoadSaveData_RestoresDice()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DieDefinitionSO> { die });
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinitionSO> { die });
|
||||
var ids = new List<string> { "standard_d6" };
|
||||
|
||||
collection.LoadSaveData(ids, catalog);
|
||||
@@ -99,7 +99,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void LoadSaveData_SkipsMissingIds()
|
||||
{
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DieDefinitionSO>());
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinitionSO>());
|
||||
var ids = new List<string> { "nonexistent" };
|
||||
|
||||
collection.LoadSaveData(ids, catalog);
|
||||
@@ -110,7 +110,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Clear_RemovesAll()
|
||||
{
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Clear();
|
||||
@@ -124,7 +124,7 @@ namespace YachtDice.Tests
|
||||
bool fired = false;
|
||||
collection.OnChanged += () => fired = true;
|
||||
|
||||
var die = StandardDieSO.CreateStandardD6ForTest();
|
||||
var die = StandardDiceSO.CreateStandardD6ForTest();
|
||||
collection.Add(die);
|
||||
|
||||
Assert.IsTrue(fired);
|
||||
|
||||
@@ -41,12 +41,12 @@ namespace YachtDice.Tests
|
||||
};
|
||||
}
|
||||
|
||||
// ── AddPerDieEffect ─────────────────────────────────────────
|
||||
// ── AddPerDiceEffect ─────────────────────────────────────────
|
||||
|
||||
[Test]
|
||||
public void AddPerDieEffect_CountsMatchingDice()
|
||||
public void AddPerDiceEffect_CountsMatchingDice()
|
||||
{
|
||||
var effect = AddPerDieEffect.CreateForTest(10, targetDieValue: 1);
|
||||
var effect = AddPerDiceEffect.CreateForTest(10, targetDiceValue: 1);
|
||||
var ctx = CreateContext(5, new[] { 1, 1, 3, 4, 1 });
|
||||
var inst = CreateInstance();
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddPerDieEffect_ZeroTarget_CountsAllDice()
|
||||
public void AddPerDiceEffect_ZeroTarget_CountsAllDice()
|
||||
{
|
||||
var effect = AddPerDieEffect.CreateForTest(2, targetDieValue: 0);
|
||||
var effect = AddPerDiceEffect.CreateForTest(2, targetDiceValue: 0);
|
||||
var ctx = CreateContext(10, new[] { 1, 2, 3, 4, 5 });
|
||||
var inst = CreateInstance();
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddPerDieEffect_NoMatches_ZeroBonus()
|
||||
public void AddPerDiceEffect_NoMatches_ZeroBonus()
|
||||
{
|
||||
var effect = AddPerDieEffect.CreateForTest(10, targetDieValue: 6);
|
||||
var effect = AddPerDiceEffect.CreateForTest(10, targetDiceValue: 6);
|
||||
var ctx = CreateContext(5, new[] { 1, 2, 3, 4, 5 });
|
||||
var inst = CreateInstance();
|
||||
|
||||
@@ -80,9 +80,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddPerDieEffect_ScalesWithStacks()
|
||||
public void AddPerDiceEffect_ScalesWithStacks()
|
||||
{
|
||||
var effect = AddPerDieEffect.CreateForTest(10, targetDieValue: 1);
|
||||
var effect = AddPerDiceEffect.CreateForTest(10, targetDiceValue: 1);
|
||||
var ctx = CreateContext(5, new[] { 1, 1, 3, 4, 1 });
|
||||
var inst = CreateInstance();
|
||||
inst.Stacks = 2;
|
||||
@@ -119,12 +119,12 @@ namespace YachtDice.Tests
|
||||
Assert.AreEqual(45, ctx.FlatBonus); // 15 * 3 stacks
|
||||
}
|
||||
|
||||
// ── MultiplyPerDieEffect ────────────────────────────────────
|
||||
// ── MultiplyPerDiceEffect ────────────────────────────────────
|
||||
|
||||
[Test]
|
||||
public void MultiplyPerDieEffect_MultipliesPerMatch()
|
||||
public void MultiplyPerDiceEffect_MultipliesPerMatch()
|
||||
{
|
||||
var effect = MultiplyPerDieEffect.CreateForTest(2f, targetDieValue: 6);
|
||||
var effect = MultiplyPerDiceEffect.CreateForTest(2f, targetDiceValue: 6);
|
||||
var ctx = CreateContext(18, new[] { 6, 6, 6, 1, 2 });
|
||||
var inst = CreateInstance();
|
||||
|
||||
@@ -134,9 +134,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultiplyPerDieEffect_NoMatches_MultiplierUnchanged()
|
||||
public void MultiplyPerDiceEffect_NoMatches_MultiplierUnchanged()
|
||||
{
|
||||
var effect = MultiplyPerDieEffect.CreateForTest(3f, targetDieValue: 6);
|
||||
var effect = MultiplyPerDiceEffect.CreateForTest(3f, targetDiceValue: 6);
|
||||
var ctx = CreateContext(10, new[] { 1, 2, 3, 4, 5 });
|
||||
var inst = CreateInstance();
|
||||
|
||||
|
||||
@@ -186,8 +186,8 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Execute_MultipleModifiers_CorrectOrder()
|
||||
{
|
||||
var perDieAdd = AddPerDieEffect.CreateForTest(2, targetDieValue: 3, phase: ModifierPhase.Additive);
|
||||
var perDieMul = MultiplyPerDieEffect.CreateForTest(1.5f, targetDieValue: 3, phase: ModifierPhase.Multiplicative);
|
||||
var perDieAdd = AddPerDiceEffect.CreateForTest(2, targetDiceValue: 3, phase: ModifierPhase.Additive);
|
||||
var perDieMul = MultiplyPerDiceEffect.CreateForTest(1.5f, targetDiceValue: 3, phase: ModifierPhase.Multiplicative);
|
||||
var flatAdd = AddFlatScoreEffect.CreateForTest(10, ModifierPhase.Additive, priority: 10);
|
||||
var finalMul = MultiplyScoreEffect.CreateForTest(2f, ModifierPhase.Multiplicative, priority: 10);
|
||||
|
||||
@@ -283,12 +283,12 @@ namespace YachtDice.Tests
|
||||
Assert.IsTrue(result.DebugLog.Count > 0);
|
||||
}
|
||||
|
||||
// ── DieValue Condition ──────────────────────────────────────
|
||||
// ── DiceValue Condition ──────────────────────────────────────
|
||||
|
||||
[Test]
|
||||
public void Execute_DieValueCondition_OnlyTriggersOnMatch()
|
||||
public void Execute_DiceValueCondition_OnlyTriggersOnMatch()
|
||||
{
|
||||
var condition = DieValueCondition.CreateForTest(6, minCount: 3);
|
||||
var condition = DiceValueCondition.CreateForTest(6, minCount: 3);
|
||||
var effect = AddFlatScoreEffect.CreateForTest(100);
|
||||
|
||||
var def = CreateDef("sixes-bonus", TriggerType.OnCategoryScored,
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace YachtDice.Tests
|
||||
private CategoryDefinition twosCategory;
|
||||
private CategoryDefinition chanceCategory;
|
||||
private CategoryCatalog catalog;
|
||||
private DieDefinitionSO standardDie;
|
||||
private DiceDefinitionSO standardDice;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
standardDie = DieDefinitionSO.CreateForTest<StandardDieSO>("d6", "d6");
|
||||
standardDice = DiceDefinitionSO.CreateForTest<StandardDiceSO>("d6", "d6");
|
||||
|
||||
yachtCategory = NOfAKindCategory.CreateForTest("yacht", "Яхта", 5, fixedScoreMode: true, score: 50);
|
||||
onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
@@ -43,7 +43,7 @@ namespace YachtDice.Tests
|
||||
Object.DestroyImmediate(twosCategory);
|
||||
Object.DestroyImmediate(chanceCategory);
|
||||
Object.DestroyImmediate(catalog);
|
||||
Object.DestroyImmediate(standardDie);
|
||||
Object.DestroyImmediate(standardDice);
|
||||
}
|
||||
|
||||
private ScoringSystem CreateScoringSystem()
|
||||
@@ -52,11 +52,11 @@ namespace YachtDice.Tests
|
||||
return go.AddComponent<ScoringSystem>();
|
||||
}
|
||||
|
||||
private IReadOnlyList<IDie> CreateDice(params int[] values)
|
||||
private IReadOnlyList<IDice> CreateDice(params int[] values)
|
||||
{
|
||||
var dice = new DieInstance[values.Length];
|
||||
var dice = new DiceInstance[values.Length];
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
dice[i] = new DieInstance(standardDie, values[i]);
|
||||
dice[i] = new DiceInstance(standardDice, values[i]);
|
||||
return dice;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +140,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryPurchase_DieItem_AddsToDiceCollection()
|
||||
public void TryPurchase_DiceItem_AddsToDiceCollection()
|
||||
{
|
||||
var die = DieDefinitionSO.CreateForTest<StandardDieSO>("test_die", shopPrice: 100);
|
||||
var die = DiceDefinitionSO.CreateForTest<StandardDiceSO>("test_die", shopPrice: 100);
|
||||
|
||||
bool result = shop.TryPurchase(die);
|
||||
|
||||
@@ -152,9 +152,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryPurchase_DieItem_CannotBeBoughtTwice()
|
||||
public void TryPurchase_DiceItem_CannotBeBoughtTwice()
|
||||
{
|
||||
var die = DieDefinitionSO.CreateForTest<StandardDieSO>("unique_die", shopPrice: 100);
|
||||
var die = DiceDefinitionSO.CreateForTest<StandardDiceSO>("unique_die", shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(die);
|
||||
bool secondResult = shop.TryPurchase(die);
|
||||
@@ -165,9 +165,9 @@ namespace YachtDice.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItemState_Die_Owned_AfterPurchase()
|
||||
public void GetItemState_Dice_Owned_AfterPurchase()
|
||||
{
|
||||
var die = DieDefinitionSO.CreateForTest<StandardDieSO>("die1", shopPrice: 50);
|
||||
var die = DiceDefinitionSO.CreateForTest<StandardDiceSO>("die1", shopPrice: 50);
|
||||
|
||||
shop.TryPurchase(die);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace YachtDice.UI
|
||||
SetRollButtonState(true, 0, 3);
|
||||
}
|
||||
|
||||
public void SetDieValue(int index, int value)
|
||||
public void SetDiceValue(int index, int value)
|
||||
{
|
||||
if (index >= 0 && index < diceValueTexts.Length)
|
||||
diceValueTexts[index].text = value.ToString();
|
||||
@@ -55,7 +55,7 @@ namespace YachtDice.UI
|
||||
diceValueTexts[i].text = values[i].ToString();
|
||||
}
|
||||
|
||||
public void SetDieLocked(int index, bool isLocked)
|
||||
public void SetDiceLocked(int index, bool isLocked)
|
||||
{
|
||||
if (index >= 0 && index < diceBackgrounds.Length)
|
||||
diceBackgrounds[index].color = isLocked ? lockedColor : unlockedColor;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace YachtDice.UI
|
||||
gameManager.OnRollComplete += HandleRollComplete;
|
||||
gameManager.OnScored += HandleScored;
|
||||
gameManager.OnGameOver += HandleGameOver;
|
||||
diceManager.OnDieSettled += HandleDieSettled;
|
||||
diceManager.OnDiceSettled += HandleDiceSettled;
|
||||
|
||||
// View → Controller
|
||||
scoreCardView.OnCategorySelected += HandleCategorySelected;
|
||||
@@ -108,7 +108,7 @@ namespace YachtDice.UI
|
||||
gameManager.OnRollComplete -= HandleRollComplete;
|
||||
gameManager.OnScored -= HandleScored;
|
||||
gameManager.OnGameOver -= HandleGameOver;
|
||||
diceManager.OnDieSettled -= HandleDieSettled;
|
||||
diceManager.OnDiceSettled -= HandleDiceSettled;
|
||||
|
||||
scoreCardView.OnCategorySelected -= HandleCategorySelected;
|
||||
dicePanelView.OnRollClicked -= HandleRollClicked;
|
||||
@@ -217,9 +217,9 @@ namespace YachtDice.UI
|
||||
UpdatePreviewScores();
|
||||
}
|
||||
|
||||
private void HandleDieSettled(int index, int value)
|
||||
private void HandleDiceSettled(int index, int value)
|
||||
{
|
||||
dicePanelView.SetDieValue(index, value);
|
||||
dicePanelView.SetDiceValue(index, value);
|
||||
}
|
||||
|
||||
private void HandleScored(CategoryDefinition category, int finalScore)
|
||||
@@ -261,7 +261,7 @@ namespace YachtDice.UI
|
||||
gameManager.ToggleDiceLock(index);
|
||||
|
||||
bool isLocked = diceManager.IsLocked(index);
|
||||
dicePanelView.SetDieLocked(index, isLocked);
|
||||
dicePanelView.SetDiceLocked(index, isLocked);
|
||||
}
|
||||
|
||||
private void HandleCategorySelected(CategoryDefinition category)
|
||||
|
||||
Reference in New Issue
Block a user