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>
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using YachtDice.Modifiers.Core;
|
|
using YachtDice.Modifiers.Definition;
|
|
using YachtDice.Modifiers.Runtime;
|
|
|
|
namespace YachtDice.Modifiers.Effects
|
|
{
|
|
[CreateAssetMenu(fileName = "AddPerDiceEffect", menuName = "YachtDice/Modifiers/Effects/Add Per Dice")]
|
|
public class AddPerDiceEffect : Effect
|
|
{
|
|
[Tooltip("Points to add per matching dice.")]
|
|
[SerializeField] private int valuePerDice;
|
|
|
|
[Tooltip("Dice face value to match (1-6). 0 = any/all dice.")]
|
|
[SerializeField, Range(0, 6)] private int targetDiceValue;
|
|
|
|
public override UniTask Apply(ModifierContext context, ModifierInstance instance)
|
|
{
|
|
if (context.DiceValues == null) return UniTask.CompletedTask;
|
|
|
|
int count = 0;
|
|
for (int i = 0; i < context.DiceValues.Length; i++)
|
|
{
|
|
if (targetDiceValue == 0 || context.DiceValues[i] == targetDiceValue)
|
|
count++;
|
|
}
|
|
|
|
context.FlatBonus += valuePerDice * count * instance.Stacks;
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public static AddPerDiceEffect CreateForTest(int valuePerDice, int targetDiceValue = 0,
|
|
ModifierPhase phase = ModifierPhase.Additive, int priority = 0)
|
|
{
|
|
var so = CreateInstance<AddPerDiceEffect>();
|
|
so.valuePerDice = valuePerDice;
|
|
so.targetDiceValue = targetDiceValue;
|
|
so.SetPhaseForTest(phase);
|
|
so.SetPriorityForTest(priority);
|
|
return so;
|
|
}
|
|
#endif
|
|
}
|
|
}
|