Files
YachtDice/Assets/Scripts/Modifiers/Conditions/DiceValueCondition.cs
T
horooko 13b18b0a8b [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>
2026-03-02 05:37:12 +07:00

38 lines
1.1 KiB
C#

using UnityEngine;
using YachtDice.Modifiers.Core;
using YachtDice.Modifiers.Definition;
using YachtDice.Modifiers.Runtime;
namespace YachtDice.Modifiers.Conditions
{
[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;
public override bool Evaluate(ModifierContext context, ModifierInstance instance)
{
if (context.DiceValues == null) return false;
int count = 0;
for (int i = 0; i < context.DiceValues.Length; i++)
{
if (context.DiceValues[i] == targetValue)
count++;
}
return count >= minCount;
}
#if UNITY_EDITOR
public static DiceValueCondition CreateForTest(int targetValue, int minCount = 1)
{
var so = CreateInstance<DiceValueCondition>();
so.targetValue = targetValue;
so.minCount = minCount;
return so;
}
#endif
}
}