Modified GhostifyHandler to deal with original ghost

This commit is contained in:
Alexander Sazonov 2022-04-02 23:11:19 +02:00
parent f677f5cb71
commit 75027f60b7

View File

@ -1,14 +1,23 @@
package ch.unibas.dmi.dbis.cs108.gamelogic;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.GhostPlayer;
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
public class GhostifyHandler {
/**
* Changes passenger at position x to ghost
* Changes passenger at position x to ghost. Monitors the times the ghostify method is being called. If it's being
* called for the first time, the ghostified player is being set as the original ghost.
* @param p
* Passenger to be ghostified
*/
private static int ghostifyCallCounter = 0;
public void ghostify(Passenger p) {
p.setGhost();
if (ghostifyCallCounter == 0) {
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), true);
} else {
GhostPlayer g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), false);
}
ghostifyCallCounter++;
}
}