From cfab2fe985b36568d13d386cf5ed0a3d3ec90090 Mon Sep 17 00:00:00 2001 From: Myrd Date: Thu, 31 Dec 2015 17:57:57 +0000 Subject: [PATCH] Implement Okk and Orcish Conscripts. --- .gitattributes | 2 + .../java/forge/game/phase/PhaseHandler.java | 38 ++++++++++++++++--- .../res/cardsfolder/e/ekundu_cyclops.txt | 1 + forge-gui/res/cardsfolder/o/okk.txt | 8 ++++ .../res/cardsfolder/o/orcish_conscripts.txt | 8 ++++ 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 forge-gui/res/cardsfolder/o/okk.txt create mode 100644 forge-gui/res/cardsfolder/o/orcish_conscripts.txt diff --git a/.gitattributes b/.gitattributes index baf535f4d9a..0e4216ba568 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10434,6 +10434,7 @@ forge-gui/res/cardsfolder/o/ojutais_summons.txt -text forge-gui/res/cardsfolder/o/okiba_gang_shinobi.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/okina_nightwatch.txt -text forge-gui/res/cardsfolder/o/okina_temple_to_the_grandfathers.txt svneol=native#text/plain +forge-gui/res/cardsfolder/o/okk.txt -text forge-gui/res/cardsfolder/o/old_ghastbark.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/old_man_of_the_sea.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/olivia_voldaren.txt -text @@ -10527,6 +10528,7 @@ forge-gui/res/cardsfolder/o/orcish_bloodpainter.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/orcish_cannonade.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/orcish_cannoneers.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/orcish_captain.txt svneol=native#text/plain +forge-gui/res/cardsfolder/o/orcish_conscripts.txt -text forge-gui/res/cardsfolder/o/orcish_farmer.txt -text forge-gui/res/cardsfolder/o/orcish_healer.txt svneol=native#text/plain forge-gui/res/cardsfolder/o/orcish_librarian.txt -text diff --git a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java index fc2caff1188..0f4468c5a60 100644 --- a/forge-game/src/main/java/forge/game/phase/PhaseHandler.java +++ b/forge-game/src/main/java/forge/game/phase/PhaseHandler.java @@ -594,12 +594,40 @@ public class PhaseHandler implements java.io.Serializable { } } - List remainingBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), p); - for (Card c : remainingBlockers) { - if (remainingBlockers.size() < 2 && c.hasKeyword("CARDNAME can't attack or block alone.")) { - combat.undoBlockingAssignment(c); + // We may need to do multiple iterations removing blockers, since removing one may invalidate + // others. The loop below is structured so that if no blockers were removed, no extra passes + // are needed. + boolean reachedSteadyState; + do { + reachedSteadyState = true; + List remainingBlockers = CardLists.filterControlledBy(combat.getAllBlockers(), p); + for (Card c : remainingBlockers) { + int minBlockers = Integer.MIN_VALUE; + if (c.hasKeyword("CARDNAME can't attack or block alone.")) { + minBlockers = 2; + } else if (c.hasKeyword("CARDNAME can't block unless at least two other creatures block.")) { + minBlockers = 3; + } + if (remainingBlockers.size() < minBlockers) { + combat.undoBlockingAssignment(c); + reachedSteadyState = false; + } else if (c.hasKeyword("CARDNAME can't block unless a creature with greater power also blocks.")) { + boolean found = false; + int power = c.getNetPower(); + // Note: This is O(n^2), but there shouldn't generally be many creatures with the above keyword. + for (Card c2 : remainingBlockers) { + if (c2.getNetPower() > power) { + found = true; + break; + } + } + if (!found) { + combat.undoBlockingAssignment(c); + reachedSteadyState = false; + } + } } - } + } while (!reachedSteadyState); // Player is done declaring blockers - redraw UI at this point diff --git a/forge-gui/res/cardsfolder/e/ekundu_cyclops.txt b/forge-gui/res/cardsfolder/e/ekundu_cyclops.txt index 755e7a9c732..cc0677bd0bc 100644 --- a/forge-gui/res/cardsfolder/e/ekundu_cyclops.txt +++ b/forge-gui/res/cardsfolder/e/ekundu_cyclops.txt @@ -3,4 +3,5 @@ ManaCost:3 R Types:Creature Cyclops PT:3/4 K:If a creature you control attacks, CARDNAME also attacks if able. +SVar:Picture:http://www.wizards.com/global/images/magic/general/ekundu_cyclops.jpg Oracle:If a creature you control attacks, Ekundu Cyclops also attacks if able. diff --git a/forge-gui/res/cardsfolder/o/okk.txt b/forge-gui/res/cardsfolder/o/okk.txt new file mode 100644 index 00000000000..2b7dcfeaed2 --- /dev/null +++ b/forge-gui/res/cardsfolder/o/okk.txt @@ -0,0 +1,8 @@ +Name:Okk +ManaCost:1 R +Types:Creature Goblin +PT:4/4 +K:CARDNAME can't attack unless a creature with greater power also attacks. +K:CARDNAME can't block unless a creature with greater power also blocks. +SVar:Picture:http://www.wizards.com/global/images/magic/general/okk.jpg +Oracle:Okk can't attack unless a creature with greater power also attacks.\nOkk can't block unless a creature with greater power also blocks. diff --git a/forge-gui/res/cardsfolder/o/orcish_conscripts.txt b/forge-gui/res/cardsfolder/o/orcish_conscripts.txt new file mode 100644 index 00000000000..42d4f5e1a74 --- /dev/null +++ b/forge-gui/res/cardsfolder/o/orcish_conscripts.txt @@ -0,0 +1,8 @@ +Name:Orcish Conscripts +ManaCost:R +Types:Creature Orc +PT:2/2 +K:CARDNAME can't attack unless at least two other creatures attack. +K:CARDNAME can't block unless at least two other creatures block. +SVar:Picture:http://www.wizards.com/global/images/magic/general/orcish_conscripts.jpg +Oracle:Orcish Conscripts can't attack unless at least two other creatures attack.\nOkk can't block unless at least two other creatures block.