use of mage.game.permanent.token.Token in project mage by magefree.
the class HungryForMoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new HungryForMoreVampireToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new SacrificeTargetEffect().setTargetPointer(new FixedTargets(token.getLastAddedTokenIds().stream().map(game::getPermanent).collect(Collectors.toList()), game)).setText("sacrifice that token")), source);
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class MarathWillOfTheWildRemoveCountersCost method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int amount = ManacostVariableValue.REGULAR.calculate(game, source, this);
Token token = new MarathWillOfTheWildElementalToken();
token.getPower().modifyBaseValue(amount);
token.getToughness().modifyBaseValue(amount);
token.putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class OversimplifyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game);
Map<UUID, Integer> playerMap = permanents.stream().filter(Objects::nonNull).collect(Collectors.toMap(Controllable::getControllerId, p -> p.getPower().getValue(), Integer::sum));
controller.moveCards(new CardsImpl(permanents), Zone.EXILED, source, game);
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Token token = new FractalToken();
token.putOntoBattlefield(1, game, source, playerId);
int counter = playerMap.getOrDefault(playerId, 0);
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(counter), playerId, source, game);
}
}
}
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class RiseOfTheHobgoblinsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
if (you != null && you.chooseUse(Outcome.Neutral, "Do you want to to pay {X}?", source, game)) {
int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
Token token = new GoblinSoldierToken();
return token.putOntoBattlefield(costX, game, source, source.getControllerId());
}
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class WarrenWeirdingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player == null) {
return false;
}
FilterControlledPermanent filter = new FilterControlledPermanent("creature");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new ControllerIdPredicate(player.getId()));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
// had, if thats the case this ability should fizzle.
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
if (filterGoblin.match(permanent, game)) {
for (int i = 0; i < 2; i++) {
Token token = new GoblinRogueToken();
Effect effect = new CreateTokenTargetEffect(token);
effect.setTargetPointer(new FixedTarget(player.getId()));
if (effect.apply(game, source)) {
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
if (tokenPermanent != null) {
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
hasteEffect.setTargetPointer(new FixedTarget(tokenPermanent.getId()));
game.addEffect(hasteEffect, source);
}
}
}
}
}
return true;
}
return false;
}
Aggregations