mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Fixed counter replacement effects with Doubling Season and Pir, Imaginative Rascal
This commit is contained in:
parent
52243eb75c
commit
e1aa40cbf7
6 changed files with 30 additions and 12 deletions
|
|
@ -64,17 +64,19 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gatherer Ruling:
|
||||
* 10/1/2005: Planeswalkers will enter the battlefield with double the normal amount of loyalty counters. However,
|
||||
* if you activate an ability whose cost has you put loyalty counters on a planeswalker, the number you put on isn’t doubled.
|
||||
* This is because those counters are put on as a cost, not as an effect.
|
||||
**/
|
||||
* Gatherer Ruling: 10/1/2005: Planeswalkers will enter the battlefield with
|
||||
* double the normal amount of loyalty counters. However, if you activate an
|
||||
* ability whose cost has you put loyalty counters on a planeswalker, the
|
||||
* number you put on isn’t doubled. This is because those counters are put
|
||||
* on as a cost, not as an effect.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
if (planeswalker != null && planeswalker.getCounters(game).getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
|
||||
if (amount > 0) {
|
||||
planeswalker.getCounters(game).addCounter(CounterType.LOYALTY.createInstance(amount));
|
||||
planeswalker.addCounters(CounterType.LOYALTY.createInstance(amount), ability, game, false);
|
||||
} else if (amount < 0) {
|
||||
planeswalker.removeCounters(CounterType.LOYALTY.getName(), Math.abs(amount), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class PutCountersSourceCost extends CostImpl {
|
|||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null) {
|
||||
this.paid = permanent.addCounters(counter, ability, game);
|
||||
this.paid = permanent.addCounters(counter, ability, game, false);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,8 +161,12 @@ public interface Card extends MageObject {
|
|||
|
||||
boolean addCounters(Counter counter, Ability source, Game game);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect);
|
||||
|
||||
void removeCounters(String name, int amount, Game game);
|
||||
|
||||
void removeCounters(Counter counter, Game game);
|
||||
|
|
|
|||
|
|
@ -789,15 +789,26 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game) {
|
||||
return addCounters(counter, source, game, null);
|
||||
return addCounters(counter, source, game, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect) {
|
||||
return addCounters(counter, source, game, null, isEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
return addCounters(counter, source, game, appliedEffects, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
boolean returnCode = true;
|
||||
UUID sourceId = (source == null ? getId() : source.getSourceId());
|
||||
GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, sourceId, getControllerOrOwner(), counter.getName(), counter.getCount());
|
||||
countersEvent.setAppliedEffects(appliedEffects);
|
||||
countersEvent.setFlag(isEffect);
|
||||
if (!game.replaceEvent(countersEvent)) {
|
||||
int amount = countersEvent.getAmount();
|
||||
int finalAmount = amount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue