This commit is contained in:
yaoyanwei
2025-08-04 16:45:48 +08:00
parent 565aa16389
commit 2f2a601227
2296 changed files with 522745 additions and 93 deletions

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TcgEngine.Gameplay;
namespace TcgEngine
{
/// <summary>
/// Effect to make a card attack a target
/// </summary>
[CreateAssetMenu(fileName = "effect", menuName = "TcgEngine/Effect/Attack", order = 10)]
public class EffectAttack : EffectData
{
public EffectAttackerType attacker_type;
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Player target)
{
Card attacker = GetAttacker(logic.GetGameData(), caster);
if (attacker != null)
{
logic.AttackPlayer(attacker, target, true);
}
}
public override void DoEffect(GameLogic logic, AbilityData ability, Card caster, Card target)
{
Card attack = GetAttacker(logic.GetGameData(), caster);
if (attack != null)
{
logic.AttackTarget(attack, target, true);
}
}
public Card GetAttacker(Game gdata, Card caster)
{
if (attacker_type == EffectAttackerType.Self)
return caster;
if (attacker_type == EffectAttackerType.AbilityTriggerer)
return gdata.GetCard(gdata.ability_triggerer);
if (attacker_type == EffectAttackerType.LastPlayed)
return gdata.GetCard(gdata.last_played);
if (attacker_type == EffectAttackerType.LastTargeted)
return gdata.GetCard(gdata.last_target);
return null;
}
}
public enum EffectAttackerType
{
Self = 1,
AbilityTriggerer = 25,
LastPlayed = 70,
LastTargeted = 72,
}
}