Added getVoteFromClient method to superclass Passenger so when NPC vote, nothing happens when this method is called
This commit is contained in:
parent
09024dbfad
commit
96b0fa70ef
@ -38,5 +38,24 @@ public class GhostPlayer extends Ghost {
|
|||||||
String formattedMsg = ServerGameInfoHandler.format(msg, game);
|
String formattedMsg = ServerGameInfoHandler.format(msg, game);
|
||||||
clientHandler.sendMsgToClient(formattedMsg);
|
clientHandler.sendMsgToClient(formattedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the voting information vote and hasVoted from clientHandler and this values to those values.
|
||||||
|
* Sets clientHandler fields to default: vote = Integer.MAX_VALUE , hasVoted = false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void getVoteFromClientHandler() {
|
||||||
|
vote = clientHandler.getVote();
|
||||||
|
hasVoted = clientHandler.getHasVoted();
|
||||||
|
clientHandler.setVote(Integer.MAX_VALUE);
|
||||||
|
clientHandler.setHasVoted(false);
|
||||||
|
/*
|
||||||
|
* if vote wasn't valid, make sure, the passenger field hasVoted == false, probably redundant but better be safe than sorry
|
||||||
|
*/
|
||||||
|
if(vote == Integer.MAX_VALUE) {
|
||||||
|
hasVoted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,4 +35,22 @@ public class HumanPlayer extends Human {
|
|||||||
String formattedMsg = ServerGameInfoHandler.format(msg, game);
|
String formattedMsg = ServerGameInfoHandler.format(msg, game);
|
||||||
clientHandler.sendMsgToClient(formattedMsg);
|
clientHandler.sendMsgToClient(formattedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the voting information vote and hasVoted from clientHandler and this values to those values.
|
||||||
|
* Sets clientHandler fields to default: vote = Integer.MAX_VALUE , hasVoted = false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void getVoteFromClientHandler() {
|
||||||
|
vote = clientHandler.getVote();
|
||||||
|
hasVoted = clientHandler.getHasVoted();
|
||||||
|
clientHandler.setVote(Integer.MAX_VALUE);
|
||||||
|
clientHandler.setHasVoted(false);
|
||||||
|
/*
|
||||||
|
* if vote wasn't valid, make sure, the passenger field hasVoted == false, probably redundant but better be safe than sorry
|
||||||
|
*/
|
||||||
|
if(vote == Integer.MAX_VALUE) {
|
||||||
|
hasVoted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,4 +109,7 @@ public class Passenger {
|
|||||||
return clientHandler;
|
return clientHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getVoteFromClientHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user