use of mage.game.permanent.token.Token in project mage by magefree.
the class VolrathsLaboratoryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
Token token = new VolrathsLaboratoryToken(color, subType);
return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class GarbageElementalCEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
int thisRoll = results.get(0);
int thatRoll = results.get(1);
Token token = new GoblinToken();
return token.putOntoBattlefield(Math.abs(thatRoll - thisRoll), game, source, source.getControllerId());
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class KamahlsSummonsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Map<UUID, Integer> revealedCards = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CREATURE);
if (player.choose(outcome, target, source.getSourceId(), game)) {
Cards cards = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), cards, game);
revealedCards.put(playerId, target.getTargets().size());
}
}
}
}
Token token = new BearToken();
for (Map.Entry<UUID, Integer> revealedCardsByPlayer : revealedCards.entrySet()) {
int value = revealedCardsByPlayer.getValue();
if (value > 0) {
token.putOntoBattlefield(value, game, source, revealedCardsByPlayer.getKey());
}
}
return true;
}
return false;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class NahiriHeirOfTheAncientsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new KorWarriorToken();
token.putOntoBattlefield(1, game, source, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
List<Permanent> tokens = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
int equipCount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (tokens.isEmpty() || equipCount == 0 || !player.chooseUse(outcome, "Attach an equipment to the token?", source, game)) {
return true;
}
Permanent tokenCreature = tokens.get(0);
if (tokens.size() > 1) {
FilterPermanent tokenFilter = new FilterPermanent("token");
tokenFilter.add(Predicates.or(tokens.stream().map(MageObject::getId).map(PermanentIdPredicate::new).collect(Collectors.toSet())));
TargetPermanent target = new TargetPermanent(tokenFilter);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
tokenCreature = game.getPermanent(target.getFirstTarget());
}
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
tokenCreature.addAttachment(target.getFirstTarget(), source, game);
return true;
}
use of mage.game.permanent.token.Token in project mage by magefree.
the class SmokeSpiritsAidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Token token = new SmokeBlessingToken();
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null) {
continue;
}
token.putOntoBattlefield(1, game, source);
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent aura = game.getPermanent(tokenId);
if (aura == null) {
continue;
}
aura.getAbilities().get(0).getTargets().get(0).add(source.getFirstTarget(), game);
aura.getAbilities().get(0).getEffects().get(0).apply(game, aura.getAbilities().get(0));
}
}
return true;
}
Aggregations