mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Merge branch 'etbCounterArixmethes' into 'master'
GameAction: fixed putEtbCounters with Arixmethes See merge request core-developers/forge!814
This commit is contained in:
@@ -256,7 +256,20 @@ public class GameAction {
|
|||||||
CardCollection preList = new CardCollection(noLandLKI);
|
CardCollection preList = new CardCollection(noLandLKI);
|
||||||
checkStaticAbilities(false, Sets.newHashSet(noLandLKI), preList);
|
checkStaticAbilities(false, Sets.newHashSet(noLandLKI), preList);
|
||||||
|
|
||||||
|
// fake etb counters thing, then if something changed,
|
||||||
|
// need to apply checkStaticAbilities again
|
||||||
|
if(!noLandLKI.isLand()) {
|
||||||
|
if (noLandLKI.putEtbCounters()) {
|
||||||
|
// counters are added need to check again
|
||||||
|
checkStaticAbilities(false, Sets.newHashSet(noLandLKI), preList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(noLandLKI.isLand()) {
|
if(noLandLKI.isLand()) {
|
||||||
|
// if it isn't on the Stack, it stays in that Zone
|
||||||
|
if (!c.getZone().is(ZoneType.Stack)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
// if something would only be a land when entering the battlefield and not before
|
// if something would only be a land when entering the battlefield and not before
|
||||||
// put it into the graveyard instead
|
// put it into the graveyard instead
|
||||||
zoneTo = c.getOwner().getZone(ZoneType.Graveyard);
|
zoneTo = c.getOwner().getZone(ZoneType.Graveyard);
|
||||||
@@ -264,6 +277,9 @@ public class GameAction {
|
|||||||
copied.setState(CardStateName.Original, false);
|
copied.setState(CardStateName.Original, false);
|
||||||
copied.setManifested(false);
|
copied.setManifested(false);
|
||||||
copied.updateStateForView();
|
copied.updateStateForView();
|
||||||
|
|
||||||
|
// not to battlefield anymore!
|
||||||
|
toBattlefield = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +375,10 @@ public class GameAction {
|
|||||||
// do ETB counters after StaticAbilities check
|
// do ETB counters after StaticAbilities check
|
||||||
if (!suppress) {
|
if (!suppress) {
|
||||||
if (toBattlefield) {
|
if (toBattlefield) {
|
||||||
copied.putEtbCounters();
|
if (copied.putEtbCounters()) {
|
||||||
|
// if counter where put of card, call checkStaticAbilities again
|
||||||
|
checkStaticAbilities();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
copied.clearEtbCounters();
|
copied.clearEtbCounters();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ public abstract class GameEntity extends GameObject implements IIdentifiable {
|
|||||||
abstract public void setCounters(final Map<CounterType, Integer> allCounters);
|
abstract public void setCounters(final Map<CounterType, Integer> allCounters);
|
||||||
|
|
||||||
abstract public boolean canReceiveCounters(final CounterType type);
|
abstract public boolean canReceiveCounters(final CounterType type);
|
||||||
abstract public void addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier, final boolean fireEvents);
|
abstract public int addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier, final boolean fireEvents);
|
||||||
abstract public void subtractCounter(final CounterType counterName, final int n);
|
abstract public void subtractCounter(final CounterType counterName, final int n);
|
||||||
abstract public void clearCounters();
|
abstract public void clearCounters();
|
||||||
|
|
||||||
|
|||||||
@@ -1082,18 +1082,19 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
countersAdded = value;
|
countersAdded = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
public final int addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
||||||
addCounter(counterType, n, source, applyMultiplier, true);
|
return addCounter(counterType, n, source, applyMultiplier, true);
|
||||||
}
|
}
|
||||||
public final void addCounterFireNoEvents(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
public final int addCounterFireNoEvents(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
||||||
addCounter(counterType, n, source, applyMultiplier, false);
|
return addCounter(counterType, n, source, applyMultiplier, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier, final boolean fireEvents) {
|
public int addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier, final boolean fireEvents) {
|
||||||
int addAmount = n;
|
int addAmount = n;
|
||||||
if(addAmount < 0) {
|
if(addAmount < 0) {
|
||||||
addAmount = 0; // As per rule 107.1b
|
addAmount = 0; // As per rule 107.1b
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
final Map<String, Object> repParams = Maps.newHashMap();
|
final Map<String, Object> repParams = Maps.newHashMap();
|
||||||
repParams.put("Event", "AddCounter");
|
repParams.put("Event", "AddCounter");
|
||||||
@@ -1111,7 +1112,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canReceiveCounters(counterType)) {
|
if (canReceiveCounters(counterType)) {
|
||||||
@@ -1124,7 +1125,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addAmount <= 0) {
|
if (addAmount <= 0) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
setTotalCountersToAdd(addAmount);
|
setTotalCountersToAdd(addAmount);
|
||||||
|
|
||||||
@@ -1170,6 +1171,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
getController().addCounterToPermThisTurn(counterType, addAmount);
|
getController().addCounterToPermThisTurn(counterType, addAmount);
|
||||||
view.updateCounters(this);
|
view.updateCounters(this);
|
||||||
}
|
}
|
||||||
|
return addAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5091,7 +5093,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInZone(final ZoneType zone) {
|
public boolean isInZone(final ZoneType zone) {
|
||||||
Zone z = getZone();
|
Zone z = this.getLastKnownZone();
|
||||||
return z != null && z.is(zone);
|
return z != null && z.is(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5791,10 +5793,24 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
etbCounters.clear();
|
etbCounters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void putEtbCounters() {
|
public final Set<Table.Cell<Player, CounterType, Integer>> getEtbCounters() {
|
||||||
|
return etbCounters.cellSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean putEtbCounters() {
|
||||||
|
boolean changed = false;
|
||||||
for (Table.Cell<Player, CounterType, Integer> e : etbCounters.cellSet()) {
|
for (Table.Cell<Player, CounterType, Integer> e : etbCounters.cellSet()) {
|
||||||
this.addCounter(e.getColumnKey(), e.getValue(), e.getRowKey(), true);
|
CounterType ct = e.getColumnKey();
|
||||||
|
if (this.isLKI()) {
|
||||||
|
if (canReceiveCounters(ct)) {
|
||||||
|
setCounters(ct, getCounters(ct) + e.getValue());
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
changed |= addCounter(ct, e.getValue(), e.getRowKey(), true) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void clearTemporaryVars() {
|
public final void clearTemporaryVars() {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
|
||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
@@ -270,6 +271,10 @@ public final class CardUtil {
|
|||||||
newCopy.addImprintedCard(o);
|
newCopy.addImprintedCard(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(Table.Cell<Player, CounterType, Integer> cl : in.getEtbCounters()) {
|
||||||
|
newCopy.addEtbCounter(cl.getColumnKey(), cl.getValue(), cl.getRowKey());
|
||||||
|
}
|
||||||
|
|
||||||
newCopy.setUnearthed(in.isUnearthed());
|
newCopy.setUnearthed(in.isUnearthed());
|
||||||
|
|
||||||
newCopy.setChangedCardColors(in.getChangedCardColors());
|
newCopy.setChangedCardColors(in.getChangedCardColors());
|
||||||
|
|||||||
@@ -876,20 +876,20 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
public final int addCounter(final CounterType counterType, final int n, final Player source, final boolean applyMultiplier) {
|
||||||
addCounter(counterType, n, source, applyMultiplier, true);
|
return addCounter(counterType, n, source, applyMultiplier, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCounter(CounterType counterType, int n, final Player source, boolean applyMultiplier, boolean fireEvents) {
|
public int addCounter(CounterType counterType, int n, final Player source, boolean applyMultiplier, boolean fireEvents) {
|
||||||
if (!canReceiveCounters(counterType)) {
|
if (!canReceiveCounters(counterType)) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addAmount = n;
|
int addAmount = n;
|
||||||
if(addAmount <= 0) {
|
if(addAmount <= 0) {
|
||||||
// Can't add negative or 0 counters, bail out now
|
// Can't add negative or 0 counters, bail out now
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Object> repParams = Maps.newHashMap();
|
final Map<String, Object> repParams = Maps.newHashMap();
|
||||||
@@ -908,7 +908,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int oldValue = getCounters(counterType);
|
final int oldValue = getCounters(counterType);
|
||||||
@@ -925,6 +925,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
if (addAmount > 0) {
|
if (addAmount > 0) {
|
||||||
getGame().getTriggerHandler().runTrigger(TriggerType.CounterAddedOnce, runParams, false);
|
getGame().getTriggerHandler().runTrigger(TriggerType.CounterAddedOnce, runParams, false);
|
||||||
}
|
}
|
||||||
|
return addAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user