use of mage.choices.ChoiceImpl in project mage by magefree.
the class GideonBlackbladeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (player == null || permanent == null) {
return false;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose an ability to give to " + permanent.getLogName());
choice.setChoices(choices);
if (!player.choose(outcome, choice, game)) {
return false;
}
Ability ability = null;
switch(choice.getChoice()) {
case "Vigilance":
ability = VigilanceAbility.getInstance();
break;
case "Lifelink":
ability = LifelinkAbility.getInstance();
break;
case "Indestructible":
ability = IndestructibleAbility.getInstance();
break;
}
if (ability != null) {
game.addEffect(new GainAbilityTargetEffect(ability, Duration.EndOfTurn), source);
}
return true;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class ChooseTwoBasicLandTypesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
mageObject = game.getObject(source.getSourceId());
}
if (controller != null && mageObject != null) {
ChoiceImpl choices = new ChoiceBasicLandType();
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(mageObject.getName() + ": First chosen basic land type is " + choices.getChoice());
game.getState().setValue(mageObject.getId().toString() + "firstChoice", choices.getChoice());
choiceOne = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "firstChoice")).getDescription();
}
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(mageObject.getName() + ": Second chosen basic land type is " + choices.getChoice());
game.getState().setValue(mageObject.getId().toString() + "secondChoice", choices.getChoice());
choiceTwo = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "secondChoice")).getDescription();
if (mageObject instanceof Permanent && choiceOne != null && choiceTwo != null) {
((Permanent) mageObject).addInfo("Chosen Types", CardUtil.addToolTipMarkTags("First chosen basic land type: " + choiceOne + "\n Second chosen basic land type: " + choiceTwo), game);
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class RiteOfRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Set<String> choices = new HashSet<>();
choices.add("Artifacts");
choices.add("Creatures");
choices.add("Lands");
LinkedList<CardType> order = new LinkedList<>();
ChoiceImpl choice = new ChoiceImpl(true);
choice.setMessage("Choose a card type");
choice.setChoices(choices);
while (choices.size() > 1) {
if (!controller.choose(Outcome.Sacrifice, choice, game)) {
return false;
}
order.add(getCardType(choice.getChoice()));
choices.remove(choice.getChoice());
choice.clearChoice();
}
order.add(getCardType(choices.iterator().next()));
int count = 1;
for (CardType cardType : order) {
FilterControlledPermanent filter = new FilterControlledPermanent(cardType + " you control");
filter.add(cardType.getPredicate());
new SacrificeAllEffect(count, filter).apply(game, source);
count++;
}
return true;
}
use of mage.choices.ChoiceImpl 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.ChoiceImpl 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;
}
Aggregations