use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class RoarOfTheCrowdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
return false;
}
FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
return new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class SkyshroudWarBeastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
MageObject target = game.getObject(source.getSourceId());
if (target != null) {
UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
FilterLandPermanent filter = FilterLandPermanent.nonbasicLand();
filter.add(new ControllerIdPredicate(playerId));
int number = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
target.getPower().setValue(number);
target.getToughness().setValue(number);
return true;
}
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class CheeseStandsAloneContinuousEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.getHand().isEmpty()) {
int numberPerms = new PermanentsOnBattlefieldCount(new FilterControlledPermanent()).calculate(game, source, this);
if (numberPerms == 1) {
if (game.getBattlefield().containsControlled(filter, source, game, 1)) {
if (!wonAlready) {
wonAlready = true;
controller.won(game);
}
}
}
}
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class TezzeretAgentOfBolasEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
int count = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT).calculate(game, source, this) * 2;
if (count > 0) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.loseLife(count, game, source, false);
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(count, game, source);
}
}
return true;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class WinnowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
FilterPermanent filter = new FilterPermanent();
filter.add(new NamePredicate(target.getName()));
if (new PermanentsOnBattlefieldCount(filter).calculate(game, source, this) > 1) {
super.apply(game, source);
}
return true;
}
return false;
}
Aggregations