use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class NoosegrafMobEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
permanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
Effect effect = new CreateTokenEffect(new ZombieToken());
return effect.apply(game, source);
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class AwakenTheErstwhileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// discard hands
Map<UUID, Integer> cardsAmount = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int cardsInHand = player.getHand().size();
if (cardsInHand > 0) {
player.discard(cardsInHand, false, false, source, game);
cardsAmount.put(playerId, cardsInHand);
}
}
}
// create tokens
cardsAmount.entrySet().forEach(discardedHand -> {
Player player = game.getPlayer(discardedHand.getKey());
int tokensCount = discardedHand.getValue();
if (player != null && tokensCount > 0) {
new ZombieToken().putOntoBattlefield(tokensCount, game, source, player.getId());
}
});
return true;
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class MidnightRitualEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source));
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (!cardsToExile.isEmpty()) {
new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source, controller.getId());
}
return true;
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class NecromentiaEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
Player controller = game.getPlayer(source.getControllerId());
if (cardName != null && controller != null) {
FilterCard filter = new FilterCard("card named " + cardName);
filter.add(new NamePredicate(cardName));
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
// cards in Graveyard
int cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getGraveyard().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the graveyard of " + targetPlayer.getName());
TargetCard target = new TargetCard(0, cardsCount, Zone.GRAVEYARD, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
}
}
// cards in Hand
int numberOfCardsExiledFromHand = 0;
cardsCount = (cardName.isEmpty() ? 0 : targetPlayer.getHand().count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the hand of " + targetPlayer.getName());
TargetCard target = new TargetCard(0, cardsCount, Zone.HAND, filter);
if (controller.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) {
numberOfCardsExiledFromHand = target.getTargets().size();
controller.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
}
} else {
targetPlayer.revealCards(targetPlayer.getName() + "'s Hand", targetPlayer.getHand(), game);
}
// cards in Library
Cards cardsInLibrary = new CardsImpl();
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
cardsCount = (cardName.isEmpty() ? 0 : cardsInLibrary.count(filter, game));
if (cardsCount > 0) {
filter.setMessage("card named " + cardName + " in the library of " + targetPlayer.getLogName());
TargetCardInLibrary targetLib = new TargetCardInLibrary(0, cardsCount, filter);
if (controller.choose(Outcome.Exile, cardsInLibrary, targetLib, game)) {
controller.moveCards(new CardsImpl(targetLib.getTargets()), Zone.EXILED, source, game);
}
} else {
targetPlayer.revealCards(targetPlayer.getName() + "'s Library", new CardsImpl(new HashSet<>(targetPlayer.getLibrary().getCards(game))), game);
}
targetPlayer.shuffleLibrary(source, game);
if (numberOfCardsExiledFromHand > 0) {
game.getState().applyEffects(game);
Token zombieToken = new ZombieToken();
zombieToken.putOntoBattlefield(numberOfCardsExiledFromHand, game, source, targetPlayer.getId());
}
return true;
}
return false;
}
use of mage.game.permanent.token.ZombieToken in project mage by magefree.
the class NecromancersConvenantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller == null || player == null) {
return false;
}
Set<Card> cards = player.getGraveyard().getCards(new FilterCreatureCard(), game);
UUID exileId = CardUtil.getCardExileZoneId(game, source);
// a previous refactor removed the exile code. Just putting it back.
controller.moveCardsToExile(cards, source, game, true, exileId, "Necromancer's Convenant");
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null) {
int count = exileZone.getCards(game).size();
return count > 0 && new ZombieToken().putOntoBattlefield(count, game, source, controller.getId());
}
return false;
}
Aggregations