use of mage.game.permanent.token.Token in project mage by magefree.
the class GorMuldrakAmphinologistEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Map<UUID, Integer> creatureMap = new HashMap<>();
game.getState().getPlayersInRange(source.getControllerId(), game).stream().forEach(uuid -> creatureMap.put(uuid, 0));
game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game).stream().filter(Objects::nonNull).map(Controllable::getControllerId).forEach(uuid -> creatureMap.compute(uuid, CardUtil::setOrIncrementValue));
int minValue = creatureMap.values().stream().mapToInt(x -> x).min().orElse(0);
minValue = Math.max(minValue, 0);
Token token = new SalamnderWarriorToken();
for (Map.Entry<UUID, Integer> entry : creatureMap.entrySet()) {
if (entry.getValue() > minValue) {
continue;
}
token.putOntoBattlefield(1, game, source, entry.getKey());
}
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class HourOfNeedExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID creatureId : getTargetPointer().getTargets(game, source)) {
Permanent creature = game.getPermanent(creatureId);
if (creature != null) {
controller.moveCardToExileWithInfo(creature, null, null, source, game, Zone.BATTLEFIELD, true);
Token token = new HourOfNeedSphinxToken();
token.putOntoBattlefield(1, game, source, creature.getControllerId());
}
}
return true;
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class HornetCannonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token hornetToken = new HornetToken();
hornetToken.putOntoBattlefield(1, game, source, source.getControllerId());
for (UUID tokenId : hornetToken.getLastAddedTokenIds()) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
DestroyTargetEffect destroyEffect = new DestroyTargetEffect(false);
destroyEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(destroyEffect), source);
}
}
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class MercurialTransformationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Token token;
if (player.chooseUse(outcome, "1/1 Frog or 4/4 Octopus?", null, "Frog", "Octopus", source, game)) {
token = new CreatureToken(1, 1).withColor("U").withSubType(SubType.FROG);
} else {
token = new CreatureToken(4, 4).withColor("U").withSubType(SubType.OCTOPUS);
}
game.addEffect(new BecomesCreatureTargetEffect(token, true, false, Duration.EndOfTurn), source);
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class NotForgottenEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card targetCard = game.getCard(source.getFirstTarget());
if (controller != null && targetCard != null) {
boolean onTop = controller.chooseUse(outcome, "Put " + targetCard.getName() + " on top of it's owners library (otherwise on bottom)?", source, game);
boolean moved = controller.moveCardToLibraryWithInfo(targetCard, source, game, Zone.GRAVEYARD, onTop, true);
if (moved) {
Token token = new SpiritWhiteToken();
token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
return true;
}
}
return false;
}
Aggregations