forked from External/mage
* created interface for handling voting * created class for two choice votes, refactored a card to use it * refactored all cards which use two choice votes * updated VoteHandler to an abstract class to encapsulate more of its functions * refactored cards which vote for more than two things * [CNS] Implemented Brago's Representative * [CN2] Implemented Ballot Broker * [CN2] Implemented Illusion of Choice * [CNS] Implemented Grudge Keeper * added vote outcomes * updated implementation of Illusion of Choice to work correctly in multiples * added test for voting * updated implementation of extra votes * simplified vote message handling * Improved names, additional comments * Votes: fixed not working getMostVoted * Votes: added final vote results to game logs; * Votes: added additional info for the vote choices; * Votes: added vote step info in choose dialogs, added AI support example for Tyrant's Choice; Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
package mage.choices;
|
|
|
|
import mage.abilities.Ability;
|
|
import mage.constants.Outcome;
|
|
import mage.game.Game;
|
|
import mage.players.Player;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* @author TheElk801
|
|
*/
|
|
public class TwoChoiceVote extends VoteHandler<Boolean> {
|
|
|
|
private final String choice1;
|
|
private final String choice2;
|
|
private final Outcome outcome;
|
|
|
|
public TwoChoiceVote(String choice1, String choice2, Outcome outcome) {
|
|
this.choice1 = choice1;
|
|
this.choice2 = choice2;
|
|
this.outcome = outcome;
|
|
}
|
|
|
|
@Override
|
|
protected Set<Boolean> getPossibleVotes(Ability source, Game game) {
|
|
return new LinkedHashSet<>(Arrays.asList(Boolean.TRUE, Boolean.FALSE));
|
|
}
|
|
|
|
@Override
|
|
public Boolean playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) {
|
|
return decidingPlayer.chooseUse(outcome, voteInfo, null, choice1, choice2, source, game);
|
|
}
|
|
|
|
@Override
|
|
protected String voteName(Boolean vote) {
|
|
return (vote ? choice1 : choice2);
|
|
}
|
|
}
|