use of mage.choices.Choice in project mage by magefree.
the class BecomesChosenCreatureTypeTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
String chosenType = "";
if (player != null && card != null) {
Choice typeChoice = new ChoiceCreatureType();
String msg = "Choose a creature type";
if (nonWall) {
msg += " other than Wall";
}
typeChoice.setMessage(msg);
if (nonWall) {
typeChoice.getChoices().remove(SubType.WALL.getDescription());
}
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
game.informPlayers(card.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
chosenType = typeChoice.getChoice();
if (chosenType != null && !chosenType.isEmpty()) {
// ADD TYPE TO TARGET
ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(duration, SubType.byDescription(chosenType));
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addEffect(effect, source);
return true;
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class AquamorphEntityReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent;
if (event instanceof EntersTheBattlefieldEvent) {
permanent = ((EntersTheBattlefieldEvent) event).getTarget();
} else {
permanent = game.getPermanent(event.getTargetId());
}
if (permanent == null) {
return false;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what the creature becomes to");
choice.getChoices().add(choice51);
choice.getChoices().add(choice15);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) {
discard();
return false;
}
int power = 0;
int toughness = 0;
switch(choice.getChoice()) {
case choice51:
power = 5;
toughness = 1;
break;
case choice15:
power = 1;
toughness = 5;
break;
}
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
use of mage.choices.Choice in project mage by magefree.
the class ButcherOfTheHordeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Choice abilityChoice = new ChoiceImpl();
abilityChoice.setMessage("Choose an ability to add");
Set<String> abilities = new HashSet<>();
abilities.add(VigilanceAbility.getInstance().getRule());
abilities.add(LifelinkAbility.getInstance().getRule());
abilities.add(HasteAbility.getInstance().getRule());
abilityChoice.setChoices(abilities);
controller.choose(Outcome.AddAbility, abilityChoice, game);
if (!abilityChoice.isChosen()) {
return false;
}
String chosen = abilityChoice.getChoice();
Ability ability = null;
if (VigilanceAbility.getInstance().getRule().equals(chosen)) {
ability = VigilanceAbility.getInstance();
} else if (LifelinkAbility.getInstance().getRule().equals(chosen)) {
ability = LifelinkAbility.getInstance();
} else if (HasteAbility.getInstance().getRule().equals(chosen)) {
ability = HasteAbility.getInstance();
}
if (ability != null) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen: " + chosen);
ContinuousEffect effect = new GainAbilitySourceEffect(ability, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class DwarvenArmorerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose type of counter to add");
choice.setChoices(choices);
if (controller.choose(outcome, choice, game)) {
Counter counter = choice.getChoice().equals("+0/+1") ? CounterType.P0P1.createInstance() : CounterType.P1P0.createInstance();
Effect effect = new AddCountersTargetEffect(counter);
effect.setTargetPointer(new FixedTarget(this.getTargetPointer().getFirst(game, source), game));
return effect.apply(game, source);
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class GraveSifterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to return cards from your graveyard");
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toHand = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
typeChoice.clearChoice();
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game);
toHand.addAll(new CardsImpl(target.getTargets()).getCards(game));
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toHand, Zone.HAND, source, game, false, false, true, null);
return true;
}
return false;
}
Aggregations