@Override public boolean applies(GameEvent event, Ability source, Game game) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null && player.getId().equals(event.getPlayerId())) { Card card = game.getCard(event.getSourceId()); if (card != null && !card.isCreature()) { return true; } } return false; } }
protected void logLife(Game game) { StringBuilder sb = new StringBuilder(); sb.append(game.getTurn().getValue(game.getTurnNum())); for (Player player: game.getPlayers().values()) { sb.append("[player ").append(player.getName()).append(':').append(player.getLife()).append(']'); } logger.info(sb.toString()); }
@Override public boolean applies(GameEvent event, Ability source, Game game) { String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { MageObject object = game.getObject(event.getSourceId()); if (object != null && object.getName().equals(cardName)) { return true; } } return false; } }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { Card card = game.getCard(objectId); if (card != null && affectedControllerId.equals(card.getOwnerId()) && game.getState().getZone(card.getId()) == Zone.EXILED) { return true; } return false; } }
private List<Permanent> getAttackers(Game game) { List<UUID> attackersUUID = game.getCombat().getAttackers(); if (attackersUUID.isEmpty()) { return null; } List<Permanent> attackers = new ArrayList<>(); for (UUID attackerId : attackersUUID) { Permanent permanent = game.getPermanent(attackerId); attackers.add(permanent); } return attackers; }
@Override public boolean canTarget(UUID id, Ability source, Game game) { Permanent permanent = game.getPermanent(id); if (permanent != null) { return filter.match(permanent, game); } Card card = game.getCard(id); return card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD && filter.match(card, game); }
@Override public boolean apply(Game game, Ability source) { UUID chosenOpponent = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY); FilterPermanent filter = new FilterPermanent(); filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color"))); filter.add(Predicates.not(TokenPredicate.instance)); return game.getBattlefield().countAll(filter, chosenOpponent, game) > 0; } }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { if (game.getPermanent(sourceAbility.getSourceId()) == null) { return 1; } Object obj = game.getState().getValue(sourceAbility.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY); if (!(obj instanceof UUID)) { return 1; } return 1 + game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, (UUID) obj, game).size(); }
@Override public boolean checkTrigger(GameEvent event, Game game) { DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; if (damageEvent.isCombatDamage()) { Permanent permanent = game.getPermanent(event.getSourceId()); if (damageEvent.getPlayerId().equals(getControllerId()) && permanent != null && permanent.isCreature()) { game.getState().setValue(getSourceId().toString(), permanent.getControllerId()); return true; } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { CardType cardType = ArchonOfValorsReachChoice.getType((String) game.getState().getValue(source.getSourceId().toString() + "_cardtype")); // spell is not on the stack yet, so we have to check the card Card card = game.getCard(event.getSourceId()); return cardType != null && card != null && card.getCardType().contains(cardType); }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Choice choice = new ChoiceBasicLandType(); if (player != null && player.choose(Outcome.Neutral, choice, game)) { game.getState().setValue(source.getSourceId().toString() + "_ElsewhereFlask", choice.getChoice()); game.addEffect(new ElsewhereFlaskContinuousEffect(), source); return true; } return false; } }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if ((abilityToModify instanceof SpellAbility) && abilityToModify.isControlledBy(source.getControllerId())) { Card card = game.getCard(abilityToModify.getSourceId()); if (card != null) { String needName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); return CardUtil.haveSameNames(card.getName(), needName); } } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility && abilityToModify.isControlledBy(source.getControllerId())) { Spell spell = game.getStack().getSpell(abilityToModify.getSourceId()); if (spell != null && spell.getCardType().toString().contains((String) game.getState().getValue(source.getSourceId().toString() + "_CloudKey"))) { return true; } } return false; } }
@Override public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { if (!(excludeSource && perm.getId().equals(source.getSourceId()))) { affectedObjectList.add(new MageObjectReference(perm, game)); } } } }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent land = game.getPermanent(event.getTargetId()); return land.getControllerId().equals(controllerId); }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId.equals(source.getSourceId())) { Card card = game.getCard(source.getSourceId()); if (card != null && card.isOwnedBy(affectedControllerId) && game.getState().getZone(source.getSourceId()) == Zone.EXILED) { return true; } } return false; } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null && sourcePermanent.isAttacking()) { return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game)); } return false; } }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (getSourceId().equals(event.getTargetId())) { StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); if (stackObject != null) { return game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId()); } } return false; }