mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Card: add EtbCounter functions: that does handle ETB counter effects with Replacements better
This commit is contained in:
@@ -227,7 +227,7 @@ public class GameAction {
|
|||||||
copied.getOwner().addInboundToken(copied);
|
copied.getOwner().addInboundToken(copied);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, Object> repParams = new HashMap<String, Object>();
|
Map<String, Object> repParams = Maps.newHashMap();
|
||||||
repParams.put("Event", "Moved");
|
repParams.put("Event", "Moved");
|
||||||
repParams.put("Affected", copied);
|
repParams.put("Affected", copied);
|
||||||
repParams.put("CardLKI", lastKnownInfo);
|
repParams.put("CardLKI", lastKnownInfo);
|
||||||
@@ -252,6 +252,10 @@ public class GameAction {
|
|||||||
lastKnownInfo = CardUtil.getLKICopy(c);
|
lastKnownInfo = CardUtil.getLKICopy(c);
|
||||||
c.setUnearthed(false);
|
c.setUnearthed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toBattlefield) {
|
||||||
|
copied.putEtbCounters();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copied.getOwner().removeInboundToken(copied);
|
copied.getOwner().removeInboundToken(copied);
|
||||||
|
|||||||
@@ -192,7 +192,11 @@ 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)) {
|
||||||
tgtCard.addCounter(counterType, counterAmount, true);
|
if (etbcounter) {
|
||||||
|
tgtCard.addEtbCounter(counterType, counterAmount);
|
||||||
|
} else {
|
||||||
|
tgtCard.addCounter(counterType, counterAmount, true);
|
||||||
|
}
|
||||||
if (remember) {
|
if (remember) {
|
||||||
final int value = tgtCard.getTotalCountersToAdd();
|
final int value = tgtCard.getTotalCountersToAdd();
|
||||||
tgtCard.addCountersAddedBy(card, counterType, value);
|
tgtCard.addCountersAddedBy(card, counterType, value);
|
||||||
@@ -219,7 +223,11 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
|||||||
} else {
|
} else {
|
||||||
// adding counters to something like re-suspend cards
|
// adding counters to something like re-suspend cards
|
||||||
// etbcounter should apply multiplier
|
// etbcounter should apply multiplier
|
||||||
tgtCard.addCounter(counterType, counterAmount, etbcounter);
|
if (etbcounter) {
|
||||||
|
tgtCard.addEtbCounter(counterType, counterAmount);
|
||||||
|
} else {
|
||||||
|
tgtCard.addCounter(counterType, counterAmount, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (obj instanceof Player) {
|
} else if (obj instanceof Player) {
|
||||||
|
|||||||
@@ -242,6 +242,8 @@ 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);
|
||||||
|
|
||||||
// Enumeration for CMC request types
|
// Enumeration for CMC request types
|
||||||
public enum SplitCMCMode {
|
public enum SplitCMCMode {
|
||||||
CurrentSideCMC,
|
CurrentSideCMC,
|
||||||
@@ -7126,4 +7128,28 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void setLastKnownZone(Zone zone) {
|
public final void setLastKnownZone(Zone zone) {
|
||||||
this.savedLastKnownZone = zone;
|
this.savedLastKnownZone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
int old = etbCounters.containsKey(type) ? etbCounters.get(type) : 0;
|
||||||
|
etbCounters.put(type, old + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void clearEtbCounters() {
|
||||||
|
etbCounters.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void putEtbCounters() {
|
||||||
|
for (Map.Entry<CounterType, Integer> e : etbCounters.entrySet()) {
|
||||||
|
this.addCounter(e.getKey(), e.getValue(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user