use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class TemptingContractEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int counter = 0;
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null && opponent.chooseUse(outcome, "Create a Treasure token?", "If you do, " + controller.getName() + " will create one as well", "Yes", "No", source, game) && new TreasureToken().putOntoBattlefield(1, game, source, opponent.getId())) {
counter++;
}
}
if (counter > 0) {
new TreasureToken().putOntoBattlefield(counter, game, source, source.getControllerId());
return true;
}
return false;
}
use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class TirelessProvisionerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Token token = player.chooseUse(outcome, "Create a Food token or a Treasure token?", null, "Food", "Treasure", source, game) ? new FoodToken() : new TreasureToken();
return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class XornReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
if (event instanceof CreateTokenEvent) {
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
TreasureToken treasureToken = null;
Map<Token, Integer> tokens = tokenEvent.getTokens();
for (Token token : tokens.keySet()) {
if (token instanceof TreasureToken) {
treasureToken = (TreasureToken) token;
break;
}
}
if (treasureToken == null) {
treasureToken = new TreasureToken();
}
tokens.put(treasureToken, tokens.getOrDefault(treasureToken, 0) + 1);
}
return false;
}
use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class OldRutsteinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = player.millCards(1, source, game);
if (cards.getCards(game).stream().anyMatch(card -> card.isLand(game))) {
new TreasureToken().putOntoBattlefield(1, game, source, source.getControllerId());
}
if (cards.getCards(game).stream().anyMatch(card -> card.isCreature(game))) {
new InsectToken().putOntoBattlefield(1, game, source, source.getControllerId());
}
if (cards.getCards(game).stream().anyMatch(card -> !card.isCreature(game) && !card.isLand(game))) {
new BloodToken().putOntoBattlefield(1, game, source, source.getControllerId());
}
return true;
}
use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class SmashingSuccessEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null && permanent.isPhasedIn() && !permanent.isPhasedOutIndirectly()) {
if (permanent.isArtifact(game)) {
if (permanent.destroy(source, game, false)) {
Token token = new TreasureToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
return true;
}
} else {
return permanent.destroy(source, game, false);
}
}
return false;
}
Aggregations