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>
45 lines
1.6 KiB
C#
45 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 = "MultiplyPerDiceEffect", menuName = "YachtDice/Modifiers/Effects/Multiply Per Dice")]
|
|
public class MultiplyPerDiceEffect : Effect
|
|
{
|
|
[Tooltip("Multiplier to apply per matching dice.")]
|
|
[SerializeField] private float multiplierPerDice = 1f;
|
|
|
|
[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;
|
|
|
|
for (int i = 0; i < context.DiceValues.Length; i++)
|
|
{
|
|
if (targetDiceValue == 0 || context.DiceValues[i] == targetDiceValue)
|
|
context.Multiplier *= multiplierPerDice;
|
|
}
|
|
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
public static MultiplyPerDiceEffect CreateForTest(float multiplierPerDice, int targetDiceValue = 0,
|
|
ModifierPhase phase = ModifierPhase.Multiplicative, int priority = 0)
|
|
{
|
|
var so = CreateInstance<MultiplyPerDiceEffect>();
|
|
so.multiplierPerDice = multiplierPerDice;
|
|
so.targetDiceValue = targetDiceValue;
|
|
so.SetPhaseForTest(phase);
|
|
so.SetPriorityForTest(priority);
|
|
return so;
|
|
}
|
|
#endif
|
|
}
|
|
}
|