From 75027f60b725b799337b4163fea2186413f99dd8 Mon Sep 17 00:00:00 2001 From: Alexander Sazonov Date: Sat, 2 Apr 2022 23:11:19 +0200 Subject: [PATCH] Modified GhostifyHandler to deal with original ghost --- .../dmi/dbis/cs108/gamelogic/GhostifyHandler.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/GhostifyHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/GhostifyHandler.java index 58bb07e..a971eef 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/GhostifyHandler.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/GhostifyHandler.java @@ -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++; } }