implemented recommended changes

This commit is contained in:
Andy Fries 2014-10-28 08:59:11 -07:00
parent 6f6cf6e3bb
commit 4c9ca8a11b

View file

@ -37,6 +37,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect; import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -63,7 +64,7 @@ public class BelbesPortal extends CardImpl {
this.expansionSetCode = "NMS"; this.expansionSetCode = "NMS";
// As Belbe's Portal enters the battlefield, choose a creature type. // As Belbe's Portal enters the battlefield, choose a creature type.
this.addAbility(new AsEntersBattlefieldAbility(new BelbesPortalEnterBattlefieldEffect())); this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.PutCreatureInPlay)));
// {3}, {tap}: You may put a creature card of the chosen type from your hand onto the battlefield. // {3}, {tap}: You may put a creature card of the chosen type from your hand onto the battlefield.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new BelbesPortalPutCreatureOnBattlefieldEffect(), new BelbesPortalPutCreatureOnBattlefieldEffect(),
@ -82,43 +83,6 @@ public class BelbesPortal extends CardImpl {
} }
} }
class BelbesPortalEnterBattlefieldEffect extends OneShotEffect {
BelbesPortalEnterBattlefieldEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "choose a creature type";
}
BelbesPortalEnterBattlefieldEffect(final BelbesPortalEnterBattlefieldEffect effect) {
super(effect);
}
@Override
public BelbesPortalEnterBattlefieldEffect copy() {
return new BelbesPortalEnterBattlefieldEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose a creature type:");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.PutCreatureInPlay, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
permanent.addInfo("chosen type", "<i>Chosen type: " + typeChoice.getChoice() + "</i>");
}
return false;
}
}
class BelbesPortalPutCreatureOnBattlefieldEffect extends OneShotEffect { class BelbesPortalPutCreatureOnBattlefieldEffect extends OneShotEffect {
BelbesPortalPutCreatureOnBattlefieldEffect() { BelbesPortalPutCreatureOnBattlefieldEffect() {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
@ -143,9 +107,8 @@ class BelbesPortalPutCreatureOnBattlefieldEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
String choiceText = "Put a " + subtype.toLowerCase() + " creature card from your hand onto the battlefield?"; String choiceText = "Put a " + subtype.toLowerCase() + " creature card from your hand onto the battlefield?";
if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, game)) { if (player != null) {
return false; if (player.chooseUse(Outcome.PutCreatureInPlay, choiceText, game)) {
}
FilterCreatureCard creatureTypeFilter = new FilterCreatureCard(); FilterCreatureCard creatureTypeFilter = new FilterCreatureCard();
creatureTypeFilter.add(new SubtypePredicate(subtype)); creatureTypeFilter.add(new SubtypePredicate(subtype));
@ -154,13 +117,13 @@ class BelbesPortalPutCreatureOnBattlefieldEffect extends OneShotEffect {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
}
}
}
return true; return true;
} }
} else { }
}
return false; return false;
} }
}
}
return true;
}
} }