use of mage.abilities.Ability in project mage by magefree.
the class BruenorBattlehammerWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
int equipped = permanent.getAttachments().stream().map(game::getPermanent).mapToInt(p -> p.hasSubtype(SubType.EQUIPMENT, game) ? 1 : 0).sum();
permanent.addPower(2 * equipped);
}
return true;
}
use of mage.abilities.Ability in project mage by magefree.
the class BucknardsEverfullPurseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
new TreasureToken().putOntoBattlefield(player.rollDice(outcome, source, game, 4), game, source, source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return true;
}
UUID playerToRightId = game.getState().getPlayersInRange(source.getControllerId(), game).stream().reduce((u1, u2) -> u2).orElse(null);
if (playerToRightId == null) {
return false;
}
game.addEffect(new GainControlTargetEffect(Duration.Custom, true, playerToRightId).setTargetPointer(new FixedTarget(permanent, game)), source);
return true;
}
use of mage.abilities.Ability in project mage by magefree.
the class CryptIncursionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Cards cards = new CardsImpl(targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game));
player.moveCards(cards, Zone.EXILED, source, game);
int count = cards.stream().map(game.getState()::getZone).map(Zone.EXILED::equals).mapToInt(x -> x ? 1 : 0).sum();
player.gainLife(3 * count, game, source);
return true;
}
use of mage.abilities.Ability in project mage by magefree.
the class CrystallineResonanceCopyApplier method createAbility.
static Ability createAbility() {
Ability ability = new CycleControllerTriggeredAbility(new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, new CrystallineResonanceCopyApplier(), true).setDuration(Duration.UntilYourNextTurn).setText("have {this} become a copy of another target permanent until your next turn, " + "except it has this ability"), true);
ability.addTarget(new TargetPermanent(filter));
return ability;
}
use of mage.abilities.Ability in project mage by magefree.
the class CryptoplasmEffect method apply.
@Override
public boolean apply(Game game, final Ability source) {
Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creatureToCopy != null) {
CopyApplier applier = new CopyApplier() {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
blueprint.getAbilities().add(upkeepAbility);
return true;
}
};
game.copyPermanent(creatureToCopy, source.getSourceId(), source, applier);
}
return true;
}
Aggregations