Files
tcg-client/Assets/TcgEngine/Scripts/Effects/EffectDamage.cs
yaoyanwei 2f2a601227 init
2025-08-04 16:45:48 +08:00

37 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TcgEngine.Gameplay;
namespace TcgEngine
{
/// <summary>
/// Effect that damages a card or a player (lose hp)
/// </summary>
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Damage", order = 10)]
public class EffectDamage : EffectData
{
public TraitData bonus_damage;
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
{
int damage = GetDamage(logic.GameData, caster, ability.value);
logic.DamagePlayer(caster, target, damage);
}
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
{
int damage = GetDamage(logic.GameData, caster, ability.value);
logic.DamageCard(caster, target, damage, true);
}
private int GetDamage(Game data, Card caster, int value)
{
Player player = data.GetPlayer(caster.player_id);
int damage = value + caster.GetTraitValue(bonus_damage) + player.GetTraitValue(bonus_damage);
return damage;
}
}
}