13b18b0a8b
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>
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using UnityEngine;
|
|
using YachtDice.Modifiers.Core;
|
|
using YachtDice.Modifiers.Definition;
|
|
using YachtDice.Modifiers.Runtime;
|
|
|
|
namespace YachtDice.Modifiers.Conditions
|
|
{
|
|
[CreateAssetMenu(fileName = "DiceCountCondition", menuName = "YachtDice/Modifiers/Conditions/Dice Count")]
|
|
public class DiceCountCondition : Condition
|
|
{
|
|
[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.")]
|
|
[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 (targetValue == 0 || context.DiceValues[i] == targetValue)
|
|
count++;
|
|
}
|
|
return count >= minCount;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public static DiceCountCondition CreateForTest(int targetValue, int minCount)
|
|
{
|
|
var so = CreateInstance<DiceCountCondition>();
|
|
so.targetValue = targetValue;
|
|
so.minCount = minCount;
|
|
return so;
|
|
}
|
|
#endif
|
|
}
|
|
}
|