Commit 4866c58c authored by mercury233's avatar mercury233

add Executor.OnPreActivate

don't activate if the card will be negated
parent 4eb4cab5
......@@ -116,6 +116,7 @@ namespace WindBot.Game.AI
public const int RedDragonArchfiend = 70902743;
public const int ImperialOrder = 61740673;
public const int RoyalDecreel = 51452091;
public const int NaturiaBeast = 33198837;
public const int AntiSpellFragrance = 58921041;
}
......@@ -247,6 +248,29 @@ namespace WindBot.Game.AI
return true;
}
public override bool OnPreActivate(ClientCard card)
{
ClientCard LastChainCard = Util.GetLastChainCard();
if (LastChainCard != null && Duel.Phase == DuelPhase.Standby &&
LastChainCard.IsCode(
_CardId.SandaionTheTimelord,
_CardId.GabrionTheTimelord,
_CardId.MichionTheTimelord,
_CardId.ZaphionTheTimelord,
_CardId.HailonTheTimelord,
_CardId.RaphionTheTimelord,
_CardId.SadionTheTimelord,
_CardId.MetaionTheTimelord,
_CardId.KamionTheTimelord,
_CardId.LazionTheTimelord
))
return false;
if ((card.Location == CardLocation.Hand || card.Location == CardLocation.SpellZone && card.IsFacedown()) &&
(Card.IsSpell() && DefaultSpellWillBeNegated() || card.IsTrap() && DefaultTrapWillBeNegated()))
return false;
return true;
}
/// <summary>
/// Called when the AI has to select a card position.
/// </summary>
......@@ -729,7 +753,15 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultSpellWillBeNegated()
{
return Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true);
return (Bot.HasInSpellZone(_CardId.ImperialOrder, true, true) || Enemy.HasInSpellZone(_CardId.ImperialOrder, true)) && !Util.ChainContainsCard(_CardId.ImperialOrder);
}
/// <summary>
/// If trap will be negated
/// </summary>
protected bool DefaultTrapWillBeNegated()
{
return (Bot.HasInSpellZone(_CardId.RoyalDecreel, true, true) || Enemy.HasInSpellZone(_CardId.RoyalDecreel, true)) && !Util.ChainContainsCard(_CardId.RoyalDecreel);
}
/// <summary>
......
......@@ -73,13 +73,19 @@ namespace WindBot.Game.AI
public virtual BattlePhaseAction OnSelectAttackTarget(ClientCard attacker, IList<ClientCard> defenders)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return null;
}
public virtual bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return true;
}
public virtual bool OnPreActivate(ClientCard card)
{
// Overrided in DefaultExecutor
return true;
}
......@@ -178,13 +184,13 @@ namespace WindBot.Game.AI
public virtual CardPosition OnSelectPosition(int cardId, IList<CardPosition> positions)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return 0;
}
public virtual bool OnSelectBattleReplay()
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return false;
}
......@@ -194,7 +200,7 @@ namespace WindBot.Game.AI
/// <returns>True if select to set the monster.</returns>
public virtual bool OnSelectMonsterSummonOrSet(ClientCard card)
{
// Overrided in DefalultExecutor
// Overrided in DefaultExecutor
return false;
}
......
......@@ -1102,10 +1102,12 @@ namespace WindBot.Game
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1)
{
if (card.Id != 0 && type == ExecutorType.Activate &&
_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
if (card.Id != 0 && type == ExecutorType.Activate)
{
return false;
if (_activatedCards.ContainsKey(card.Id) && _activatedCards[card.Id] >= 9)
return false;
if (!Executor.OnPreActivate(card))
return false;
}
Executor.SetCard(type, card, desc);
bool result = card != null && exec.Type == type &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment