mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
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:
parent
3278139da3
commit
3875f42bac
2 changed files with 65 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue