private static LinkedHashMap<UUID, ActivatedManaAbilityImpl> replace(LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities, ActivatedManaAbilityImpl chosenManaAbility) { // modify the map with the chosen mana ability useableAbilities.clear(); useableAbilities.put(chosenManaAbility.getId(), chosenManaAbility); return useableAbilities; }
protected LinkedHashMap<UUID, ActivatedManaAbilityImpl> getUseableManaAbilities(MageObject object, Zone zone, Game game) { LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>(); boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game); for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) { if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) { if (ability.canActivate(playerId, game).canActivate()) { useable.put(ability.getId(), ability); } } } return useable; }
protected boolean playManaAbility(ActivatedManaAbilityImpl ability, Game game) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getId(), ability.getSourceId(), playerId))) { int bookmark = game.bookmarkState(); if (ability.activate(game, false)) { if (ability.resolve(game)) { if (ability.isUndoPossible()) { if (storedBookmark == -1 || storedBookmark > bookmark) { // e.g. useful for undo Nykthos, Shrine to Nyx setStoredBookmark(bookmark); } } else { resetStoredBookmark(game); } return true; } } restoreState(bookmark, ability.getRule(), game); } return false; }