mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Stop permanents getting counters when phased out (#9194)
This commit is contained in:
parent
97fd9b6b6e
commit
b52576fcf9
2 changed files with 61 additions and 49 deletions
|
@ -69,12 +69,21 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (counter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (putOnCard) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
if (counter != null) {
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Counter newCounter = counter.copy();
|
||||
int countersToAdd = amount.calculate(game, source, this);
|
||||
if (countersToAdd > 0 && newCounter.getCount() == 1) {
|
||||
|
@ -89,18 +98,18 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
game.informPlayers(player.getLogName() + " puts " + newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counter on " + card.getLogName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
|
||||
permanent = game.getPermanentEntering(source.getSourceId());
|
||||
}
|
||||
if (permanent != null
|
||||
&& (source.getSourceObjectZoneChangeCounter() == 0 // from static ability
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((source.getSourceObjectZoneChangeCounter() == 0 // from static ability
|
||||
|| source.getSourceObjectZoneChangeCounter() == permanent.getZoneChangeCounter(game))) { // prevent to add counters to later source objects
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
int countersToAdd = amount.calculate(game, source, this);
|
||||
if (amount instanceof StaticValue || countersToAdd > 0) {
|
||||
|
@ -121,11 +130,8 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -699,6 +699,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect, int maxCounters) {
|
||||
if (this instanceof Permanent) {
|
||||
if (!((Permanent) this).isPhasedIn()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean returnCode = true;
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, source, playerAddingCounters, counter.getName(), counter.getCount());
|
||||
addingAllEvent.setAppliedEffects(appliedEffects);
|
||||
|
|
Loading…
Reference in a new issue