@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { UUID playerThatChoseId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OWNER); if (playerThatChoseId == null || !playerThatChoseId.equals(controllerId)) { return false; } UUID opponentId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OPPONENT); return opponentId != null; }
public int getDevouredCreaturesAmount(Game game, UUID permanentId) { Object object = game.getState().getValue(permanentId.toString() + "devoured"); if (object != null) { return ((List<ArrayList<String>>) object).size(); } return 0; }
public static UUID getSuspendExileId(UUID controllerId, Game game) { UUID exileId = (UUID) game.getState().getValue("SuspendExileId" + controllerId.toString()); if (exileId == null) { exileId = UUID.randomUUID(); game.getState().setValue("SuspendExileId" + controllerId.toString(), exileId); } return exileId; }
@Override protected int getInputValue(Game game, Ability source) { Object object = game.getState().getValue("buzz" + source.getSourceId()); if (object instanceof Boolean && (Boolean) object) { return 1; } return 0; }
private void resetConspire(Ability ability, Game game) { Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId()); if (activations != null) { activations.remove(getConspireId()); } }
public static UUID getExileZoneId(String key, Game game) { UUID exileId = (UUID) game.getState().getValue(key); if (exileId == null) { exileId = UUID.randomUUID(); game.getState().setValue(key, exileId); } return exileId; }
protected ActivationInfo getActivationInfo(Game game) { Integer turnNum = (Integer) game.getState() .getValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game)); Integer activationCount = (Integer) game.getState() .getValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game)); if (turnNum == null || activationCount == null) { return null; } return new ActivationInfo(turnNum, activationCount); }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (((ZoneChangeEvent) event).isDiesEvent()) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; Object object = game.getState().getValue(getSourceId().toString() + "returnedCreature"); if ((object instanceof MageObjectReference) && ((MageObjectReference) object).refersTo(zEvent.getTarget(), game)) { return true; } } return false; }
@Override public Mana produceMana(boolean netMana, Game game, Ability source) { ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); if (color != null) { return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0))); } else { return null; } }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); UUID controllerId = (UUID) game.getState().getValue(source.getSourceId().toString()); if (permanent != null && controllerId != null) { return permanent.changeControllerId(controllerId, game); } return false; }
@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 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 boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null) { Integer castCount = (Integer) game.getState().getValue(permanent.getId() + "_castCount"); if (castCount != null && castCount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(castCount), source, game); } } return false; }
@Override public boolean apply(Game game, Ability source) { Object object = game.getState().getValue(source.getSourceId().toString() + "returnedCreature"); if ((object instanceof MageObjectReference)) { Effect effect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD); effect.setTargetPointer(new FixedTarget(((MageObjectReference) object).getSourceId())); effect.apply(game, source); } return false; } }
@Override public boolean checkTrigger(GameEvent event, Game game) { UUID playerId = (UUID) game.getState().getValue(getSourceId() + "_player"); if (playerId.equals(event.getPlayerId())) { this.getEffects().get(0).setTargetPointer(new FixedTarget(playerId)); return true; } return false; }
@Override public int calculate(Game game, Ability source, Effect effect) { Integer sweepNumber = (Integer) game.getState().getValue("sweep" + source.getSourceId() + game.getState().getZoneChangeCounter(source.getSourceId())); return sweepNumber != null ? sweepNumber : 0; }
@Override public boolean apply(Game game, Ability source) { Permanent imminentDoom = game.getPermanent(source.getSourceId()); if (imminentDoom != null) { Effect effect = new DamageTargetEffect((int) game.getState().getValue("ImminentDoomCount" + source.getSourceId().toString())); effect.apply(game, source); imminentDoom.addCounters(CounterType.DOOM.createInstance(), source, game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { UUID playerId = (UUID) game.getState().getValue(source.getSourceId() + "_player"); Player player = game.getPlayer(playerId); if (player != null && player.canRespond()) { player.damage((Integer) this.getValue("damageAmount"), source.getSourceId(), game, false, true); } return true; } }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); return chosenColor != null && !permanent.getAbilities().contains(FlyingAbility.getInstance()) && permanent.getColor(game).shares(chosenColor) && permanent.isCreature(); }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer((UUID) game.getState().getValue(source.getSourceId() + "_player")); if (player != null) { checkToFirePossibleEvents(getMana(game, source), game, source); player.getManaPool().addMana(getMana(game, source), game, source); return true; } return false; }