@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for (Cost cost : sourceAbility.getCosts()) { if (cost instanceof SacrificeTargetCost) { SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost; return sacrificeCost.getPermanents() .stream().mapToInt(p -> p.getPower().getValue()).sum(); } } return 0; }
@Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { int sumPower = 0; for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controllerId, game)) { if (!permanent.getId().equals(sourceId)) { sumPower += permanent.getPower().getValue(); } } return sumPower >= 10; }
@Override public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null && attacker.isControlledBy(sourcePermanent.getControllerId())) { return blocker.getPower().getValue() >= sourcePermanent.getPower().getValue(); } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent creature = (Permanent) getValue("attachedTo"); if (controller != null && creature != null) { controller.gainLife(creature.getToughness().getValue(), game, source); controller.drawCards(creature.getToughness().getValue(), game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { MageObject sourceObject = source.getSourceObject(game); if (sourceObject != null) { if (sourceObject.getPower().getValue() >= 10) { game.addEffect(new GainAbilitySourceEffect(TrampleAbility.getInstance(), Duration.EndOfTurn), source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); if (creature == null) { return false; } return new GainLifeEffect(creature.getToughness().getValue()).apply(game, source); } }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { Permanent sourcePermanent = game.getPermanent(sourceAbility.getFirstTarget()); if (sourcePermanent == null) { sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getFirstTarget(), Zone.BATTLEFIELD); } if (sourcePermanent != null) { return sourcePermanent.getPower().getValue(); } return 0; }
@Override public boolean apply(Game game, Ability source) { int maxPower = 0; for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { maxPower = Math.max(maxPower, creature.getPower().getValue()); } game.addEffect(new BoostSourceEffect(maxPower, 0, Duration.EndOfTurn), source); return true; } }
@Override public boolean apply(Game game, Ability source) { Permanent perm = game.getPermanent(source.getSourceId()); GainLifeEffect lifeEffect = new GainLifeEffect(perm.getPower().getValue()); return lifeEffect.apply(game, source); } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null) { Player you = game.getPlayer(source.getControllerId()); if (you != null) { you.discard(permanent.getToughness().getValue(), false, source, game); } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent == null) { return false; } return permanent.damage(permanent.getPower().getValue(), permanent.getId(), game, false, true) > 0; } }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); Player player = game.getPlayer(source.getControllerId()); if (target != null && player != null) { player.gainLife(target.getPower().getValue(), game, source); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); Player player = game.getPlayer(source.getControllerId()); if (player != null && target != null) { player.drawCards(target.getPower().getValue(), game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent perm = game.getPermanent(source.getSourceId()); int damage = CardUtil.addWithOverflowCheck(perm.getPower().getValue(), 2); DamageTargetEffect dmgEffect = new DamageTargetEffect(damage); return dmgEffect.apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { Card targetCreatureCard = game.getCard(source.getFirstTarget()); if (targetCreatureCard != null) { targetCreatureCard.moveToExile(null, null, source.getSourceId(), game); int toughness = targetCreatureCard.getToughness().getValue(); SaprolingToken token = new SaprolingToken(); return token.putOntoBattlefield(toughness, game, source.getSourceId(), source.getControllerId()); } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent meglonoth = game.getPermanent(source.getSourceId()); Permanent blocked = game.getPermanent(targetPointer.getFirst(game, source)); if (blocked != null && meglonoth != null) { game.getPlayer(blocked.getControllerId()).damage(meglonoth.getPower().getValue(), source.getSourceId(), game, false, true); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { FilterPermanent filter = new FilterPermanent(); filter.add(new CardTypePredicate(CardType.CREATURE)); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { int amount = permanent.getPower().getValue(); permanent.damage(amount, permanent.getId(), game, false, true); } return true; }