use of mage.choices.TwoChoiceVote in project mage by magefree.
the class BiteOfTheBlackRoseEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Outcome.Detriment - AI will discard a card all the time (Psychosis choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Sickness (-2/-2)", "Psychosis (discard cards)", Outcome.Detriment);
vote.doVotes(source, game);
int sicknessCount = vote.getVoteCount(true);
int psychosisCount = vote.getVoteCount(false);
if (sicknessCount > psychosisCount) {
// sickness
game.addEffect(new BoostOpponentsEffect(-2, -2, Duration.EndOfTurn), source);
} else {
// psychosis or tied
new DiscardEachPlayerEffect(StaticValue.get(2), false, TargetController.OPPONENT).apply(game, source);
}
return true;
}
use of mage.choices.TwoChoiceVote in project mage by magefree.
the class MagisterOfWorthEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Outcome.Benefit - AI will return from graveyard all the time (Grace choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Grace (return from graveyard)", "Condemnation (destroy all)", Outcome.Benefit);
vote.doVotes(source, game);
int graceCount = vote.getVoteCount(true);
int condemnationCount = vote.getVoteCount(false);
if (condemnationCount >= graceCount) {
return new DestroyAllEffect(filter).apply(game, source);
}
// grace win - each player returns each creature card from their graveyard to the battlefield
Cards cards = new CardsImpl();
game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).map(g -> g.getCards(game)).flatMap(Collection::stream).filter(Objects::nonNull).filter(card -> card.isCreature(game)).forEach(cards::add);
return controller.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
use of mage.choices.TwoChoiceVote in project mage by magefree.
the class MessengerJaysEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Outcome.Benefit - AI will boost all the time (Feather choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Feather (+1/+1 counter)", "Quill (draw a card)", Outcome.Benefit);
vote.doVotes(source, game);
int featherCount = vote.getVoteCount(true);
int quillCount = vote.getVoteCount(false);
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (featherCount > 0 && permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(featherCount), source.getControllerId(), source, game);
}
Player player = game.getPlayer(source.getControllerId());
if (quillCount > 0 && player != null) {
int drawn = player.drawCards(quillCount, source, game);
player.discard(drawn, false, false, source, game);
}
return featherCount + quillCount > 0;
}
use of mage.choices.TwoChoiceVote in project mage by magefree.
the class OrchardElementalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Outcome.Benefit - AI will boost all the time (Sprout choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Sprout (two +1/+1 counters)", "Harvest (3 life)", Outcome.Benefit);
vote.doVotes(source, game);
int sproutCount = vote.getVoteCount(true);
int harvestCount = vote.getVoteCount(false);
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (sproutCount > 0 && permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(2 * sproutCount), source.getControllerId(), source, game);
}
Player player = game.getPlayer(source.getControllerId());
if (harvestCount > 0 && player != null) {
player.gainLife(3 * harvestCount, game, source);
}
return sproutCount + harvestCount > 0;
}
use of mage.choices.TwoChoiceVote in project mage by magefree.
the class PleaForPowerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// Outcome.Detriment - AI will draw cards all the time (Knowledge choice)
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
TwoChoiceVote vote = new TwoChoiceVote("Time (extra turn)", "Knowledge (draw 3 cards)", Outcome.Detriment);
vote.doVotes(source, game);
int timeCount = vote.getVoteCount(true);
int knowledgeCount = vote.getVoteCount(false);
if (timeCount > knowledgeCount) {
return new AddExtraTurnControllerEffect().apply(game, source);
} else {
return controller.drawCards(3, source, game) > 0;
}
}
Aggregations