Files
tcg-client/Assets/TcgEngine/Scripts/Effects/EffectAddStatRoll.cs
2025-08-11 14:09:21 +08:00

71 lines
2.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TcgEngine.Gameplay;
namespace TcgEngine
{
/// <summary>
/// Effect that adds or removes basic card/player stats such as hp, attack, mana, by the value of the dice roll
/// </summary>
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/AddStatRoll", order = 10)]
public class EffectAddStatRoll : EffectData
{
public EffectStatType type;
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
{
Game data = logic.GetGameData();
if (type == EffectStatType.HP)
{
target.hp += data.rolled_value;
target.hp_max += data.rolled_value;
}
if (type == EffectStatType.Mana)
{
target.mana += data.rolled_value;
target.mana_max += data.rolled_value;
target.mana = Mathf.Max(target.mana, 0);
target.mana_max = Mathf.Clamp(target.mana_max, 0, GameplayData.Get().mana_max);
}
if (type == EffectStatType.ManaFire)
target.mana_fire += data.rolled_value;
target.mana_fire_max += data.rolled_value;
target.mana_fire = Mathf.Max(target.mana_fire, 0);
target.mana_fire_max = Mathf.Clamp(target.mana_fire_max, 0, GameplayData.Get().mana_max);
if (type == EffectStatType.ManaForest)
target.mana_forest += data.rolled_value;
target.mana_forest_max += data.rolled_value;
target.mana_forest = Mathf.Max(target.mana_forest, 0);
target.mana_forest_max = Mathf.Clamp(target.mana_forest_max, 0, GameplayData.Get().mana_max);
if (type == EffectStatType.ManaWater)
target.mana_water += data.rolled_value;
target.mana_water_max += data.rolled_value;
target.mana_water = Mathf.Max(target.mana_water, 0);
target.mana_water_max = Mathf.Clamp(target.mana_water_max, 0, GameplayData.Get().mana_max);
}
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
{
Game data = logic.GetGameData();
if (type == EffectStatType.Attack)
target.attack += data.rolled_value;
if (type == EffectStatType.HP)
target.hp += data.rolled_value;
if (type == EffectStatType.Mana)
target.mana += data.rolled_value;
if (type == EffectStatType.ManaFire)
target.mana_fire += data.rolled_value;
if (type == EffectStatType.ManaForest)
target.mana_forest += data.rolled_value;
if (type == EffectStatType.ManaWater)
target.mana_water += data.rolled_value;
}
}
}