[Add] Data
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++)
|
||||
|
||||
@@ -4,20 +4,20 @@ namespace YachtDice.Dice
|
||||
/// Рантайм-состояние одного дайса.
|
||||
/// Хранит текущее значение верхней грани и ссылку на определение типа.
|
||||
/// </summary>
|
||||
public class DieInstance : IDie
|
||||
public class DiceInstance : IDice
|
||||
{
|
||||
public DiсeDefinition Definition { get; }
|
||||
public int Value { get; set; }
|
||||
public bool IsLocked { get; set; }
|
||||
|
||||
public DieInstance(DiсeDefinition definition)
|
||||
public DiceInstance(DiсeDefinition definition)
|
||||
{
|
||||
Definition = definition;
|
||||
Value = 0;
|
||||
IsLocked = false;
|
||||
}
|
||||
|
||||
public DieInstance(DiсeDefinition definition, int initialValue)
|
||||
public DiceInstance(DiсeDefinition definition, int initialValue)
|
||||
{
|
||||
Definition = definition;
|
||||
Value = initialValue;
|
||||
@@ -4,7 +4,7 @@ namespace YachtDice.Dice
|
||||
/// Минимальный контракт для любого дайса.
|
||||
/// Каждый дайс всегда имеет текущее значение (верхняя грань) и определение типа.
|
||||
/// </summary>
|
||||
public interface IDie
|
||||
public interface IDice
|
||||
{
|
||||
/// <summary>Текущее значение верхней грани.</summary>
|
||||
int Value { get; }
|
||||
@@ -6,7 +6,7 @@ namespace YachtDice.Dice
|
||||
/// Стандартный дайс с настраиваемыми значениями граней.
|
||||
/// По умолчанию — классический d6 (1-6).
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "StandardDie", menuName = "YachtDice/Dice/Standard Die")]
|
||||
[CreateAssetMenu(fileName = "StandardDice", menuName = "YachtDice/Dice/Standard Dice")]
|
||||
public class StandardDiсe : DiсeDefinition
|
||||
{
|
||||
[Header("Configuration")]
|
||||
|
||||
@@ -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.")]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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(_standardDiсe, values[i]);
|
||||
dice[i] = new DiceInstance(_standardDiсe, values[i]);
|
||||
return dice;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,7 +217,7 @@ namespace YachtDice.UI
|
||||
UpdatePreviewScores();
|
||||
}
|
||||
|
||||
private void HandleDieSettled(int index, int value)
|
||||
private void HandleDiceSettled(int index, int value)
|
||||
{
|
||||
dicePanelView.SetDieValue(index, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user