[Fix] Code visual
This commit is contained in:
@@ -3,58 +3,57 @@ using YachtDice.Scoring;
|
||||
|
||||
namespace YachtDice.Modifiers
|
||||
{
|
||||
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
|
||||
|
||||
public delegate void ModifierHandler(ModifierData data, ref ScoreResult result);
|
||||
|
||||
public static class ModifierEffect
|
||||
{
|
||||
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
|
||||
public static class ModifierEffect
|
||||
{
|
||||
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
|
||||
{ ModifierEffectType.AddFlatToFinalScore, ApplyAddFlat },
|
||||
{ ModifierEffectType.MultiplyPerDieValue, ApplyMultiplyPerDieValue },
|
||||
{ ModifierEffectType.MultiplyFinalScore, ApplyMultiplyFinal }
|
||||
};
|
||||
|
||||
public static void Apply(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
if (Handlers.TryGetValue(data.EffectType, out var handler))
|
||||
handler(data, ref result);
|
||||
}
|
||||
|
||||
private static void ApplyAddPerDieValue(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
int targetValue = data.Target.DieValue;
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < result.DiceValues.Length; i++)
|
||||
private static readonly Dictionary<ModifierEffectType, ModifierHandler> Handlers = new()
|
||||
{
|
||||
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
||||
count++;
|
||||
{ ModifierEffectType.AddPerDieValue, ApplyAddPerDieValue },
|
||||
{ ModifierEffectType.AddFlatToFinalScore, ApplyAddFlat },
|
||||
{ ModifierEffectType.MultiplyPerDieValue, ApplyMultiplyPerDieValue },
|
||||
{ ModifierEffectType.MultiplyFinalScore, ApplyMultiplyFinal }
|
||||
};
|
||||
|
||||
public static void Apply(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
if (Handlers.TryGetValue(data.EffectType, out var handler))
|
||||
handler(data, ref result);
|
||||
}
|
||||
|
||||
result.FlatBonus += (int)(data.EffectValue * count);
|
||||
}
|
||||
|
||||
private static void ApplyAddFlat(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
result.FlatBonus += (int)data.EffectValue;
|
||||
}
|
||||
|
||||
private static void ApplyMultiplyPerDieValue(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
int targetValue = data.Target.DieValue;
|
||||
|
||||
for (int i = 0; i < result.DiceValues.Length; i++)
|
||||
private static void ApplyAddPerDieValue(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
||||
result.Multiplier *= data.EffectValue;
|
||||
int targetValue = data.Target.DieValue;
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < result.DiceValues.Length; i++)
|
||||
{
|
||||
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
||||
count++;
|
||||
}
|
||||
|
||||
result.FlatBonus += (int)(data.EffectValue * count);
|
||||
}
|
||||
|
||||
private static void ApplyAddFlat(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
result.FlatBonus += (int)data.EffectValue;
|
||||
}
|
||||
|
||||
private static void ApplyMultiplyPerDieValue(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
int targetValue = data.Target.DieValue;
|
||||
|
||||
for (int i = 0; i < result.DiceValues.Length; i++)
|
||||
{
|
||||
if (targetValue == 0 || result.DiceValues[i] == targetValue)
|
||||
result.Multiplier *= data.EffectValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyMultiplyFinal(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
result.Multiplier *= data.EffectValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyMultiplyFinal(ModifierData data, ref ScoreResult result)
|
||||
{
|
||||
result.Multiplier *= data.EffectValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user