private static boolean hasReach(Permanent permanent) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof ReachAbility) { return true; } } return false; }
private static boolean cantBeBlocked(Permanent permanent) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof CantBeBlockedSourceAbility) { return true; } } return false; }
/** * We need this to check Flying existence in not-common way: by instanceof. * @return */ private static boolean hasFlying(Permanent permanent) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof FlyingAbility) { return true; } } return false; }
public List<Permanent> getPhasedIn(UUID controllerId) { return field.values() .stream() .filter(perm -> perm.getAbilities().containsKey(PhasingAbility.getInstance().getId()) && perm.isPhasedIn() && perm.isControlledBy(controllerId)) .collect(Collectors.toList()); }
@Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { // 112.10 while (permanent.getAbilities().remove(ability)) { } } return true; } }
@Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { if (blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId())) { return true; } return false; }
private static boolean canTap(Permanent permanent) { return !permanent.isTapped() && (!permanent.hasSummoningSickness() || !permanent.getCardType().contains(CardType.CREATURE) || permanent.getAbilities().contains(HasteAbility.getInstance())); }
private static int sumPoisonDamage(List<Permanent> attackersThatWontBeBlocked, Player defender) { int damage = 0; for (Permanent attacker : attackersThatWontBeBlocked) { if (attacker.getAbilities().contains(InfectAbility.getInstance())) { damage += attacker.getPower().getValue(); if (attacker.getAbilities().contains(DoubleStrikeAbility.getInstance())) { damage += attacker.getPower().getValue(); } } } return damage; }
private static int sumDamage(List<Permanent> attackersThatWontBeBlocked, Player defender) { int damage = 0; for (Permanent attacker : attackersThatWontBeBlocked) { if (!attacker.getAbilities().contains(InfectAbility.getInstance())) { damage += attacker.getPower().getValue(); if (attacker.getAbilities().contains(DoubleStrikeAbility.getInstance())) { damage += attacker.getPower().getValue(); } } } return damage; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(getSourceId()); if(permanent != null && permanent.getAbilities().contains(FlyingAbility.getInstance())){ return true; } return false; }
public CreatureSimulator(Permanent permanent) { this.id = permanent.getId(); this.damage = permanent.getDamage(); this.power = permanent.getPower().getValue(); this.toughness = permanent.getToughness().getValue(); this.hasDoubleStrike = permanent.getAbilities().containsKey(DoubleStrikeAbility.getInstance().getId()); this.hasFirstStrike = permanent.getAbilities().containsKey(FirstStrikeAbility.getInstance().getId()); this.hasTrample = permanent.getAbilities().containsKey(TrampleAbility.getInstance().getId()); }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { Ability ability = new PutCardIntoGraveFromAnywhereAllTriggeredAbility( new LazavDimirMastermindEffect(), true, new FilterCreatureCard("a creature card"), TargetController.OPPONENT, SetTargetPointer.CARD); permanent.getAbilities().add(ability); permanent.setName("Lazav, Dimir Mastermind"); permanent.addSuperType(SuperType.LEGENDARY); permanent.getAbilities().add(HexproofAbility.getInstance()); return true; }
@Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { return blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId()) || (null != game.getContinuousEffects().asThough(blocker.getId(), AsThoughEffectType.BLOCK_DRAGON, source, blocker.getControllerId(), game) && attacker.hasSubtype(SubType.DRAGON, game)); }
@Override public boolean apply(Game game, Ability source) { Set<UUID> opponents = game.getOpponents(source.getControllerId()); for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (opponents.contains(perm.getControllerId())) { perm.getAbilities().remove(InfectAbility.getInstance()); } } return true; }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { DynamicValue variableMana = ManacostVariableValue.instance; Effect effect = new SetPowerToughnessSourceEffect(variableMana, Duration.WhileOnBattlefield, SubLayer.SetPT_7b); effect.setText("This creature has base power and toughness X/X"); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}")); permanent.getAbilities().add(ability); return true; }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { permanent.getColor(game).setColor(sourcePermanent.getColor(game)); permanent.getAbilities().add(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new VesuvanDoppelgangerCopyEffect(), TargetController.YOU, true, false, rule2)); return true; }
@Override public boolean checkTrigger(GameEvent event, Game game){ Permanent creature = game.getPermanent(event.getSourceId()); if (creature != null && filter.match(creature, game) && game.getOpponents(this.getControllerId()).contains(creature.getControllerId()) && game.getPermanent(this.getSourceId()).getAbilities().contains(DefenderAbility.getInstance())) { return true; } return false; }
@Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sourceCreature != null && sourceCreature.isAttacking()) { return permanent.getAbilities().contains(FlyingAbility.getInstance()) && permanent.canBlock(source.getSourceId(), game); } return false; }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { Effect effect = new VesuvanShapeshifterFaceDownEffect(); Ability ability = new BeginningOfUpkeepTriggeredAbility(effect, TargetController.YOU, true); permanent.getAbilities().add(ability); // Why is this needed? permanent.addAbility(new MorphAbility(permanent, new ManaCostsImpl("{1}{U}")), permanent.getId(), game); 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(); }