public void removeAbilitiesOfNonExistingSources(Game game) { // e.g. Token that had triggered abilities entrySet().removeIf(entry -> game.getObject(entry.getValue().getSourceId()) == null && game.getState().getDesignations().stream().noneMatch(designation -> designation.getId().equals(entry.getValue().getSourceId()))); }
return ability; MageObject object = game.getObject(ability.getSourceId()); String rule = ability.getRule(object != null ? object.getName() : null); if (triggerAutoOrderNameFirst.contains(rule)) { if (ability.getId().equals(response.getUUID()) || (!macroTriggeredSelectionFlag && ability.getSourceId().equals(response.getUUID()))) { if (recordingMacro) { PlayerResponse tResponse = new PlayerResponse(); tResponse.setUUID(ability.getSourceId()); actionQueueSaved.add(tResponse); logger.debug("Adding Triggered Ability Source: " + tResponse);
if (ability.getControllerId() == null) { String sourceName = "no sourceId"; if (ability.getSourceId() != null) { MageObject mageObject = getObject(ability.getSourceId()); if (mageObject != null) { sourceName = mageObject.getName(); manaAbiltiy.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId())); newAbility.newId(); if (newAbility.getSourceObjectZoneChangeCounter() == 0) { newAbility.setSourceObjectZoneChangeCounter(getState().getZoneChangeCounter(ability.getSourceId()));
private void checkTrigger(TriggeredAbility ability, GameEvent event, Game game) { MageObject object = game.getObject(ability.getSourceId()); if (ability.isInUseableZone(game, object, event)) { if (event == null || !game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) { && game.getLKI().get(Zone.BATTLEFIELD) != null && game.getLKI().get(Zone.BATTLEFIELD).containsKey(ability.getSourceId())) { Permanent permanent = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD, ability.getSourceObjectZoneChangeCounter() - 1); if (permanent != null) { if (permanent.isFaceDown(game) NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability.getControllerId(), ability.getSourceId(), event); if (!game.replaceEvent(numberOfTriggersEvent)) { for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
ability.resolve(game); } else { game.fireEvent(new GameEvent(EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
if (SagaAbility.isChapterAbility(trigger) && trigger.getSourceId().equals(perm.getId())) { noChapterAbilityTriggeredOrOnStack = false; break;