Working on VoteHandler
This commit is contained in:
parent
bb29f77fa9
commit
d0c4290894
@ -5,21 +5,22 @@ import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
|||||||
|
|
||||||
public class GhostifyHandler {
|
public class GhostifyHandler {
|
||||||
/**
|
/**
|
||||||
* Changes passenger at position x to ghost. Monitors the times the ghostify method is being
|
* Changes passenger at position x to ghost and returns this ghost. Monitors the times the ghost method is being
|
||||||
* called. If it's being called for the first time, the ghostified player is being set as the
|
* called. If it's being called for the first time, the ghostified player is being set as the original ghost.
|
||||||
* original ghost.
|
|
||||||
*
|
*
|
||||||
* @param p Passenger to be ghostified
|
* @param p Passenger to be ghostified
|
||||||
*/
|
*/
|
||||||
private static int ghostifyCallCounter = 0;
|
private static int ghostifyCallCounter = -1;
|
||||||
|
|
||||||
public void ghostify(Passenger p) {
|
public GhostPlayer ghost(Passenger p) {
|
||||||
p.setGhost();
|
p.setGhost();
|
||||||
|
ghostifyCallCounter++;
|
||||||
if (ghostifyCallCounter == 0) {
|
if (ghostifyCallCounter == 0) {
|
||||||
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), true);
|
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), true);
|
||||||
|
return g;
|
||||||
} else {
|
} else {
|
||||||
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), false);
|
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), false);
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
ghostifyCallCounter++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Ghost;
|
||||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.GhostPlayer;
|
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.GhostPlayer;
|
||||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
||||||
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
import ch.unibas.dmi.dbis.cs108.multiplayer.server.ClientHandler;
|
||||||
@ -64,7 +65,7 @@ public class VoteHandler {
|
|||||||
for (int i = 0; i < votesForPlayers.length; i++) {
|
for (int i = 0; i < votesForPlayers.length; i++) {
|
||||||
if (votesForPlayers[i] == currentMax) { // if player has most votes
|
if (votesForPlayers[i] == currentMax) { // if player has most votes
|
||||||
GhostifyHandler gh = new GhostifyHandler();
|
GhostifyHandler gh = new GhostifyHandler();
|
||||||
gh.ghostify(passengers[i]);
|
Ghost g = gh.ghost(passengers[i]);
|
||||||
passengers[i].send(
|
passengers[i].send(
|
||||||
"You are now a ghost!"); // TODO: ServerGameInfoHandler might deal with this one
|
"You are now a ghost!"); // TODO: ServerGameInfoHandler might deal with this one
|
||||||
}
|
}
|
||||||
@ -122,11 +123,7 @@ public class VoteHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (passengers[i].getIsGhost()) { // if player is a ghost
|
if (passengers[i].getIsGhost()) { // if player is a ghost
|
||||||
// Now the case "ghost is og" and the case "ghost is not og" need to be handled
|
if (
|
||||||
/* TODO: I don't know how to get the information about a ghost being the OG because I'm accessing the players
|
|
||||||
via the Passenger class which can't use the getIsOG method from the Ghost class. I (Alex) will try to
|
|
||||||
solve this issue but if anyone can help please do!
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user