use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class ElvishBranchbenderToken method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
// fix
ContinuousEffect effect = new BecomesCreatureTargetEffect(new ElvishBranchbenderToken(xValue), false, false, Duration.EndOfTurn);
effect.setTargetPointer(targetPointer);
game.addEffect(effect, source);
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class HarvestSeasonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int tappedCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
if (tappedCreatures > 0) {
TargetCardInLibrary target = new TargetCardInLibrary(0, tappedCreatures, StaticFilters.FILTER_CARD_BASIC_LAND);
if (controller.searchLibrary(target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class HazezonTamarEntersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Effect effect = new CreateTokenEffect(new HazezonTamarSandWarriorToken(), new PermanentsOnBattlefieldCount(new FilterControlledLandPermanent()));
effect.setText("create X 1/1 Sand Warrior creature tokens that are red, green, and white, where X is the number of lands you control at that time");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class PeerPressureEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (controller != null && controller.choose(Outcome.GainControl, choice, game)) {
String chosenType = choice.getChoice();
game.informPlayers(controller.getLogName() + " has chosen " + chosenType);
UUID playerWithMost = null;
int maxControlled = 0;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
FilterPermanent filter = new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType);
filter.add(new ControllerIdPredicate(playerId));
int controlled = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
if (controlled > maxControlled) {
maxControlled = controlled;
playerWithMost = playerId;
} else if (controlled == maxControlled) {
// Do nothing in case of tie
playerWithMost = null;
}
}
if (playerWithMost != null && playerWithMost.equals(controller.getId())) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType), controller.getId(), source.getSourceId(), game)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
use of mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount in project mage by magefree.
the class LuminescentRainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (player != null && player.choose(Outcome.BoostCreature, typeChoice, game)) {
FilterControlledPermanent filter = new FilterControlledPermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
return new GainLifeEffect(new PermanentsOnBattlefieldCount(filter, 2)).apply(game, source);
}
return false;
}
Aggregations