[Fix] Naming
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9191bf86efa11bc47bcd9383d3a106f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 511dff8ba41dd7e49a817a1053ff3b90
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
-8
@@ -9,14 +9,14 @@ namespace YachtDice.Categories
|
||||
/// Аналог ModifierCatalogSO.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "CategoryCatalog", menuName = "YachtDice/Categories/Catalog")]
|
||||
public class CategoryCatalogSO : ScriptableObject
|
||||
public class CategoryCatalog : ScriptableObject
|
||||
{
|
||||
[SerializeField] private List<CategoryDefinitionSO> categories = new();
|
||||
[SerializeField] private List<CategoryDefinition> categories = new();
|
||||
|
||||
public IReadOnlyList<CategoryDefinitionSO> All => categories;
|
||||
public IReadOnlyList<CategoryDefinition> All => categories;
|
||||
public int Count => categories.Count;
|
||||
|
||||
public CategoryDefinitionSO FindById(string id)
|
||||
public CategoryDefinition FindById(string id)
|
||||
{
|
||||
for (int i = 0; i < categories.Count; i++)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace YachtDice.Categories
|
||||
return null;
|
||||
}
|
||||
|
||||
public int IndexOf(CategoryDefinitionSO def)
|
||||
public int IndexOf(CategoryDefinition def)
|
||||
{
|
||||
for (int i = 0; i < categories.Count; i++)
|
||||
{
|
||||
@@ -37,10 +37,10 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static CategoryCatalogSO CreateForTest(List<CategoryDefinitionSO> defs)
|
||||
public static CategoryCatalog CreateForTest(List<CategoryDefinition> defs)
|
||||
{
|
||||
var catalog = CreateInstance<CategoryCatalogSO>();
|
||||
catalog.categories = defs ?? new List<CategoryDefinitionSO>();
|
||||
var catalog = CreateInstance<CategoryCatalog>();
|
||||
catalog.categories = defs ?? new List<CategoryDefinition>();
|
||||
return catalog;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e89ee3a4aac1e6d4eabd79f32b9d8d15
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace YachtDice.Categories
|
||||
/// Абстрактное определение категории для скоринга.
|
||||
/// Каждая категория знает как вычислить очки по набору дайсов.
|
||||
/// </summary>
|
||||
public abstract class CategoryDefinitionSO : ScriptableObject
|
||||
public abstract class CategoryDefinition : ScriptableObject
|
||||
{
|
||||
[Header("Identity")]
|
||||
[SerializeField] private string id;
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b24bbcc7122ad0429210eb02f5b51a7
|
||||
+3
-3
@@ -9,7 +9,7 @@ namespace YachtDice.Categories
|
||||
/// При совпадении возвращает фиксированное число очков.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "FullHouseCategory", menuName = "YachtDice/Categories/Full House")]
|
||||
public class FullHouseCategorySO : CategoryDefinitionSO
|
||||
public class FullHouseCategory : CategoryDefinition
|
||||
{
|
||||
[Header("Scoring")]
|
||||
[Tooltip("Фиксированное число очков за фулл-хаус")]
|
||||
@@ -22,9 +22,9 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static FullHouseCategorySO CreateForTest(string id, string displayName, int score = 25)
|
||||
public static FullHouseCategory CreateForTest(string id, string displayName, int score = 25)
|
||||
{
|
||||
var so = CreateInstance<FullHouseCategorySO>();
|
||||
var so = CreateInstance<FullHouseCategory>();
|
||||
so.SetTestData(id, displayName);
|
||||
so.fixedScore = score;
|
||||
return so;
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fbe9492ec44ebb4da7074b0719b3eda
|
||||
+3
-3
@@ -10,7 +10,7 @@ namespace YachtDice.Categories
|
||||
/// Используется для Тройки (3, сумма), Каре (4, сумма), Яхты (5, fixed=50).
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "NOfAKindCategory", menuName = "YachtDice/Categories/N Of A Kind")]
|
||||
public class NOfAKindCategorySO : CategoryDefinitionSO
|
||||
public class NOfAKindCategory : CategoryDefinition
|
||||
{
|
||||
[Header("Scoring")]
|
||||
[Tooltip("Сколько одинаковых дайсов требуется")]
|
||||
@@ -33,9 +33,9 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static NOfAKindCategorySO CreateForTest(string id, string displayName, int count, bool fixedScoreMode = false, int score = 0)
|
||||
public static NOfAKindCategory CreateForTest(string id, string displayName, int count, bool fixedScoreMode = false, int score = 0)
|
||||
{
|
||||
var so = CreateInstance<NOfAKindCategorySO>();
|
||||
var so = CreateInstance<NOfAKindCategory>();
|
||||
so.SetTestData(id, displayName);
|
||||
so.requiredCount = count;
|
||||
so.useFixedScore = fixedScoreMode;
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a4bac360359f3847a088d18e67b5c8b
|
||||
+3
-3
@@ -10,7 +10,7 @@ namespace YachtDice.Categories
|
||||
/// Малый стрит: runLength=4, fixedScore=30. Большой стрит: runLength=5, fixedScore=40.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "StraightCategory", menuName = "YachtDice/Categories/Straight")]
|
||||
public class StraightCategorySO : CategoryDefinitionSO
|
||||
public class StraightCategory : CategoryDefinition
|
||||
{
|
||||
[Header("Scoring")]
|
||||
[Tooltip("Требуемая длина последовательности")]
|
||||
@@ -26,9 +26,9 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static StraightCategorySO CreateForTest(string id, string displayName, int run, int score)
|
||||
public static StraightCategory CreateForTest(string id, string displayName, int run, int score)
|
||||
{
|
||||
var so = CreateInstance<StraightCategorySO>();
|
||||
var so = CreateInstance<StraightCategory>();
|
||||
so.SetTestData(id, displayName);
|
||||
so.runLength = run;
|
||||
so.fixedScore = score;
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f267a540d10bec4b91f1b9c1173257b
|
||||
+3
-3
@@ -8,7 +8,7 @@ namespace YachtDice.Categories
|
||||
/// Категория «Шанс»: суммирует все дайсы без условий.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "SumAllCategory", menuName = "YachtDice/Categories/Sum All (Chance)")]
|
||||
public class SumAllCategorySO : CategoryDefinitionSO
|
||||
public class SumAllCategory : CategoryDefinition
|
||||
{
|
||||
public override int Calculate(IReadOnlyList<IDie> dice)
|
||||
{
|
||||
@@ -19,9 +19,9 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static SumAllCategorySO CreateForTest(string id, string displayName)
|
||||
public static SumAllCategory CreateForTest(string id, string displayName)
|
||||
{
|
||||
var so = CreateInstance<SumAllCategorySO>();
|
||||
var so = CreateInstance<SumAllCategory>();
|
||||
so.SetTestData(id, displayName);
|
||||
return so;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeb4a3033474e7c4b945a3c5a71df067
|
||||
+3
-3
@@ -9,7 +9,7 @@ namespace YachtDice.Categories
|
||||
/// Используется для Единиц (1), Двоек (2), ... Шестёрок (6).
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "SumOfValueCategory", menuName = "YachtDice/Categories/Sum Of Value")]
|
||||
public class SumOfValueCategorySO : CategoryDefinitionSO
|
||||
public class SumOfValueCategory : CategoryDefinition
|
||||
{
|
||||
[Header("Scoring")]
|
||||
[Tooltip("Значение грани для суммирования (1-6)")]
|
||||
@@ -26,9 +26,9 @@ namespace YachtDice.Categories
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static SumOfValueCategorySO CreateForTest(string id, string displayName, int target)
|
||||
public static SumOfValueCategory CreateForTest(string id, string displayName, int target)
|
||||
{
|
||||
var so = CreateInstance<SumOfValueCategorySO>();
|
||||
var so = CreateInstance<SumOfValueCategory>();
|
||||
so.SetTestData(id, displayName, upperSection: true);
|
||||
so.targetValue = target;
|
||||
return so;
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdb02f59d2ac5894f9f28d4547d3d941
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa749c160e90ff54ea903f977051f51d
|
||||
@@ -15,7 +15,7 @@ namespace YachtDice.DI
|
||||
public class GameLifetimeScope : LifetimeScope
|
||||
{
|
||||
[SerializeField] private ModifierCatalogSO modifierCatalog;
|
||||
[SerializeField] private CategoryCatalogSO categoryCatalog;
|
||||
[SerializeField] private CategoryCatalog categoryCatalog;
|
||||
|
||||
[Header("Scene References")]
|
||||
[SerializeField] private ScoringSystem scoringSystem;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9db7c202fb40af469cc815db88f1ad6
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ce67a0ca086c084da281c1c3ff97d5f
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0df5b1c4a22d7744bcdde17cd09463e
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c05eaecc1af5cb34aa0cde534039784d
|
||||
@@ -23,7 +23,7 @@ namespace YachtDice.Game
|
||||
|
||||
public event Action<int> OnTurnStarted;
|
||||
public event Action<int> OnRollComplete;
|
||||
public event Action<CategoryDefinitionSO, int> OnScored;
|
||||
public event Action<CategoryDefinition, int> OnScored;
|
||||
public event Action<int> OnGameOver;
|
||||
|
||||
private void Start()
|
||||
@@ -76,7 +76,7 @@ namespace YachtDice.Game
|
||||
Debug.Log($"Dice {index + 1} (value={diceManager.GetValue(index)}): {(isLocked ? "LOCKED" : "UNLOCKED")}");
|
||||
}
|
||||
|
||||
public void ScoreInCategory(CategoryDefinitionSO category)
|
||||
public void ScoreInCategory(CategoryDefinition category)
|
||||
{
|
||||
if (!CanScore) return;
|
||||
if (scoringSystem.IsCategoryUsed(category)) return;
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace YachtDice.Inventory
|
||||
RefreshView();
|
||||
}
|
||||
|
||||
private void HandleCategoryConfirmed(CategoryDefinitionSO category, ScoreResult result)
|
||||
private void HandleCategoryConfirmed(CategoryDefinition category, ScoreResult result)
|
||||
{
|
||||
model.ConsumeUseOnActive();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YachtDice.Modifiers.Conditions
|
||||
[CreateAssetMenu(fileName = "CategoryCondition", menuName = "YachtDice/Modifiers/Conditions/Category")]
|
||||
public class CategoryCondition : ConditionSO
|
||||
{
|
||||
[SerializeField] private CategoryDefinitionSO requiredCategory;
|
||||
[SerializeField] private CategoryDefinition requiredCategory;
|
||||
|
||||
public override bool Evaluate(ModifierContext context, ModifierInstance instance)
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace YachtDice.Modifiers.Conditions
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static CategoryCondition CreateForTest(CategoryDefinitionSO category)
|
||||
public static CategoryCondition CreateForTest(CategoryDefinition category)
|
||||
{
|
||||
var so = CreateInstance<CategoryCondition>();
|
||||
so.requiredCategory = category;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YachtDice.Modifiers.Core
|
||||
public int[] DiceValues;
|
||||
|
||||
/// <summary>Категория, в которую записывается результат.</summary>
|
||||
public CategoryDefinitionSO Category;
|
||||
public CategoryDefinition Category;
|
||||
|
||||
// Game state (read-only snapshot)
|
||||
public int CurrentRoll;
|
||||
@@ -56,7 +56,7 @@ namespace YachtDice.Modifiers.Core
|
||||
public static ModifierContext CreateForScoring(
|
||||
int baseScore,
|
||||
IReadOnlyList<IDie> dice,
|
||||
CategoryDefinitionSO category,
|
||||
CategoryDefinition category,
|
||||
int currentRoll,
|
||||
int currentTurn,
|
||||
int playerCurrency,
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace YachtDice.Scoring
|
||||
public int FlatBonus;
|
||||
public float Multiplier;
|
||||
public int[] DiceValues;
|
||||
public CategoryDefinitionSO Category;
|
||||
public CategoryDefinition Category;
|
||||
|
||||
public int FinalScore => Mathf.FloorToInt((BaseScore + FlatBonus) * Multiplier);
|
||||
|
||||
public static ScoreResult Create(int baseScore, IReadOnlyList<IDie> dice, CategoryDefinitionSO category)
|
||||
public static ScoreResult Create(int baseScore, IReadOnlyList<IDie> dice, CategoryDefinition category)
|
||||
{
|
||||
return new ScoreResult
|
||||
{
|
||||
|
||||
@@ -13,30 +13,30 @@ namespace YachtDice.Scoring
|
||||
{
|
||||
public class ScoringSystem : MonoBehaviour
|
||||
{
|
||||
public event Action<CategoryDefinitionSO, int> OnCategoryScored;
|
||||
public event Action<CategoryDefinition, int> OnCategoryScored;
|
||||
public event Action<int> OnAllCategoriesScored;
|
||||
public event Action<CategoryDefinitionSO, ScoreResult> OnCategoryConfirmed;
|
||||
public event Action<CategoryDefinition, ScoreResult> OnCategoryConfirmed;
|
||||
|
||||
private readonly Dictionary<CategoryDefinitionSO, int> scorecard = new();
|
||||
private readonly HashSet<CategoryDefinitionSO> usedCategories = new();
|
||||
private readonly Dictionary<CategoryDefinition, int> scorecard = new();
|
||||
private readonly HashSet<CategoryDefinition> usedCategories = new();
|
||||
|
||||
private GameEventBus eventBus;
|
||||
private ModifierRegistry modifierRegistry;
|
||||
private CategoryCatalogSO catalog;
|
||||
private CategoryCatalog catalog;
|
||||
|
||||
[Inject]
|
||||
public void Construct(GameEventBus eventBus, ModifierRegistry modifierRegistry, CategoryCatalogSO catalog)
|
||||
public void Construct(GameEventBus eventBus, ModifierRegistry modifierRegistry, CategoryCatalog catalog)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
this.modifierRegistry = modifierRegistry;
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
public CategoryCatalogSO Catalog => catalog;
|
||||
public CategoryCatalog Catalog => catalog;
|
||||
|
||||
public bool IsCategoryUsed(CategoryDefinitionSO category) => usedCategories.Contains(category);
|
||||
public bool IsCategoryUsed(CategoryDefinition category) => usedCategories.Contains(category);
|
||||
|
||||
public int GetCategoryScore(CategoryDefinitionSO category)
|
||||
public int GetCategoryScore(CategoryDefinition category)
|
||||
{
|
||||
return scorecard.TryGetValue(category, out int score) ? score : -1;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace YachtDice.Scoring
|
||||
|
||||
public bool IsComplete => CategoriesFilledCount >= TotalCategoryCount;
|
||||
|
||||
public ScoreResult PreviewScore(IReadOnlyList<IDie> dice, CategoryDefinitionSO category,
|
||||
public ScoreResult PreviewScore(IReadOnlyList<IDie> 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, CategoryDefinitionSO category,
|
||||
public async UniTask<ScoreResult> ScoreCategoryAsync(IReadOnlyList<IDie> 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, CategoryDefinitionSO category)
|
||||
public ScoreResult ScoreCategory(IReadOnlyList<IDie> dice, CategoryDefinition category)
|
||||
{
|
||||
if (usedCategories.Contains(category))
|
||||
throw new InvalidOperationException($"Category {category.DisplayName} has already been scored.");
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public class ModifierEffectTests
|
||||
{
|
||||
private CategoryDefinitionSO testCategory;
|
||||
private CategoryDefinition testCategory;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
testCategory = SumAllCategorySO.CreateForTest("chance", "Шанс");
|
||||
testCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace YachtDice.Tests
|
||||
private ModifierPipeline pipeline;
|
||||
|
||||
// Тестовые категории
|
||||
private CategoryDefinitionSO chanceCategory;
|
||||
private CategoryDefinitionSO fullHouseCategory;
|
||||
private CategoryDefinitionSO onesCategory;
|
||||
private CategoryDefinitionSO threesCategory;
|
||||
private CategoryDefinitionSO foursCategory;
|
||||
private CategoryDefinitionSO sixesCategory;
|
||||
private CategoryDefinition chanceCategory;
|
||||
private CategoryDefinition fullHouseCategory;
|
||||
private CategoryDefinition onesCategory;
|
||||
private CategoryDefinition threesCategory;
|
||||
private CategoryDefinition foursCategory;
|
||||
private CategoryDefinition sixesCategory;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -32,12 +32,12 @@ namespace YachtDice.Tests
|
||||
pipeline = new ModifierPipeline(registry);
|
||||
pipeline.TracingEnabled = false;
|
||||
|
||||
chanceCategory = SumAllCategorySO.CreateForTest("chance", "Шанс");
|
||||
fullHouseCategory = FullHouseCategorySO.CreateForTest("full_house", "Фулл-хаус");
|
||||
onesCategory = SumOfValueCategorySO.CreateForTest("ones", "Единицы", 1);
|
||||
threesCategory = SumOfValueCategorySO.CreateForTest("threes", "Тройки", 3);
|
||||
foursCategory = SumOfValueCategorySO.CreateForTest("fours", "Четвёрки", 4);
|
||||
sixesCategory = SumOfValueCategorySO.CreateForTest("sixes", "Шестёрки", 6);
|
||||
chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
fullHouseCategory = FullHouseCategory.CreateForTest("full_house", "Фулл-хаус");
|
||||
onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
threesCategory = SumOfValueCategory.CreateForTest("threes", "Тройки", 3);
|
||||
foursCategory = SumOfValueCategory.CreateForTest("fours", "Четвёрки", 4);
|
||||
sixesCategory = SumOfValueCategory.CreateForTest("sixes", "Шестёрки", 6);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -67,7 +67,7 @@ namespace YachtDice.Tests
|
||||
registry.TryActivate(inst);
|
||||
}
|
||||
|
||||
private ModifierContext CreateScoringContext(int baseScore, int[] dice, CategoryDefinitionSO category)
|
||||
private ModifierContext CreateScoringContext(int baseScore, int[] dice, CategoryDefinition category)
|
||||
{
|
||||
return new ModifierContext
|
||||
{
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public class ScoringSystemTests
|
||||
{
|
||||
private CategoryDefinitionSO yachtCategory;
|
||||
private CategoryDefinitionSO onesCategory;
|
||||
private CategoryDefinitionSO twosCategory;
|
||||
private CategoryDefinitionSO chanceCategory;
|
||||
private CategoryCatalogSO catalog;
|
||||
private CategoryDefinition yachtCategory;
|
||||
private CategoryDefinition onesCategory;
|
||||
private CategoryDefinition twosCategory;
|
||||
private CategoryDefinition chanceCategory;
|
||||
private CategoryCatalog catalog;
|
||||
private DieDefinitionSO standardDie;
|
||||
|
||||
[SetUp]
|
||||
@@ -21,12 +21,12 @@ namespace YachtDice.Tests
|
||||
{
|
||||
standardDie = DieDefinitionSO.CreateForTest<StandardDieSO>("d6", "d6");
|
||||
|
||||
yachtCategory = NOfAKindCategorySO.CreateForTest("yacht", "Яхта", 5, fixedScoreMode: true, score: 50);
|
||||
onesCategory = SumOfValueCategorySO.CreateForTest("ones", "Единицы", 1);
|
||||
twosCategory = SumOfValueCategorySO.CreateForTest("twos", "Двойки", 2);
|
||||
chanceCategory = SumAllCategorySO.CreateForTest("chance", "Шанс");
|
||||
yachtCategory = NOfAKindCategory.CreateForTest("yacht", "Яхта", 5, fixedScoreMode: true, score: 50);
|
||||
onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
twosCategory = SumOfValueCategory.CreateForTest("twos", "Двойки", 2);
|
||||
chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
|
||||
catalog = CategoryCatalogSO.CreateForTest(new List<CategoryDefinitionSO>
|
||||
catalog = CategoryCatalog.CreateForTest(new List<CategoryDefinition>
|
||||
{
|
||||
onesCategory, twosCategory, yachtCategory, chanceCategory
|
||||
});
|
||||
@@ -77,7 +77,7 @@ namespace YachtDice.Tests
|
||||
public void ScoreCategory_FiresOnCategoryConfirmed()
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
CategoryDefinitionSO firedCategory = null;
|
||||
CategoryDefinition firedCategory = null;
|
||||
ScoreResult firedResult = default;
|
||||
|
||||
system.OnCategoryConfirmed += (cat, res) =>
|
||||
@@ -144,7 +144,7 @@ namespace YachtDice.Tests
|
||||
public void SumOfValueCategory_SumsCorrectly()
|
||||
{
|
||||
var dice = CreateDice(3, 3, 3, 1, 2);
|
||||
var cat = SumOfValueCategorySO.CreateForTest("threes", "Тройки", 3);
|
||||
var cat = SumOfValueCategory.CreateForTest("threes", "Тройки", 3);
|
||||
|
||||
Assert.AreEqual(9, cat.Calculate(dice));
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void NOfAKindCategory_ThreeOfAKind_ReturnsSumOrZero()
|
||||
{
|
||||
var cat = NOfAKindCategorySO.CreateForTest("three_of_a_kind", "Тройка", 3);
|
||||
var cat = NOfAKindCategory.CreateForTest("three_of_a_kind", "Тройка", 3);
|
||||
|
||||
Assert.AreEqual(17, cat.Calculate(CreateDice(4, 4, 4, 3, 2))); // sum = 17
|
||||
Assert.AreEqual(0, cat.Calculate(CreateDice(1, 2, 3, 4, 5))); // no 3-of-a-kind
|
||||
@@ -172,7 +172,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void FullHouseCategory_CalculatesCorrectly()
|
||||
{
|
||||
var cat = FullHouseCategorySO.CreateForTest("fh", "Фулл-хаус", 25);
|
||||
var cat = FullHouseCategory.CreateForTest("fh", "Фулл-хаус", 25);
|
||||
|
||||
Assert.AreEqual(25, cat.Calculate(CreateDice(3, 3, 3, 2, 2)));
|
||||
Assert.AreEqual(0, cat.Calculate(CreateDice(3, 3, 3, 3, 2)));
|
||||
@@ -183,7 +183,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void StraightCategory_SmallStraight()
|
||||
{
|
||||
var cat = StraightCategorySO.CreateForTest("ss", "Малый стрит", 4, 30);
|
||||
var cat = StraightCategory.CreateForTest("ss", "Малый стрит", 4, 30);
|
||||
|
||||
Assert.AreEqual(30, cat.Calculate(CreateDice(1, 2, 3, 4, 6)));
|
||||
Assert.AreEqual(0, cat.Calculate(CreateDice(1, 2, 3, 5, 6)));
|
||||
@@ -194,7 +194,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void StraightCategory_LargeStraight()
|
||||
{
|
||||
var cat = StraightCategorySO.CreateForTest("ls", "Большой стрит", 5, 40);
|
||||
var cat = StraightCategory.CreateForTest("ls", "Большой стрит", 5, 40);
|
||||
|
||||
Assert.AreEqual(40, cat.Calculate(CreateDice(1, 2, 3, 4, 5)));
|
||||
Assert.AreEqual(40, cat.Calculate(CreateDice(2, 3, 4, 5, 6)));
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace YachtDice.UI
|
||||
[SerializeField] private Color previewPositiveColor = new Color(0.85f, 1f, 0.85f, 1f);
|
||||
[SerializeField] private Color previewZeroColor = new Color(1f, 0.88f, 0.88f, 1f);
|
||||
|
||||
private CategoryDefinitionSO category;
|
||||
private CategoryDefinition category;
|
||||
private bool isUsed;
|
||||
|
||||
public event Action<CategoryDefinitionSO> OnCategorySelected;
|
||||
public event Action<CategoryDefinition> OnCategorySelected;
|
||||
|
||||
public void Initialize(CategoryDefinitionSO categoryDef)
|
||||
public void Initialize(CategoryDefinition categoryDef)
|
||||
{
|
||||
category = categoryDef;
|
||||
isUsed = false;
|
||||
|
||||
@@ -39,12 +39,12 @@ namespace YachtDice.UI
|
||||
private const int UpperBonusValue = 35;
|
||||
|
||||
private ModifierRegistry modifierRegistry;
|
||||
private CategoryCatalogSO categoryCatalog;
|
||||
private CategoryCatalog categoryCatalog;
|
||||
private InventoryModel inventoryModel;
|
||||
private ShopModel shopModel;
|
||||
|
||||
[Inject]
|
||||
public void Construct(ModifierRegistry modifierRegistry, CategoryCatalogSO categoryCatalog)
|
||||
public void Construct(ModifierRegistry modifierRegistry, CategoryCatalog categoryCatalog)
|
||||
{
|
||||
this.modifierRegistry = modifierRegistry;
|
||||
this.categoryCatalog = categoryCatalog;
|
||||
@@ -217,7 +217,7 @@ namespace YachtDice.UI
|
||||
dicePanelView.SetDieValue(index, value);
|
||||
}
|
||||
|
||||
private void HandleScored(CategoryDefinitionSO category, int finalScore)
|
||||
private void HandleScored(CategoryDefinition category, int finalScore)
|
||||
{
|
||||
scoreCardView.SetCategoryScored(category, finalScore);
|
||||
UpdateTotalDisplay();
|
||||
@@ -259,7 +259,7 @@ namespace YachtDice.UI
|
||||
dicePanelView.SetDieLocked(index, isLocked);
|
||||
}
|
||||
|
||||
private void HandleCategorySelected(CategoryDefinitionSO category)
|
||||
private void HandleCategorySelected(CategoryDefinition category)
|
||||
{
|
||||
if (!gameManager.CanScore) return;
|
||||
if (scoringSystem.IsCategoryUsed(category)) return;
|
||||
@@ -317,7 +317,7 @@ namespace YachtDice.UI
|
||||
private void UpdatePreviewScores()
|
||||
{
|
||||
var dice = diceManager.GetDice();
|
||||
var previews = new Dictionary<CategoryDefinitionSO, int>();
|
||||
var previews = new Dictionary<CategoryDefinition, int>();
|
||||
var allCategories = categoryCatalog.All;
|
||||
|
||||
for (int i = 0; i < allCategories.Count; i++)
|
||||
|
||||
@@ -16,19 +16,19 @@ namespace YachtDice.UI
|
||||
[SerializeField] private TMP_Text upperBonusText;
|
||||
[SerializeField] private TMP_Text totalScoreText;
|
||||
|
||||
public event Action<CategoryDefinitionSO> OnCategorySelected;
|
||||
public event Action<CategoryDefinition> OnCategorySelected;
|
||||
|
||||
private CategoryCatalogSO catalog;
|
||||
private Dictionary<CategoryDefinitionSO, int> categoryToRowIndex;
|
||||
private CategoryCatalog catalog;
|
||||
private Dictionary<CategoryDefinition, int> categoryToRowIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализирует скоркарту из каталога категорий.
|
||||
/// Вызывается из GameController после DI.
|
||||
/// </summary>
|
||||
public void Initialize(CategoryCatalogSO categoryCatalog)
|
||||
public void Initialize(CategoryCatalog categoryCatalog)
|
||||
{
|
||||
catalog = categoryCatalog;
|
||||
categoryToRowIndex = new Dictionary<CategoryDefinitionSO, int>();
|
||||
categoryToRowIndex = new Dictionary<CategoryDefinition, int>();
|
||||
|
||||
var all = catalog.All;
|
||||
int count = Mathf.Min(categoryRows.Count, all.Count);
|
||||
@@ -43,7 +43,7 @@ namespace YachtDice.UI
|
||||
UpdateTotalDisplay(0, 0, false);
|
||||
}
|
||||
|
||||
public void UpdatePreviews(Dictionary<CategoryDefinitionSO, int> previews)
|
||||
public void UpdatePreviews(Dictionary<CategoryDefinition, int> previews)
|
||||
{
|
||||
foreach (var kvp in previews)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace YachtDice.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCategoryScored(CategoryDefinitionSO category, int score)
|
||||
public void SetCategoryScored(CategoryDefinition category, int score)
|
||||
{
|
||||
if (categoryToRowIndex.TryGetValue(category, out int index))
|
||||
categoryRows[index].SetRecordedScore(score);
|
||||
@@ -91,7 +91,7 @@ namespace YachtDice.UI
|
||||
UpdateTotalDisplay(0, 0, false);
|
||||
}
|
||||
|
||||
private void HandleCategorySelected(CategoryDefinitionSO category)
|
||||
private void HandleCategorySelected(CategoryDefinition category)
|
||||
{
|
||||
OnCategorySelected?.Invoke(category);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user