mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
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:
@@ -1,6 +1,5 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -20,7 +19,6 @@ import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Lang;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -80,7 +78,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
if (!libCards.isEmpty()) {
|
||||
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("Target", tgtPlayers);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.SearchedLibrary, runParams, false);
|
||||
@@ -218,7 +216,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
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("Destination", destination);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ChangesZoneAll, runParams, false);
|
||||
|
||||
@@ -475,7 +475,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
if (sa.hasParam("WithCounters")) {
|
||||
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("NewController")) {
|
||||
|
||||
@@ -193,7 +193,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
|
||||
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
|
||||
if (etbcounter) {
|
||||
tgtCard.addEtbCounter(counterType, counterAmount);
|
||||
tgtCard.addEtbCounter(counterType, counterAmount, card);
|
||||
} else {
|
||||
tgtCard.addCounter(counterType, counterAmount, card, true);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
// adding counters to something like re-suspend cards
|
||||
// etbcounter should apply multiplier
|
||||
if (etbcounter) {
|
||||
tgtCard.addEtbCounter(counterType, counterAmount);
|
||||
tgtCard.addEtbCounter(counterType, counterAmount, card);
|
||||
} else {
|
||||
tgtCard.addCounter(counterType, counterAmount, card, false);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private CardRules cardRules;
|
||||
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
|
||||
public enum SplitCMCMode {
|
||||
@@ -7118,14 +7118,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* ETBCounters are only used between replacementEffects
|
||||
* and when the Card really enters the Battlefield with the counters
|
||||
* @return map of counters
|
||||
*/
|
||||
public final Map<CounterType,Integer> getEtbCounters() {
|
||||
return etbCounters;
|
||||
*/
|
||||
public final void addEtbCounter(CounterType type, Integer val) {
|
||||
addEtbCounter(type, val, this);
|
||||
}
|
||||
|
||||
public final void addEtbCounter(CounterType type, Integer val) {
|
||||
int old = etbCounters.containsKey(type) ? etbCounters.get(type) : 0;
|
||||
etbCounters.put(type, old + val);
|
||||
public final void addEtbCounter(CounterType type, Integer val, final Card source) {
|
||||
int old = etbCounters.get(source, type);
|
||||
etbCounters.put(source, type, old + val);
|
||||
}
|
||||
|
||||
public final void clearEtbCounters() {
|
||||
@@ -7133,8 +7133,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
public final void putEtbCounters() {
|
||||
for (Map.Entry<CounterType, Integer> e : etbCounters.entrySet()) {
|
||||
this.addCounter(e.getKey(), e.getValue(), this, true);
|
||||
for (Table.Cell<Card, CounterType, Integer> e : etbCounters.cellSet()) {
|
||||
this.addCounter(e.getColumnKey(), e.getValue(), e.getRowKey(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user