use of de.gg.game.model.votes.BallotOption in project ProjektGG by eskalon.
the class GameBallotScreen method onNewBallot.
@Subscribe
private void onNewBallot(NewBallotEvent ev) {
if (ev.getNewBallot() == null) {
application.getScreenManager().pushScreen("map", "circle_open");
return;
}
World world = application.getClient().getSession().getWorld();
Player localPlayer = application.getClient().getLocalPlayer();
optionTable.clear();
voterTable.clear();
buttons.clear();
infoText.setText(ev.getNewBallot().getInfoText());
// Display the voters
voterTable.add(new Label(Lang.get("screen.vote.voters"), skin, "title")).padBottom(12).row();
for (short s : ev.getNewBallot().getVoters()) {
// PositionType posT = world.getCharacter(s).getPosition();
boolean isLocalPlayer = s == application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId();
voterTable.add(new CharacterComponent(skin, world.getCharacter(s), isLocalPlayer ? -1 : application.getClient().getOpinionOfOtherCharacter(s))).left().padBottom(25).row();
}
// Display the options (if the player can vote)
if (ev.getNewBallot().getVoters().contains(localPlayer.getCurrentlyPlayedCharacterId())) {
for (BallotOption option : ev.getNewBallot().getOptions()) {
ImageTextButton button = new OffsettableImageTextButton(Lang.get(option), skin, 5);
button.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getClient().getActionHandler().castVote(option.getValue());
for (Button b : buttons) {
b.setDisabled(true);
b.setTouchable(Touchable.disabled);
}
}
});
buttons.add(button);
if (option.isCharacter() && option.getValue() != application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId()) {
// PositionType posT = world.getCharacters()
// .get((short) option.getValue()).getPosition();
optionTable.add(new CharacterComponent(skin, world.getCharacter((short) option.getValue()), application.getClient().getOpinionOfOtherCharacter((short) option.getValue()))).right().padBottom(8).row();
}
optionTable.add(button).right().padBottom(15).row();
}
}
}
use of de.gg.game.model.votes.BallotOption in project ProjektGG by eskalon.
the class CharacterBehaviour method getElectionVoteOption.
@SuppressWarnings("unchecked")
private static int getElectionVoteOption(short characterId, ElectionBallot matter, GameSession session) {
Map<Integer, Integer> options = new HashMap<>();
for (BallotOption vo : matter.getOptions()) {
int tmp = 0;
short voteOptionCharId = (short) vo.getValue();
tmp += getOpinionOfAnotherCharacter(voteOptionCharId, characterId, session);
if (characterId == voteOptionCharId)
tmp = 125;
options.put(vo.getValue(), tmp);
}
options = CollectionUtils.sortByValue(options);
return ((Entry<Integer, Integer>) options.entrySet().toArray()[0]).getKey();
}
Aggregations