예제 #1
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();
   }
 }
예제 #2
0
 private void startGame() {
   try {
     writeMessage(0, player.getPlayerNumber());
     out.writeChar(player.getParty());
     out.writeInt(player.getIdealPt());
     out.writeInt(model.getBudget());
   } catch (IOException e1) {
     removePlayer();
   }
   writeChartData();
   ArrayList<Candidate> candidates = model.getCandidates();
   writeMessage(2, candidates.size());
   for (int i = 0; i < candidates.size(); i++) {
     try {
       out.writeByte(candidates.get(i).getCandidateNumber());
       out.writeByte(candidates.get(i).getParty());
     } catch (IOException e) {
       removePlayer();
     }
   }
 }