Card: EtbCounters now use a Table to store what the cause of the etb counter was, for something which does care about that

This commit is contained in:
Hanmac
2017-07-07 18:30:29 +00:00
parent d17b3d4019
commit c04bae00d0
4 changed files with 14 additions and 16 deletions

View File

@@ -1,6 +1,5 @@
package forge.game.ability.effects; package forge.game.ability.effects;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -20,7 +19,6 @@ import forge.game.zone.Zone;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.util.Lang; import forge.util.Lang;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -80,7 +78,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
if (!libCards.isEmpty()) { if (!libCards.isEmpty()) {
sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner()); sa.getActivatingPlayer().getController().reveal(libCards, ZoneType.Library, libCards.get(0).getOwner());
} }
final HashMap<String, Object> runParams = new HashMap<String, Object>(); final Map<String, Object> runParams = Maps.newHashMap();
runParams.put("Player", sa.getActivatingPlayer()); runParams.put("Player", sa.getActivatingPlayer());
runParams.put("Target", tgtPlayers); runParams.put("Target", tgtPlayers);
game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
@@ -218,7 +216,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
} }
if (!triggerList.isEmpty()) { if (!triggerList.isEmpty()) {
final HashMap<String, Object> runParams = new HashMap<String, Object>(); final Map<String, Object> runParams = Maps.newHashMap();
runParams.put("Cards", triggerList); runParams.put("Cards", triggerList);
runParams.put("Destination", destination); runParams.put("Destination", destination);
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false); game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);

View File

@@ -475,7 +475,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
} }
if (sa.hasParam("WithCounters")) { if (sa.hasParam("WithCounters")) {
String[] parse = sa.getParam("WithCounters").split("_"); String[] parse = sa.getParam("WithCounters").split("_");
tgtC.addEtbCounter(CounterType.getType(parse[0]), Integer.parseInt(parse[1])); tgtC.addEtbCounter(CounterType.getType(parse[0]), Integer.parseInt(parse[1]), hostCard);
} }
if (sa.hasParam("GainControl")) { if (sa.hasParam("GainControl")) {
if (sa.hasParam("NewController")) { if (sa.hasParam("NewController")) {

View File

@@ -193,7 +193,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard); final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) { if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
if (etbcounter) { if (etbcounter) {
tgtCard.addEtbCounter(counterType, counterAmount); tgtCard.addEtbCounter(counterType, counterAmount, card);
} else { } else {
tgtCard.addCounter(counterType, counterAmount, card, true); tgtCard.addCounter(counterType, counterAmount, card, true);
} }
@@ -224,7 +224,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
// adding counters to something like re-suspend cards // adding counters to something like re-suspend cards
// etbcounter should apply multiplier // etbcounter should apply multiplier
if (etbcounter) { if (etbcounter) {
tgtCard.addEtbCounter(counterType, counterAmount); tgtCard.addEtbCounter(counterType, counterAmount, card);
} else { } else {
tgtCard.addCounter(counterType, counterAmount, card, false); tgtCard.addCounter(counterType, counterAmount, card, false);
} }

View File

@@ -254,7 +254,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private CardRules cardRules; private CardRules cardRules;
private final CardView view; private final CardView view;
private Map<CounterType, Integer> etbCounters = Maps.newEnumMap(CounterType.class); private Table<Card, CounterType, Integer> etbCounters = HashBasedTable.create();
// Enumeration for CMC request types // Enumeration for CMC request types
public enum SplitCMCMode { public enum SplitCMCMode {
@@ -7119,13 +7119,13 @@ public class Card extends GameEntity implements Comparable<Card> {
* and when the Card really enters the Battlefield with the counters * and when the Card really enters the Battlefield with the counters
* @return map of counters * @return map of counters
*/ */
public final Map<CounterType,Integer> getEtbCounters() { public final void addEtbCounter(CounterType type, Integer val) {
return etbCounters; addEtbCounter(type, val, this);
} }
public final void addEtbCounter(CounterType type, Integer val) { public final void addEtbCounter(CounterType type, Integer val, final Card source) {
int old = etbCounters.containsKey(type) ? etbCounters.get(type) : 0; int old = etbCounters.get(source, type);
etbCounters.put(type, old + val); etbCounters.put(source, type, old + val);
} }
public final void clearEtbCounters() { public final void clearEtbCounters() {
@@ -7133,8 +7133,8 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
public final void putEtbCounters() { public final void putEtbCounters() {
for (Map.Entry<CounterType, Integer> e : etbCounters.entrySet()) { for (Table.Cell<Card, CounterType, Integer> e : etbCounters.cellSet()) {
this.addCounter(e.getKey(), e.getValue(), this, true); this.addCounter(e.getColumnKey(), e.getValue(), e.getRowKey(), true);
} }
} }