示例#1
0
 private void sendWinner() {
   Candidate winner = model.getWinner();
   writeMessage(13, winner.getCandidateNumber()); // Writes out the winner
   boolean isClosest = model.winnerIsClosest(player.getIdealPt(), winner);
   try {
     out.writeBoolean(isClosest);
   } catch (IOException e) {
     removePlayer();
   }
 }
示例#2
0
 private void startSecondBuy() {
   try {
     ArrayList<Candidate> candidates = model.getSortedCandidates();
     writeMessage(10, candidates.size());
     out.writeByte(1);
     int numPlayers = model.getNumPlayers();
     for (Candidate candidate : candidates) { // This writes the top candidates
       out.writeByte(candidate.getCandidateNumber());
       int numVotes = candidate.getFirstVotes();
       int percentVotes = ((numVotes * 100) / numPlayers);
       out.writeInt(percentVotes);
     }
   } catch (IOException e) {
     removePlayer();
   }
 }
示例#3
0
 private void startFirstVote() {
   try {
     ArrayList<Candidate> candidates = model.getCandidates();
     player.setRound("first");
     writeMessage(10, candidates.size());
     out.writeByte(0);
     int numPlayers = model.getNumPlayers();
     for (Candidate candidate : candidates) {
       out.writeByte(candidate.getCandidateNumber());
       int numVotes = candidate.getStrawVotes();
       int percentVotes = ((numVotes * 100) / numPlayers);
       out.writeInt(percentVotes);
     }
   } catch (IOException e) {
     removePlayer();
   }
 }