[Fix] Code visual

This commit is contained in:
2026-02-28 19:25:26 +07:00
parent bee20fd1f8
commit e24b30743b
39 changed files with 2611 additions and 2687 deletions
+3 -4
View File
@@ -4,9 +4,8 @@ using UnityEngine;
namespace YachtDice.Dice
{
public sealed class Dice : MonoBehaviour
{
public class Dice : MonoBehaviour
{
[Serializable]
public struct Entry : IEquatable<Entry>
{
@@ -137,5 +136,5 @@ public sealed class Dice : MonoBehaviour
var e = transform.localEulerAngles;
transform.localEulerAngles = new Vector3(Norm180(e.x), Norm180(e.y), Norm180(e.z));
}
}
}
}
+7 -8
View File
@@ -5,13 +5,12 @@ using Random = UnityEngine.Random;
namespace YachtDice.Dice
{
/// <summary>
/// Красиво подбрасывает и раскручивает кубик, ждёт пока он остановится,
/// плавно доворачивает до ровного положения и сообщает результат.
/// </summary>
public sealed class DiceRoller : MonoBehaviour
{
/// <summary>
/// Красиво подбрасывает и раскручивает кубик, ждёт пока он остановится,
/// плавно доворачивает до ровного положения и сообщает результат.
/// </summary>
public class DiceRoller : MonoBehaviour
{
[Header("References")]
[SerializeField] private Dice dice;
[SerializeField] private Rigidbody rb;
@@ -152,5 +151,5 @@ public sealed class DiceRoller : MonoBehaviour
// Debug.Log($"{gameObject.name} | Выпало: <b>{topValue}</b>");
}
}
}
}
+3 -4
View File
@@ -3,9 +3,8 @@ using UnityEngine;
namespace YachtDice.Economy
{
public sealed class CurrencyBank : MonoBehaviour
{
public class CurrencyBank : MonoBehaviour
{
[SerializeField] private int startingBalance = 500;
private int balance;
@@ -44,5 +43,5 @@ public sealed class CurrencyBank : MonoBehaviour
balance = Mathf.Max(0, value);
OnBalanceChanged?.Invoke(balance);
}
}
}
}
-39
View File
@@ -1,39 +0,0 @@
using UnityEngine;
using YachtDice.Scoring;
namespace YachtDice.Game
{
public sealed class DebugGameInput : MonoBehaviour
{
[SerializeField] private GameManager gameManager;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
gameManager.Roll();
// 1-5: toggle lock on dice 0-4
if (Input.GetKeyDown(KeyCode.Alpha1)) gameManager.ToggleDiceLock(0);
if (Input.GetKeyDown(KeyCode.Alpha2)) gameManager.ToggleDiceLock(1);
if (Input.GetKeyDown(KeyCode.Alpha3)) gameManager.ToggleDiceLock(2);
if (Input.GetKeyDown(KeyCode.Alpha4)) gameManager.ToggleDiceLock(3);
if (Input.GetKeyDown(KeyCode.Alpha5)) gameManager.ToggleDiceLock(4);
// Score categories
if (Input.GetKeyDown(KeyCode.F1)) gameManager.ScoreInCategory(YachtCategory.Ones);
if (Input.GetKeyDown(KeyCode.F2)) gameManager.ScoreInCategory(YachtCategory.Twos);
if (Input.GetKeyDown(KeyCode.F3)) gameManager.ScoreInCategory(YachtCategory.Threes);
if (Input.GetKeyDown(KeyCode.F4)) gameManager.ScoreInCategory(YachtCategory.Fours);
if (Input.GetKeyDown(KeyCode.F5)) gameManager.ScoreInCategory(YachtCategory.Fives);
if (Input.GetKeyDown(KeyCode.F6)) gameManager.ScoreInCategory(YachtCategory.Sixes);
if (Input.GetKeyDown(KeyCode.F7)) gameManager.ScoreInCategory(YachtCategory.ThreeOfAKind);
if (Input.GetKeyDown(KeyCode.F8)) gameManager.ScoreInCategory(YachtCategory.FourOfAKind);
if (Input.GetKeyDown(KeyCode.F9)) gameManager.ScoreInCategory(YachtCategory.FullHouse);
if (Input.GetKeyDown(KeyCode.F10)) gameManager.ScoreInCategory(YachtCategory.SmallStraight);
if (Input.GetKeyDown(KeyCode.F11)) gameManager.ScoreInCategory(YachtCategory.LargeStraight);
if (Input.GetKeyDown(KeyCode.F12)) gameManager.ScoreInCategory(YachtCategory.Yacht);
if (Input.GetKeyDown(KeyCode.C)) gameManager.ScoreInCategory(YachtCategory.Chance);
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 982f0996b85edfe419b07ddb36d6e235
+4 -5
View File
@@ -5,9 +5,8 @@ using YachtDice.Dice;
namespace YachtDice.Game
{
public sealed class DiceManager : MonoBehaviour
{
public class DiceManager : MonoBehaviour
{
[SerializeField] private List<DiceRoller> diceRollers = new();
public event Action OnAllDiceSettled;
@@ -99,10 +98,10 @@ public sealed class DiceManager : MonoBehaviour
{
for (int i = 0; i < diceRollers.Count; i++)
{
var diceComponent = diceRollers[i].GetComponent<Dice>();
var diceComponent = diceRollers[i].GetComponent<Dice.Dice>();
if (diceComponent != null && diceComponent.TryGetTopValue(out int val))
currentValues[i] = val;
}
}
}
}
}
+3 -4
View File
@@ -4,9 +4,8 @@ using YachtDice.Scoring;
namespace YachtDice.Game
{
public sealed class GameManager : MonoBehaviour
{
public class GameManager : MonoBehaviour
{
[Header("References")]
[SerializeField] private DiceManager diceManager;
[SerializeField] private ScoringSystem scoringSystem;
@@ -101,5 +100,5 @@ public sealed class GameManager : MonoBehaviour
StartNewTurn();
}
}
}
}
}
@@ -5,9 +5,8 @@ using YachtDice.Scoring;
namespace YachtDice.Inventory
{
public sealed class InventoryController : MonoBehaviour
{
public class InventoryController : MonoBehaviour
{
[SerializeField] private InventoryView inventoryView;
[SerializeField] private ScoringSystem scoringSystem;
[SerializeField] private CurrencyBank currencyBank;
@@ -94,5 +93,5 @@ public sealed class InventoryController : MonoBehaviour
if (inventoryView != null && model != null)
inventoryView.Refresh(model.OwnedModifiers, model.MaxActiveSlots);
}
}
}
}
+3 -4
View File
@@ -4,9 +4,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventoryModel
{
public class InventoryModel
{
private readonly List<ModifierRuntime> ownedModifiers = new();
private int maxActiveSlots;
@@ -128,5 +127,5 @@ public sealed class InventoryModel
}
public List<ModifierRuntime> GetAllForSave() => new(ownedModifiers);
}
}
}
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventorySlotView : MonoBehaviour
{
public class InventorySlotView : MonoBehaviour
{
[SerializeField] private Image iconImage;
[SerializeField] private TMP_Text nameText;
[SerializeField] private TMP_Text descriptionText;
@@ -79,5 +78,5 @@ public sealed class InventorySlotView : MonoBehaviour
if (background != null)
background.color = isActive ? activeColor : inactiveColor;
}
}
}
}
+3 -4
View File
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Inventory
{
public sealed class InventoryView : MonoBehaviour
{
public class InventoryView : MonoBehaviour
{
[SerializeField] private Transform slotContainer;
[SerializeField] private InventorySlotView slotPrefab;
[SerializeField] private TMP_Text slotCountText;
@@ -75,5 +74,5 @@ public sealed class InventoryView : MonoBehaviour
private void HandleActivate(ModifierRuntime runtime) => OnActivateClicked?.Invoke(runtime);
private void HandleDeactivate(ModifierRuntime runtime) => OnDeactivateClicked?.Invoke(runtime);
private void HandleSell(ModifierRuntime runtime) => OnSellClicked?.Invoke(runtime);
}
}
}
+6 -7
View File
@@ -3,10 +3,9 @@ using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifier Data")]
public sealed class ModifierData : ScriptableObject
{
[CreateAssetMenu(fileName = "NewModifier", menuName = "YachtDice/Modifier Data")]
public sealed class ModifierData : ScriptableObject
{
[SerializeField] private string id;
[SerializeField] private string displayName;
[SerializeField] [TextArea] private string description;
@@ -55,7 +54,7 @@ public sealed class ModifierData : ScriptableObject
effectType == ModifierEffectType.AddFlatToFinalScore ||
effectType == ModifierEffectType.MultiplyFinalScore;
#if UNITY_EDITOR
#if UNITY_EDITOR
public static ModifierData CreateForTest(
string id,
ModifierScope scope,
@@ -88,6 +87,6 @@ public sealed class ModifierData : ScriptableObject
data.sellPrice = sellPrice;
return data;
}
#endif
}
#endif
}
}
+4 -5
View File
@@ -3,11 +3,10 @@ using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
public static class ModifierEffect
{
public static class ModifierEffect
{
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
{
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
@@ -56,5 +55,5 @@ public static class ModifierEffect
{
result.Multiplier *= data.EffectValue;
}
}
}
}
+12 -12
View File
@@ -1,30 +1,30 @@
namespace YachtDice.Modifiers
{
public enum ModifierScope
{
public enum ModifierScope
{
SelectedCategory,
AnyCategoryClosed
}
}
public enum ModifierEffectType
{
public enum ModifierEffectType
{
AddPerDieValue,
AddFlatToFinalScore,
MultiplyPerDieValue,
MultiplyFinalScore
}
}
public enum ModifierDurability
{
public enum ModifierDurability
{
Permanent,
LimitedUses
}
}
public enum ModifierRarity
{
public enum ModifierRarity
{
Common,
Uncommon,
Rare,
Epic
}
}
}
+3 -4
View File
@@ -3,9 +3,8 @@ using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
public static class ModifierPipeline
{
public static class ModifierPipeline
{
// Application order (explicit):
// 1. Category-level additive (AddPerDieValue)
// 2. Category-level multiplicative (MultiplyPerDieValue)
@@ -63,5 +62,5 @@ public static class ModifierPipeline
if (mod.Target.HasCategoryFilter && mod.Target.TargetCategory != result.Category) return false;
return true;
}
}
}
}
+4 -5
View File
@@ -2,10 +2,9 @@ using System;
namespace YachtDice.Modifiers
{
[Serializable]
public sealed class ModifierRuntime
{
[Serializable]
public class ModifierRuntime
{
public string ModifierId;
public bool IsActive;
public int RemainingUses;
@@ -34,5 +33,5 @@ public sealed class ModifierRuntime
Data = data
};
}
}
}
}
+4 -5
View File
@@ -4,10 +4,9 @@ using YachtDice.Scoring;
namespace YachtDice.Modifiers
{
[Serializable]
public struct ModifierTarget
{
[Serializable]
public struct ModifierTarget
{
[Tooltip("Die face value (1-6). 0 = any/all dice.")]
[Range(0, 6)]
public int DieValue;
@@ -17,5 +16,5 @@ public struct ModifierTarget
[Tooltip("If true, TargetCategory is used as a filter.")]
public bool HasCategoryFilter;
}
}
}
+8 -9
View File
@@ -3,20 +3,19 @@ using System.Collections.Generic;
namespace YachtDice.Persistence
{
[Serializable]
public sealed class SaveData
{
[Serializable]
public sealed class SaveData
{
public int Version = 1;
public int Currency;
public List<ModifierSaveEntry> OwnedModifiers = new();
}
}
[Serializable]
public sealed class ModifierSaveEntry
{
[Serializable]
public sealed class ModifierSaveEntry
{
public string ModifierId;
public bool IsActive;
public int RemainingUses;
}
}
}
+3 -4
View File
@@ -3,9 +3,8 @@ using UnityEngine;
namespace YachtDice.Persistence
{
public static class SaveSystem
{
public static class SaveSystem
{
private const string SaveKey = "YachtDice_SaveData";
public static void Save(SaveData data)
@@ -42,5 +41,5 @@ public static class SaveSystem
{
return PlayerPrefs.HasKey(SaveKey);
}
}
}
}
+3 -4
View File
@@ -2,9 +2,8 @@ using System;
namespace YachtDice.Scoring
{
public static class CategoryScorer
{
public static class CategoryScorer
{
public static int Calculate(int[] dice, YachtCategory category)
{
if (dice == null || dice.Length != 5)
@@ -79,5 +78,5 @@ public static class CategoryScorer
}
return false;
}
}
}
}
+4 -5
View File
@@ -3,10 +3,9 @@ using UnityEngine;
namespace YachtDice.Scoring
{
[Serializable]
public struct ScoreResult
{
[Serializable]
public struct ScoreResult
{
public int BaseScore;
public int FlatBonus;
public float Multiplier;
@@ -26,5 +25,5 @@ public struct ScoreResult
Category = category
};
}
}
}
}
+3 -4
View File
@@ -5,9 +5,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Scoring
{
public sealed class ScoringSystem : MonoBehaviour
{
public class ScoringSystem : MonoBehaviour
{
public event Action<YachtCategory, int> OnCategoryScored;
public event Action<int> OnAllCategoriesScored;
public event Action<YachtCategory, ScoreResult> OnCategoryConfirmed;
@@ -85,5 +84,5 @@ public sealed class ScoringSystem : MonoBehaviour
scorecard.Clear();
usedCategories.Clear();
}
}
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
namespace YachtDice.Scoring
{
public enum YachtCategory
{
public enum YachtCategory
{
// Upper Section
Ones,
Twos,
@@ -18,5 +18,5 @@ public enum YachtCategory
LargeStraight,
Yacht,
Chance
}
}
}
+4 -5
View File
@@ -4,10 +4,9 @@ using YachtDice.Modifiers;
namespace YachtDice.Shop
{
[CreateAssetMenu(fileName = "ShopCatalog", menuName = "YachtDice/Shop Catalog")]
public sealed class ShopCatalog : ScriptableObject
{
[CreateAssetMenu(fileName = "ShopCatalog", menuName = "YachtDice/Shop Catalog")]
public sealed class ShopCatalog : ScriptableObject
{
[SerializeField] private List<ModifierData> availableModifiers = new();
public IReadOnlyList<ModifierData> AvailableModifiers => availableModifiers;
@@ -21,5 +20,5 @@ public sealed class ShopCatalog : ScriptableObject
}
return null;
}
}
}
}
+3 -4
View File
@@ -4,9 +4,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopController : MonoBehaviour
{
public class ShopController : MonoBehaviour
{
[SerializeField] private ShopCatalog catalog;
[SerializeField] private ShopView shopView;
[SerializeField] private CurrencyBank currencyBank;
@@ -57,5 +56,5 @@ public sealed class ShopController : MonoBehaviour
{
shopView.RefreshStates(catalog.AvailableModifiers, model);
}
}
}
}
+3 -4
View File
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopItemView : MonoBehaviour
{
public class ShopItemView : MonoBehaviour
{
[SerializeField] private Image iconImage;
[SerializeField] private TMP_Text nameText;
[SerializeField] private TMP_Text descriptionText;
@@ -88,5 +87,5 @@ public sealed class ShopItemView : MonoBehaviour
_ => commonColor
};
}
}
}
}
+6 -7
View File
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopModel
{
public class ShopModel
{
private readonly CurrencyBank currencyBank;
private readonly InventoryModel inventoryModel;
private readonly HashSet<string> purchasedPermanentIds = new();
@@ -73,13 +72,13 @@ public sealed class ShopModel
}
public HashSet<string> GetPurchasedPermanentIds() => new(purchasedPermanentIds);
}
}
public enum ShopItemState
{
public enum ShopItemState
{
Available,
TooExpensive,
Owned,
RepurchaseAvailable
}
}
}
+3 -4
View File
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Shop
{
public sealed class ShopView : MonoBehaviour
{
public class ShopView : MonoBehaviour
{
[SerializeField] private Transform itemContainer;
[SerializeField] private ShopItemView itemPrefab;
[SerializeField] private TMP_Text currencyText;
@@ -78,5 +77,5 @@ public sealed class ShopView : MonoBehaviour
}
private void HandleBuy(ModifierData data) => OnBuyClicked?.Invoke(data);
}
}
}
@@ -5,9 +5,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class InventoryModelTests
{
public class InventoryModelTests
{
private InventoryModel inventory;
[SetUp]
@@ -157,5 +156,5 @@ public sealed class InventoryModelTests
Assert.IsTrue(fired);
}
}
}
}
@@ -5,9 +5,8 @@ using YachtDice.Scoring;
namespace YachtDice.Tests
{
public sealed class ModifierEffectTests
{
public class ModifierEffectTests
{
private static ModifierData CreateData(
ModifierEffectType effectType, float effectValue,
int dieValue = 0, ModifierScope scope = ModifierScope.SelectedCategory)
@@ -91,5 +90,5 @@ public sealed class ModifierEffectTests
Assert.AreEqual(1.5f, result.Multiplier, 0.001f);
}
}
}
}
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
namespace YachtDice.Tests
{
public sealed class ModifierPipelineTests
{
public class ModifierPipelineTests
{
[Test]
public void Apply_AdditiveBeforeMultiplicative()
{
@@ -138,5 +137,5 @@ public sealed class ModifierPipelineTests
Assert.AreEqual(10, result.FinalScore);
}
}
}
}
@@ -5,9 +5,8 @@ using YachtDice.Persistence;
namespace YachtDice.Tests
{
public sealed class SaveSystemTests
{
public class SaveSystemTests
{
[SetUp]
public void SetUp()
{
@@ -89,5 +88,5 @@ public sealed class SaveSystemTests
Assert.IsNotNull(loaded);
Assert.AreEqual(0, loaded.Currency);
}
}
}
}
@@ -6,9 +6,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class ScoringSystemTests
{
public class ScoringSystemTests
{
private ScoringSystem CreateScoringSystem()
{
var go = new GameObject("ScoringSystem");
@@ -100,5 +99,5 @@ public sealed class ScoringSystemTests
Assert.AreEqual(1f, result.Multiplier);
Assert.AreEqual(50, result.FinalScore);
}
}
}
}
@@ -7,9 +7,8 @@ using YachtDice.Modifiers;
namespace YachtDice.Tests
{
public sealed class ShopModelTests
{
public sealed class ShopModelTests
{
private CurrencyBank bank;
private InventoryModel inventory;
private ShopModel shop;
@@ -134,5 +133,5 @@ public sealed class ShopModelTests
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(mod));
}
}
}
}
+3 -4
View File
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
namespace YachtDice.UI
{
public sealed class CategoryRowView : MonoBehaviour
{
public class CategoryRowView : MonoBehaviour
{
[Header("UI Elements")]
[SerializeField] private TMP_Text categoryNameText;
[SerializeField] private TMP_Text previewText;
@@ -90,5 +89,5 @@ public sealed class CategoryRowView : MonoBehaviour
{
selectButton.onClick.RemoveListener(HandleClick);
}
}
}
}
+3 -4
View File
@@ -5,9 +5,8 @@ using TMPro;
namespace YachtDice.UI
{
public sealed class DicePanelView : MonoBehaviour
{
public class DicePanelView : MonoBehaviour
{
[Header("Dice Display")]
[SerializeField] private Button[] diceButtons = new Button[5];
[SerializeField] private TMP_Text[] diceValueTexts = new TMP_Text[5];
@@ -101,5 +100,5 @@ public sealed class DicePanelView : MonoBehaviour
rollButton.onClick.RemoveAllListeners();
}
}
}
}
+3 -4
View File
@@ -11,9 +11,8 @@ using YachtDice.Modifiers;
namespace YachtDice.UI
{
public sealed class GameController : MonoBehaviour
{
public class GameController : MonoBehaviour
{
[Header("Model")]
[SerializeField] private GameManager gameManager;
[SerializeField] private ScoringSystem scoringSystem;
@@ -354,5 +353,5 @@ public sealed class GameController : MonoBehaviour
return total;
}
}
}
}
+3 -4
View File
@@ -5,9 +5,8 @@ using TMPro;
namespace YachtDice.UI
{
public sealed class GameInfoView : MonoBehaviour
{
public class GameInfoView : MonoBehaviour
{
[Header("Turn Info")]
[SerializeField] private TMP_Text turnText;
@@ -69,5 +68,5 @@ public sealed class GameInfoView : MonoBehaviour
if (inventoryButton != null)
inventoryButton.onClick.RemoveAllListeners();
}
}
}
}
+3 -4
View File
@@ -6,9 +6,8 @@ using YachtDice.Scoring;
namespace YachtDice.UI
{
public sealed class ScoreCardView : MonoBehaviour
{
public class ScoreCardView : MonoBehaviour
{
[Header("Category Rows (in YachtCategory enum order)")]
[SerializeField] private List<CategoryRowView> categoryRows = new();
@@ -110,5 +109,5 @@ public sealed class ScoreCardView : MonoBehaviour
for (int i = 0; i < categoryRows.Count; i++)
categoryRows[i].OnCategorySelected -= HandleCategorySelected;
}
}
}
}