use of mage.choices.ChoiceImpl in project mage by magefree.
the class ChooseBasicLandTypeEffect 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() + ": Chosen basic land type is " + choices.getChoice());
game.getState().setValue(mageObject.getId().toString() + VALUE_KEY, choices.getChoice());
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen basic land type: " + choices.getChoice()), game);
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class LoseAbilityOrAnotherAbilityTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
ChoiceImpl chooseAbility = new ChoiceImpl();
chooseAbility.setMessage("Choose an ability to remove");
Set<String> choice = new HashSet<>();
if (permanent.getAbilities().contains(ability)) {
choice.add(ability.getRule());
}
if (permanent.getAbilities().contains(ability2)) {
choice.add(ability2.getRule());
}
chooseAbility.setChoices(choice);
Player player = game.getPlayer(source.getControllerId());
if (player.choose(outcome, chooseAbility, game)) {
String chosenAbility = chooseAbility.getChoice();
if (chosenAbility.equals(ability.getRule())) {
permanent.removeAbility(ability, source.getSourceId(), game);
} else if (chosenAbility.equals(ability2.getRule())) {
permanent.removeAbility(ability2, source.getSourceId(), game);
}
} else {
return false;
}
}
return true;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class RemoveCounterTargetEffect method selectCounterType.
private Counter selectCounterType(Game game, Ability source, Permanent permanent) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !permanent.getCounters(game).isEmpty()) {
String counterName = null;
if (permanent.getCounters(game).size() > 1) {
Choice choice = new ChoiceImpl(true);
Set<String> choices = new HashSet<>();
for (Counter counterOnPermanent : permanent.getCounters(game).values()) {
if (permanent.getCounters(game).getCount(counterOnPermanent.getName()) > 0) {
choices.add(counterOnPermanent.getName());
}
}
choice.setChoices(choices);
choice.setMessage("Choose a counter type to remove from " + permanent.getName());
if (controller.choose(Outcome.Detriment, choice, game)) {
counterName = choice.getChoice();
} else {
return null;
}
} else {
for (Counter counterOnPermanent : permanent.getCounters(game).values()) {
if (counterOnPermanent.getCount() > 0) {
counterName = counterOnPermanent.getName();
}
}
}
return new Counter(counterName);
}
return null;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class MonkeyMonkeyMonkeyCount 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());
}
ChoiceImpl choice = new ChoiceImpl(true);
choice.setMessage("Choose letter");
Set<String> choices = new HashSet<>();
for (char letter = 'A'; letter <= 'Z'; letter++) {
choices.add(Character.toString(letter));
}
choice.setChoices(choices);
if (controller != null && mageObject != null && controller.choose(outcome, choice, game)) {
if (!game.isSimulation()) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
}
game.getState().setValue(mageObject.getId() + "_letter", choice.getChoice());
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen letter", CardUtil.addToolTipMarkTags("Chosen letter: " + choice.getChoice()), game);
}
return true;
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class NaturesBlessingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent targetPermanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (controller != null && targetPermanent != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose one");
choice.setChoices(choices);
if (controller.choose(outcome, choice, game)) {
switch(choice.getChoice()) {
case "Banding":
gainedAbility = BandingAbility.getInstance();
break;
case "First strike":
gainedAbility = FirstStrikeAbility.getInstance();
break;
case "Trample":
gainedAbility = TrampleAbility.getInstance();
}
}
if (gainedAbility != null) {
game.addEffect(new GainAbilityTargetEffect(gainedAbility, Duration.Custom), source);
} else {
targetPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + targetPermanent.getLogName());
}
return true;
}
return false;
}
Aggregations