From 21db65e9abdeb1eef78f9eb1bfd214375fd6d478 Mon Sep 17 00:00:00 2001
From: swordshine
Date: Tue, 4 Feb 2014 08:09:25 +0000
Subject: [PATCH] - Update state-based actions (704_5r now fire remove counter
triggers, Brother Yamazaki now work correctly with Humility)
---
.../src/main/java/forge/game/GameAction.java | 39 ++++++++-----------
.../res/cardsfolder/b/brothers_yamazaki.txt | 3 +-
2 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java
index 9a2b1795ac5..3ed72d87da4 100644
--- a/forge-game/src/main/java/forge/game/GameAction.java
+++ b/forge-game/src/main/java/forge/game/GameAction.java
@@ -685,7 +685,7 @@ public class GameAction {
}
/** */
- public final void checkStaticAbilities() {
+ public final void checkStaticAbilities() { // TODO return checkagain in SBA
if (game.isGameOver()) {
return;
}
@@ -875,10 +875,9 @@ public class GameAction {
if (game.getTriggerHandler().runWaitingTriggers()) {
checkAgain = true;
}
-
- boolean yamazaki = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Brothers Yamazaki")).size() == 2;
+
for (Player p : game.getPlayers()) {
- if (this.handleLegendRule(p, yamazaki)) {
+ if (this.handleLegendRule(p)) {
checkAgain = true;
}
@@ -1041,19 +1040,16 @@ public class GameAction {
*/
private boolean stateBasedAction704_5r(Card c) {
boolean checkAgain = false;
- // +1/+1 counters should erase -1/-1 counters
- if (c.getCounters(CounterType.P1P1) > 0 && c.getCounters(CounterType.M1M1) > 0) {
- int plusOneCounters = c.getCounters(CounterType.P1P1);
- int minusOneCounters = c.getCounters(CounterType.M1M1);
-
- if (plusOneCounters >= minusOneCounters) c.getCounters().remove(CounterType.M1M1);
- if (plusOneCounters <= minusOneCounters) c.getCounters().remove(CounterType.P1P1);
-
- int diff = plusOneCounters - minusOneCounters;
- if (diff != 0) {
- CounterType ct = diff > 0 ? CounterType.P1P1 : CounterType.M1M1;
- c.getCounters().put(ct, Math.abs(diff));
- }
+ int plusOneCounters = c.getCounters(CounterType.P1P1);
+ int minusOneCounters = c.getCounters(CounterType.M1M1);
+ if (plusOneCounters > 0 && minusOneCounters > 0) {
+ int remove = Math.min(plusOneCounters, minusOneCounters);
+ // If a permanent has both a +1/+1 counter and a -1/-1 counter on it,
+ // N +1/+1 and N -1/-1 counters are removed from it, where N is the
+ // smaller of the number of +1/+1 and -1/-1 counters on it.
+ // This should fire remove counters trigger
+ c.subtractCounter(CounterType.P1P1, remove);
+ c.subtractCounter(CounterType.M1M1, remove);
checkAgain = true;
}
return checkAgain;
@@ -1186,16 +1182,15 @@ public class GameAction {
* destroyLegendaryCreatures.
*
*/
- private boolean handleLegendRule(Player p, boolean yama) {
+ private boolean handleLegendRule(Player p) {
final List a = CardLists.getType(p.getCardsIn(ZoneType.Battlefield), "Legendary");
if (a.isEmpty() || game.getStaticEffects().getGlobalRuleChange(GlobalRuleChange.noLegendRule)) {
return false;
}
boolean recheck = false;
- if (yama) {
- List yamazaki = CardLists.filter(a, CardPredicates.nameEquals("Brothers Yamazaki"));
- a.removeAll(yamazaki);
- }
+ List yamazaki = CardLists.getKeyword(a, "Legend rule doesn't apply to CARDNAME.");
+ a.removeAll(yamazaki);
+
Multimap uniqueLegends = ArrayListMultimap.create();
for (Card c : a) {
diff --git a/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt b/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt
index babfde304ec..90a5e1e0576 100644
--- a/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt
+++ b/forge-gui/res/cardsfolder/b/brothers_yamazaki.txt
@@ -2,8 +2,9 @@ Name:Brothers Yamazaki
ManaCost:2 R
Types:Legendary Creature Human Samurai
PT:2/1
-Text:If there are exactly two permanents named CARDNAME on the battlefield, the "legend rule" doesn't apply to them.
K:Bushido 1
+S:Mode$ Continuous | Affected$ Permanent.namedBrothers Yamazaki | CheckSVar$ X | SVarCompare$ EQ2 | AddHiddenKeyword$ Legend rule doesn't apply to CARDNAME. | Description$ If there are exactly two permanents named Brothers Yamazaki on the battlefield, the "legend rule" doesn't apply to them.
+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.
SVar:Picture:http://www.wizards.com/global/images/magic/general/brothers_yamazaki.jpg
Oracle:Bushido 1 (When this 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.
\ No newline at end of file