bee20fd1f8
Wrap all 39 scripts and 6 test files in namespaces matching their folder structure (e.g. Assets/Scripts/Dice/ → YachtDice.Dice). Add cross-namespace using directives where types are referenced across modules. Set rootNamespace in both .asmdef files (YachtDice, YachtDice.Tests). Namespace mapping: - YachtDice.Dice — Dice, DiceRoller - YachtDice.Economy — CurrencyBank - YachtDice.Game — GameManager, DiceManager, DebugGameInput - YachtDice.Inventory — InventoryController/Model/SlotView/View - YachtDice.Modifiers — ModifierData/Effect/Enums/Pipeline/Runtime/Target - YachtDice.Persistence — SaveData, SaveSystem - YachtDice.Scoring — CategoryScorer, ScoreResult, ScoringSystem, YachtCategory - YachtDice.Shop — ShopCatalog/Controller/ItemView/Model/View - YachtDice.UI — CategoryRowView, DicePanelView, GameController, GameInfoView, ScoreCardView - YachtDice.Editor — ModifierAssetCreator - YachtDice.Tests — all test files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
using NUnit.Framework;
|
|
using UnityEngine;
|
|
using YachtDice.Modifiers;
|
|
using YachtDice.Scoring;
|
|
|
|
namespace YachtDice.Tests
|
|
{
|
|
|
|
public sealed class ModifierEffectTests
|
|
{
|
|
private static ModifierData CreateData(
|
|
ModifierEffectType effectType, float effectValue,
|
|
int dieValue = 0, ModifierScope scope = ModifierScope.SelectedCategory)
|
|
{
|
|
return ModifierData.CreateForTest("test", scope, effectType, effectValue, dieValue);
|
|
}
|
|
|
|
[Test]
|
|
public void AddPerDieValue_CountsMatchingDice()
|
|
{
|
|
var data = CreateData(ModifierEffectType.AddPerDieValue, 10f, dieValue: 1);
|
|
var result = ScoreResult.Create(5, new[] { 1, 1, 3, 4, 1 }, YachtCategory.Ones);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(30, result.FlatBonus);
|
|
}
|
|
|
|
[Test]
|
|
public void AddPerDieValue_ZeroTarget_CountsAllDice()
|
|
{
|
|
var data = CreateData(ModifierEffectType.AddPerDieValue, 2f, dieValue: 0);
|
|
var result = ScoreResult.Create(10, new[] { 1, 2, 3, 4, 5 }, YachtCategory.Chance);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(10, result.FlatBonus);
|
|
}
|
|
|
|
[Test]
|
|
public void AddPerDieValue_NoMatches_ZeroBonus()
|
|
{
|
|
var data = CreateData(ModifierEffectType.AddPerDieValue, 10f, dieValue: 6);
|
|
var result = ScoreResult.Create(5, new[] { 1, 2, 3, 4, 5 }, YachtCategory.Chance);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(0, result.FlatBonus);
|
|
}
|
|
|
|
[Test]
|
|
public void AddFlatToFinalScore_AddsFlat()
|
|
{
|
|
var data = CreateData(ModifierEffectType.AddFlatToFinalScore, 15f);
|
|
var result = ScoreResult.Create(25, new[] { 3, 3, 2, 2, 2 }, YachtCategory.FullHouse);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(15, result.FlatBonus);
|
|
}
|
|
|
|
[Test]
|
|
public void MultiplyPerDieValue_MultipliesPerMatch()
|
|
{
|
|
var data = CreateData(ModifierEffectType.MultiplyPerDieValue, 2f, dieValue: 6);
|
|
var result = ScoreResult.Create(18, new[] { 6, 6, 6, 1, 2 }, YachtCategory.Sixes);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(8f, result.Multiplier); // 1 * 2 * 2 * 2 = 8
|
|
}
|
|
|
|
[Test]
|
|
public void MultiplyPerDieValue_NoMatches_MultiplierUnchanged()
|
|
{
|
|
var data = CreateData(ModifierEffectType.MultiplyPerDieValue, 3f, dieValue: 6);
|
|
var result = ScoreResult.Create(10, new[] { 1, 2, 3, 4, 5 }, YachtCategory.Chance);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(1f, result.Multiplier);
|
|
}
|
|
|
|
[Test]
|
|
public void MultiplyFinalScore_MultipliesOnce()
|
|
{
|
|
var data = CreateData(ModifierEffectType.MultiplyFinalScore, 1.5f);
|
|
var result = ScoreResult.Create(50, new[] { 6, 6, 6, 6, 6 }, YachtCategory.Yacht);
|
|
|
|
ModifierEffect.Apply(data, ref result);
|
|
|
|
Assert.AreEqual(1.5f, result.Multiplier, 0.001f);
|
|
}
|
|
}
|
|
}
|