Refactor addCounters to fix bugs in edge cases. (#5154)

Add code to check the controller of abilities on the stack instead of the controller of their source card or object.

This fixes https://github.com/magefree/mage/issues/5152
This commit is contained in:
Samuel Sandeen 2018-07-29 07:31:59 -04:00 committed by GitHub
parent 3278139da3
commit 3875f42bac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 1 deletions

View file

@ -779,7 +779,15 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@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());
UUID sourceId = getId();
if (source != null) {
MageObject object = game.getObject(source.getId());
if (object instanceof StackObject) {
sourceId = source.getId();
} else {
sourceId = source.getSourceId();
}
}
GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, sourceId, getControllerOrOwner(), counter.getName(), counter.getCount());
countersEvent.setAppliedEffects(appliedEffects);
countersEvent.setFlag(isEffect);