use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class VisionsOfRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Set<Permanent> permanents = new HashSet<>();
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent == null || game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT, source.getSourceId(), playerId, game) < 1) {
continue;
}
TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT);
target.setNotTarget(true);
opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
permanents.add(game.getPermanent(target.getFirstTarget()));
}
int sacrificed = 0;
for (Permanent permanent : permanents) {
if (permanent != null && permanent.sacrifice(source, game)) {
sacrificed++;
}
}
if (sacrificed > 0) {
new TreasureToken().putOntoBattlefield(sacrificed, game, source, source.getControllerId());
}
return true;
}
use of mage.game.permanent.token.TreasureToken in project mage by magefree.
the class AcademyManufactorEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
int amount = 0;
Map<Token, Integer> tokens = ((CreateTokenEvent) event).getTokens();
for (Iterator<Map.Entry<Token, Integer>> iter = tokens.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Token, Integer> entry = iter.next();
Token token = entry.getKey();
if (token.hasSubtype(SubType.CLUE, game) || token.hasSubtype(SubType.FOOD, game) || token.hasSubtype(SubType.TREASURE, game)) {
amount += entry.getValue();
iter.remove();
}
}
tokens.put(new ClueArtifactToken(), amount);
tokens.put(new FoodToken(), amount);
tokens.put(new TreasureToken(), amount);
return false;
}
Aggregations