@java.lang.Override public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { // create cost for sacrificing an artifact Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); // if they can pay the cost, then they must pay if (target.canChoose(source.getSourceId(), controller.getId(), game)) { controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game); Permanent artifactSacrifice = game.getPermanent(target.getFirstTarget()); if (artifactSacrifice != null) { // sacrifice the chosen artifact artifactSacrifice.sacrifice(source.getSourceId(), game); } } else { sourceObject.tap(game); controller.damage(4, source.getSourceId(), game, false, true); } } return true; } return false; }
@Override public void assignDamage( int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) { int remainingDamage = damage; UUID targetId; int amount; while (remainingDamage > 0) { if (targets.size() == 1) { targetId = targets.get(0); amount = remainingDamage; } else { targetId = targets.get(rnd.nextInt(targets.size())); amount = rnd.nextInt(damage + 1); } Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanent.damage(amount, sourceId, game, true, false); remainingDamage -= amount; } else { Player player = game.getPlayer(targetId); if (player != null) { player.damage(amount, sourceId, game, false, true); remainingDamage -= amount; } } targets.remove(targetId); } }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent == null) { sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); } if (sourcePermanent == null) { return false; } int damage = sourcePermanent.getPower().getValue(); Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { permanent.damage(damage, sourcePermanent.getId(), game, false, true); return true; } Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { player.damage(damage, sourcePermanent.getId(), game, false, true); 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.isInGame()) { player.damage((Integer) this.getValue("damageAmount"), source.getId(), game, false, true); } return true; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.damage(2, source.getSourceId(), game, false, true); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player controllerPlayer = game.getPlayer(source.getControllerId()); if (targetPlayer != null && controllerPlayer != null) { targetPlayer.damage(1, source.getSourceId(), game, false, true); controllerPlayer.gainLife(1, game); } return false; }
@Override public boolean apply(Game game, Ability source) { boolean isMountain = false; Card sourceCard = game.getCard(source.getSourceId()); Player player = game.getPlayer(source.getControllerId()); if (player == null || sourceCard == null) { return false; } Cards cards = new CardsImpl(Zone.PICK); while (player.getLibrary().size() > 0) { Card card = player.getLibrary().removeFromTop(game); if (card != null) { cards.add(card); if (card.getCardType().contains(CardType.LAND)) { if (card.getSubtype().contains("Mountain")) { isMountain = true; } break; } } else { break; } } player.revealCards(sourceCard.getName(), cards, game); int damage = cards.size(); if (isMountain == true) { damage *= 2; } Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { permanent.damage(damage, source.getSourceId(), game, true, false); } else { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); if (targetPlayer != null) { targetPlayer.damage(damage, source.getSourceId(), game, false, true); } } TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); target.setRequired(true); while (cards.size() > 1) { player.choose(Outcome.Neutral, cards, target, game); Card card = cards.get(target.getFirstTarget(), game); if (card != null) { cards.remove(card); card.moveToZone(Zone.PICK, source.getId(), game, false); } target.clearChosen(); } return true; }
private void defenderDamage(Permanent attacker, int amount, Game game) { if (this.defenderIsPlaneswalker) { Permanent defender = game.getPermanent(defenderId); if (defender != null) { defender.markDamage(amount, attacker.getId(), game, true, true); } } else { Player defender = game.getPlayer(defenderId); defender.damage(amount, attacker.getId(), game, true, true); } }
@Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (opponent != null) { int xValue = opponent.getHand().size() - 4; if (xValue > 0) { opponent.damage(xValue, source.getSourceId(), game, false, true); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { permanent.damage(4, source.getSourceId(), game, true, false); player.damage(2, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent targetedLand = game.getPermanent(source.getFirstTarget()); if (targetedLand != null) { targetedLand.destroy(source.getSourceId(), game, true); Player controller = game.getPlayer(targetedLand.getControllerId()); if (controller != null) { controller.damage(2, source.getSourceId(), game, false, true); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD); if (permanent != null && !permanent.getSupertype().contains("Basic")) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { player.damage(2, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (opponent != null && controller != null) { int amount = controller.getHand().size() - opponent.getHand().size(); if (amount > 0) { opponent.damage(amount, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { int amount = permanent.getPower().getValue(); controller.damage(amount, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { for (UUID permanentId : game.getBattlefield().getAllPermanentIds()) { Permanent p = game.getPermanent(permanentId); if (p != null && p.getCardType().contains(CardType.CREATURE)) { p.damage(1, source.getSourceId(), game, false, true); } } for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player p = game.getPlayer(playerId); if (p != null) { p.damage(1, source.getSourceId(), game, false, true); } } return true; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { int damage = source.getManaCostsToPay().getX(); if (damage > 0) { player.damage(damage, source.getSourceId(), game, false, true); for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(damage, source.getSourceId(), game, false, true); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { for (UUID target : targetPointer.getTargets(game, source)) { Permanent creature = game.getPermanent(target); if (creature != null) { creature.damage(1, attachmentid, game, false, true); } Player player = game.getPlayer(target); if (player != null) { player.damage(1, attachmentid, game, false, true); } } Permanent razor = game.getPermanent(attachmentid); if (razor != null) { razor.moveToZone(Zone.HAND, id, game, true); } return true; }
@Override public boolean apply(Game game, Ability source) { Card card = (Card) this.getValue("discardedCard"); if (card != null && card.getColor(game).isRed()) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { permanent.damage(4, source.getSourceId(), game, false, true); return true; } Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { player.damage(4, source.getSourceId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null && player.getLibrary().size() > 0) { Card card = player.getLibrary().getFromTop(game); Cards cards = new CardsImpl(); cards.add(card); player.revealCards("Cerebral Eruption", cards, game); game.getState().setValue(source.getId().toString(), card); int damage = card.getManaCost().convertedManaCost(); player.damage(damage, source.getId(), game, false, true); for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { perm.damage(damage, source.getId(), game, true, false); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Cost cost = new GenericManaCost(1); cost.clearPaid(); if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { permanent.damage(1, source.getId(), game, true, false); return true; } Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { player.damage(1, source.getSourceId(), game, false, true); return true; } return false; } return false; }
@Override public boolean apply(Game game, Ability source) { if (source.getTargets().size() > 0) { Target multiTarget = source.getTargets().get(0); for (UUID target : multiTarget.getTargets()) { Permanent permanent = game.getPermanent(target); if (permanent != null) { permanent.damage( multiTarget.getTargetAmount(target), source.getSourceId(), game, true, false); } else { Player player = game.getPlayer(target); if (player != null) { player.damage( multiTarget.getTargetAmount(target), source.getSourceId(), game, false, true); } } } } return true; }
@Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer == null) { return false; } targetPlayer.damage( amount.calculate(game, source, this), source.getSourceId(), game, false, true); FilterPermanent filter = new FilterPermanent("and each creature he or she controls"); filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new ControllerIdPredicate(targetPlayer.getId())); List<Permanent> permanents = game.getBattlefield() .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); for (Permanent permanent : permanents) { permanent.damage( amount.calculate(game, source, this), source.getSourceId(), game, false, true); } return true; }
@Override public boolean apply(Game game, Ability source) { // get the number of removed counters as damage amount HankyuCountersSourceCost cost = (HankyuCountersSourceCost) source.getCosts().get(1); if (cost != null) { int damageAmount = cost.getRemovedCounters(); if (damageAmount > 0) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { permanent.damage(damageAmount, source.getSourceId(), game, true, false); } Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { player.damage(damageAmount, source.getSourceId(), game, false, true); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int count = game.getBattlefield().countAll(filter, playerId, game); if (count > 0) { player.damage(count, source.getSourceId(), game, false, true); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { permanent.damage(count, source.getSourceId(), game, false, true); } } } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get("DragonOnTheBattlefieldWhileSpellWasCastWatcher"); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { player.damage(3, source.getSourceId(), game, false, true); } } } return true; } return false; }