use of mage.game.permanent.token.custom.CreatureToken in project mage by magefree.
the class JolraelEmpressOfBeastsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
FilterPermanent filter = new FilterLandPermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
game.addEffect(new BecomesCreatureAllEffect(new CreatureToken(3, 3), "lands", filter, Duration.EndOfTurn, false), source);
return true;
}
return false;
}
use of mage.game.permanent.token.custom.CreatureToken in project mage by magefree.
the class LairOfTheHydraEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX();
game.addEffect(new BecomesCreatureSourceEffect(new CreatureToken(xValue, xValue, "X/X green Hydra creature").withColor("G").withSubType(SubType.HYDRA), "land", Duration.EndOfTurn), source);
return true;
}
use of mage.game.permanent.token.custom.CreatureToken in project mage by magefree.
the class EbonyFlyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int result = player.rollDice(outcome, source, game, 6);
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || !player.chooseUse(outcome, "Have " + permanent.getName() + " become a " + result + '/' + result + " creature until end of turn?", source, game)) {
return true;
}
game.addEffect(new BecomesCreatureSourceEffect(new CreatureToken(result, result).withType(CardType.ARTIFACT).withAbility(FlyingAbility.getInstance()), "", Duration.EndOfTurn, false, false), source);
return true;
}
use of mage.game.permanent.token.custom.CreatureToken in project mage by magefree.
the class DestinySpinnerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int pt = DestinySpinnerCount.instance.calculate(game, source, this);
game.addEffect(new BecomesCreatureTargetEffect(new CreatureToken(pt, pt, "").withSubType(SubType.ELEMENTAL).withAbility(TrampleAbility.getInstance()).withAbility(HasteAbility.getInstance()), false, true, Duration.EndOfTurn), source);
return true;
}
use of mage.game.permanent.token.custom.CreatureToken in project mage by magefree.
the class MomirEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int value = source.getManaCostsToPay().getX();
if (game.isSimulation()) {
// Create dummy token to prevent multiple DB find cards what causes H2 java.lang.IllegalStateException if AI cancels calculation because of time out
Token token = new CreatureToken(value, value + 1);
token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
return true;
}
// should this be random across card names
CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).manaValue(value);
List<CardInfo> options = CardRepository.instance.findCards(criteria);
if (options == null || options.isEmpty()) {
game.informPlayers("No random creature card with mana value of " + value + " was found.");
return false;
}
// search for a random non custom set creature
EmptyToken token = null;
while (!options.isEmpty()) {
int index = RandomUtil.nextInt(options.size());
ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode());
if (expansionSet == null || !expansionSet.getSetType().isEternalLegal()) {
options.remove(index);
} else {
Card card = options.get(index).getCard();
if (card != null) {
token = new EmptyToken();
CardUtil.copyTo(token).from(card, game);
break;
} else {
options.remove(index);
}
}
}
if (token != null) {
token.putOntoBattlefield(1, game, source, source.getControllerId(), false, false);
return true;
}
return false;
}
Aggregations