Modified GhostifyHandler, added Logger statement
This commit is contained in:
parent
f224324fb5
commit
5cfa6809a2
@ -1,27 +1,27 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.GhostPlayer;
|
||||
import ch.unibas.dmi.dbis.cs108.gamelogic.klassenstruktur.Passenger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GhostifyHandler {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
/**
|
||||
* 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 original ghost.
|
||||
*
|
||||
* @param p Passenger to be ghostified
|
||||
*/
|
||||
private static int ghostifyCallCounter = -1;
|
||||
|
||||
public GhostPlayer ghost(Passenger p, Game game) {
|
||||
p.setGhost();
|
||||
GhostPlayer g;
|
||||
ghostifyCallCounter++;
|
||||
if (ghostifyCallCounter == 0) {
|
||||
g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), true);
|
||||
} else {
|
||||
g = new GhostPlayer(p.getPosition(), p.getName(), p.getClientHandler(), false);
|
||||
}
|
||||
game.gameFunctions.passengerTrain[g.getPosition()] = g;
|
||||
LOGGER.info("Passenger at position " + p.getPosition() + "has been ghostified");
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ public class VoteHandler {
|
||||
currentMax = votesForPlayer;
|
||||
}
|
||||
}
|
||||
LOGGER.info("Most votes" + currentMax);
|
||||
LOGGER.info("Most votes: " + currentMax + " vote");
|
||||
|
||||
// ghostify the player with most votes
|
||||
int ghostPosition = 0;
|
||||
@ -182,7 +182,7 @@ public class VoteHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
// set hasVoted to false for all passengers for future votings
|
||||
// set hasVoted to false for all passengers for future voting
|
||||
for (Passenger passenger : passengers) {
|
||||
passenger.setHasVoted(false);
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class VoteHandler {
|
||||
print(testArray);
|
||||
|
||||
LOGGER.info("Day");
|
||||
humanVote(testArray);
|
||||
humanVote(testArray, game);
|
||||
print(testArray);
|
||||
|
||||
} catch (TrainOverflow e) {
|
||||
|
||||
Reference in New Issue
Block a user