use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.
the class BoosterTutorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.UnboostCreature);
effect.apply(game, source);
Player controller = game.getPlayer(source.getControllerId());
String setChosen = null;
if (effect.getValue("setchosen") != null) {
setChosen = (String) effect.getValue("setchosen");
} else if (game.getState().getValue(this.getId() + "_set") != null) {
setChosen = (String) game.getState().getValue(this.getId() + "_set");
}
if (setChosen != null && controller != null) {
// ExpansionInfo set = ExpansionRepository.instance.getSetByName(setChosen);
ExpansionSet expansionSet = Sets.findSet(setChosen);
if (expansionSet != null) {
List<Card> boosterPack = expansionSet.create15CardBooster();
if (boosterPack != null) {
StringBuilder message = new StringBuilder(controller.getLogName()).append(" opened: ");
for (Card card : boosterPack) {
message.append(card.getName()).append(" ");
}
game.informPlayers(message.toString());
TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
Set<Card> cardsToLoad = new HashSet<Card>(boosterPack);
game.loadCards(cardsToLoad, controller.getId());
CardsImpl cards = new CardsImpl();
cards.addAll(boosterPack);
if (controller.choose(Outcome.Benefit, cards, targetCard, game)) {
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.
the class WorldBottlingKitEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.Exile);
effect.apply(game, source);
String setChosen = null;
if (effect.getValue("setchosen") != null) {
setChosen = (String) effect.getValue("setchosen");
} else if (game.getState().getValue(this.getId() + "_set") != null) {
setChosen = (String) game.getState().getValue(this.getId() + "_set");
}
if (setChosen != null) {
game.informPlayers(controller.getLogName() + " has chosen set " + setChosen);
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.not(Predicates.and(CardType.LAND.getPredicate(), SuperType.BASIC.getPredicate())));
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
if (permanent.getExpansionSetCode().equals(setChosen)) {
controller.moveCardToExileWithInfo(permanent, null, "", source, game, Zone.BATTLEFIELD, true);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ChooseExpansionSetEffect in project mage by magefree.
the class SummonThePackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ChooseExpansionSetEffect effect = new ChooseExpansionSetEffect(Outcome.UnboostCreature);
effect.apply(game, source);
Player controller = game.getPlayer(source.getControllerId());
String setChosen = null;
if (effect.getValue("setchosen") != null) {
setChosen = (String) effect.getValue("setchosen");
} else if (game.getState().getValue(this.getId() + "_set") != null) {
setChosen = (String) game.getState().getValue(this.getId() + "_set");
}
if (setChosen != null && controller != null) {
// ExpansionInfo set = ExpansionRepository.instance.getSetByName(setChosen);
ExpansionSet expansionSet = Sets.findSet(setChosen);
if (expansionSet != null) {
List<Card> boosterPack = expansionSet.create15CardBooster();
List<Card> creatureCards = new ArrayList<>();
if (boosterPack != null) {
StringBuilder message = new StringBuilder(controller.getLogName()).append(" opened: ");
for (Card c : boosterPack) {
if (c != null && c.isCreature(game)) {
message.append(c.getName()).append(" ");
message.append(" (creature card) ");
ContinuousEffect effect2 = new BecomesBlackZombieAdditionEffect(false);
effect2.setTargetPointer(new FixedTarget(c.getId()));
game.addEffect(effect2, source);
creatureCards.add(c);
c.setZone(Zone.OUTSIDE, game);
}
}
if (creatureCards.size() > 0) {
Set<Card> ccs = new HashSet<>(creatureCards);
game.loadCards(ccs, controller.getId());
controller.moveCards(ccs, Zone.BATTLEFIELD, source, game);
}
game.informPlayers(message.toString());
}
}
}
return false;
}
Aggregations