From 0a1f2f6670ba6476ca94f677669f63d6acb4eafb Mon Sep 17 00:00:00 2001 From: Agetian Date: Wed, 28 Nov 2018 15:31:16 +0300 Subject: [PATCH] - Improve AI for Brothers Yamazaki. --- .../java/forge/ai/ability/PermanentAi.java | 19 +++++++++++++++++-- .../res/cardsfolder/b/brothers_yamazaki.txt | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java index d0579d313ad..e89c9e87d3e 100644 --- a/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/PermanentAi.java @@ -61,8 +61,23 @@ public class PermanentAi extends SpellAbilityAi { if (card.getType().isLegendary() && !game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) { if (ai.isCardInPlay(card.getName())) { - // AiPlayDecision.WouldDestroyLegend - return false; + if (!card.hasSVar("AILegendaryException")) { + // AiPlayDecision.WouldDestroyLegend + return false; + } else { + String specialRule = card.getSVar("AILegendaryException"); + if ("TwoCopiesAllowed".equals(specialRule)) { + // One extra copy allowed on the battlefield, e.g. Brothers Yamazaki + if (CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals(card.getName())).size() > 1) { + return false; + } + } else if ("AlwaysAllowed".equals(specialRule)) { + // Nothing to do here, check for Legendary is disabled + } else { + // Unknown hint, assume two copies not allowed + return false; + } + } } } diff --git a/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt b/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt index 36da0aff1c4..0204b134bf5 100644 --- a/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt +++ b/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt @@ -7,5 +7,7 @@ S:Mode$ Continuous | Affected$ Permanent.namedBrothers Yamazaki | CheckSVar$ X | SVar:X:Count$Valid Permanent.namedBrothers Yamazaki S:Mode$ Continuous | Affected$ Creature.Other+namedBrothers Yamazaki | AddPower$ 2 | AddToughness$ 2 | AddKeyword$ Haste | Description$ Each other creature named CARDNAME gets +2/+2 and has haste. DeckHints:Name$Brothers Yamazaki +SVar:AILegendaryException:TwoCopiesAllowed +SVar:PlayMain1:TRUE SVar:Picture:http://www.wizards.com/global/images/magic/general/brothers_yamazaki.jpg Oracle:Bushido 1 (Whenever this creature blocks or becomes blocked, it gets +1/+1 until end of turn.)\nIf there are exactly two permanents named Brothers Yamazaki on the battlefield, the "legend rule" doesn't apply to them.\nEach other creature named Brothers Yamazaki gets +2/+2 and has haste.