@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 2)); return false; }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { SpellAbility spellAbility = (SpellAbility) abilityToModify; CardUtil.adjustCost(spellAbility, -2); return true; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { Card card = player.getLibrary().getFromTop(game); if (card != null) { player.moveCardsToExile(card, source, game, true, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, null)); return true; } } return false; }
public static UUID getExileZoneId(Game game, UUID objectId, int zoneChangeCounter) { return getExileZoneId(getObjectZoneString(SOURCE_EXILE_ZONE_TEXT, objectId, game, zoneChangeCounter, false), game); }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { if (abilityToModify.getAbilityType() == AbilityType.SPELL) { SpellAbility spellAbility = (SpellAbility) abilityToModify; CardUtil.adjustCost(spellAbility, -1); } if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED) { CardUtil.increaseCost(abilityToModify, 1); } return true; }
@Override public void init(Ability source, Game game) { super.init(source, game); for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanent.addInfo("kioraPrevention" + getId(), CardUtil.addToolTipMarkTags("All damage that would be dealt to and dealt by this permanent is prevented."), game); } } }
/** * Checks if the current object with sourceId has damaged the player during the current turn. * The zoneChangeCounter will be taken into account. * * @param sourceId * @param game * @return */ public boolean hasSourceDoneDamage(UUID sourceId, Game game) { return damageSourceIds.contains(CardUtil.getCardZoneString(null, sourceId, game)); }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game); // If Banisher Priest leaves the battlefield before its triggered ability resolves, // the target creature won't be exiled. if (permanent != null) { return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), permanent.getIdName()).apply(game, source); } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent == null) { return false; } if (!permanent.getImprinted().isEmpty()) { Card card = game.getCard(permanent.getImprinted().get(0)); if (card != null) { EmptyToken token = new EmptyToken(); CardUtil.copyTo(token).from(card); token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); return true; } } return false; }
@Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { Card sourceCard = game.getCard(sourceId); if (sourceCard != null) { UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); ExileZone exile = game.getExile().getExileZone(exileId); if (exile != null && !exile.isEmpty()) { return true; } } return false; }
/** * Face down cards and their copy tokens don't have names and that's "empty" names is not equals */ public static boolean haveSameNames(String name1, String name2, Boolean ignoreMtgRuleForEmptyNames) { if (ignoreMtgRuleForEmptyNames) { // simple compare for tests and engine return name1 != null && name2 != null && name1.equals(name2); } else { // mtg logic compare for game (empty names can't be same) return !haveEmptyName(name1) && !haveEmptyName(name2) && name1.equals(name2); } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (controller != null && permanent != null) { permanent.destroy(source.getSourceId(), game, false); if (!CardUtil.haveEmptyName(permanent)) { // in case of face down enchantment creature for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { if (!perm.getId().equals(permanent.getId()) && CardUtil.haveSameNames(perm, permanent) && perm.isEnchantment()) { perm.destroy(source.getSourceId(), game, false); } } } return true; } return false; } }
@Override public void lookAtCards(Ability source, String titleSuffix, Cards cards, Game game) { game.getState().getLookedAt(this.playerId).add(CardUtil.createObjectRealtedWindowTitle(source, game, titleSuffix), cards); game.fireUpdatePlayersEvent(); }
CreateTokenEffect effect = new CreateTokenEffect(new TetraviteToken(), countersToRemove); effect.apply(game, source); Object object = game.getState().getValue(CardUtil.getObjectZoneString("_tokensCreated", permanent, game)); Set<UUID> tokensCreated; if (object != null) { game.getState().setValue(CardUtil.getCardZoneString("_tokensCreated", source.getSourceId(), game), tokensCreated);
public static String getCardZoneString(String text, UUID cardId, Game game, boolean previous) { int zoneChangeCounter = 0; Card card = game.getCard(cardId); // if called for a token, the id is enough if (card != null) { zoneChangeCounter = card.getZoneChangeCounter(game); } return getObjectZoneString(text, cardId, game, zoneChangeCounter, previous); }
if (sourceObject != null && controller != null) { Map<String, UUID> exileIds; String valueKey = CardUtil.getObjectZoneString("exileIds", sourceObject, game); Object object = game.getState().getValue(valueKey); if (object instanceof Map) { if (player.getLibrary().hasCards()) { Card card = player.getLibrary().getFromTop(game); String exileKey = playerId.toString() + CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()).toString(); UUID exileId = exileIds.computeIfAbsent(exileKey, k -> UUID.randomUUID()); player.moveCardsToExile(card, source, game, false, exileId, sourceObject.getIdName() + " (" + player.getName() + ')');
@Override public void init(Ability source, Game game) { super.init(source, game); for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanent.addInfo("detain" + getId(), CardUtil.addToolTipMarkTags("Detained"), game); } } }
protected void setActivationInfo(ActivationInfo activationInfo, Game game) { game.getState().setValue(CardUtil .getCardZoneString("activationsTurn" + originalId, sourceId, game), activationInfo.turnNum); game.getState().setValue(CardUtil .getCardZoneString("activationsCount" + originalId, sourceId, game), activationInfo.activationCounter); } }
@Override public boolean apply(Game game, Ability source) { MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null) { return new ExileTargetEffect(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), sourceObject.getIdName()).apply(game, source); } return false; } }
@Override public boolean apply(Game game, Ability source) { int value = source.getManaCostsToPay().getX(); // should this be random across card names, or card printings? CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value); List<CardInfo> options = CardRepository.instance.findCards(criteria); if (options == null || options.isEmpty()) { game.informPlayers("No random creature card with converted mana cost of " + value + " was found."); return false; } EmptyToken token = new EmptyToken(); // search for a non custom set creature while (!options.isEmpty()) { int index = RandomUtil.nextInt(options.size()); ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode()); if (expansionSet == null || expansionSet.getSetType() == SetType.CUSTOM_SET) { options.remove(index); } else { Card card = options.get(index).getCard(); if (card != null) { CardUtil.copyTo(token).from(card); break; } else { options.remove(index); } } } token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false); return true; } }