* Gain abilities - fixed that objects can get only one instance of triggered ability instead multiple (example: 2+ cascades from copies of Imoti, Celebrant of Bounty, f52753ad61);

This commit is contained in:
Oleg Agafonov 2021-03-05 16:22:46 +04:00
parent 4e79c83784
commit 712cf4576d
8 changed files with 97 additions and 14 deletions

View file

@ -11,6 +11,7 @@ import mage.game.events.GameEvent;
import mage.game.events.NumberOfTriggersEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import org.apache.log4j.Logger;
/**
* @author BetaSteward_at_googlemail.com
@ -21,6 +22,8 @@ import mage.game.stack.Spell;
*/
public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbility> {
private static final Logger logger = Logger.getLogger(TriggeredAbilities.class);
private final Map<String, List<UUID>> sources = new HashMap<>();
public TriggeredAbilities() {
@ -115,7 +118,7 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
this.add(ability, attachedTo);
List<UUID> uuidList = new LinkedList<>();
uuidList.add(sourceId);
// if the object that gained the ability moves zone, also then the triggered ability must be removed
// if the object that gained the ability moves from zone then the triggered ability must be removed
uuidList.add(attachedTo.getId());
sources.put(getKey(ability, attachedTo), uuidList);
}