Added Handler skeletons concerning game logic and instructions on how to implement them
This commit is contained in:
parent
5010b66d4c
commit
401b3bec52
@ -0,0 +1,11 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
/**
|
||||
* Handles all communication Client to Server concerning games tate updates i.e. client a has voted
|
||||
* Maybe unnecessary, everything that is needed might already be implemented in ClientHandler.
|
||||
* We might only need to extend the protocol and its parser.
|
||||
*/
|
||||
|
||||
public class ClientGameInfoHandler {
|
||||
|
||||
}
|
||||
@ -15,6 +15,7 @@ public class Game {
|
||||
protected int nrOfGhosts; // sets how many Ghosts we start witch
|
||||
protected int nrOfUsers; // safes how many clients are active in this Game
|
||||
protected GameFunctions gameFunctions;
|
||||
//TODO: Figure out where Day/Night game state is saved maybe think about a game state class or smt.
|
||||
/**
|
||||
* Constructs a Game instance where:
|
||||
*
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
/**
|
||||
* Determines who heard something (via Passenger Array currently in GameFunctions 'passengerTrain')
|
||||
* and broadcasts noise message to them (via ServerGameInfoHandler)
|
||||
*/
|
||||
|
||||
public class NoiseHandler {
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
/**
|
||||
* Handles all communications Server to Client concerning game state or game state related requests
|
||||
* - Needs a possibility to only send to Ghosts
|
||||
* - and only humans
|
||||
* TODO: Figure out what format the messages have, consider protocol add what is needed dont forget about parsing
|
||||
*/
|
||||
|
||||
public class ServerGameInfoHandler {
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
|
||||
import java.util.Arrays;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -43,7 +44,7 @@ public class Train {
|
||||
}
|
||||
|
||||
}
|
||||
LOGGER.debug("A bug");
|
||||
LOGGER.info("The userTrain order is: " + Arrays.toString(userTrain));
|
||||
this.orderOfTrain = userTrain;
|
||||
this.positionOfGhost = nrOfPlayers / 2;
|
||||
}
|
||||
@ -63,23 +64,14 @@ public class Train {
|
||||
}
|
||||
i++;
|
||||
}
|
||||
LOGGER.info("An information");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] a = {1, 2, 3, 4, 5};
|
||||
System.out.println(isInArray(a, 0));
|
||||
//Test
|
||||
try {
|
||||
Train t = new Train(6, 1);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
System.out.print("|" + t.orderOfTrain[i] + "|");
|
||||
}
|
||||
System.out.println(" Ghost:" + t.positionOfGhost);
|
||||
|
||||
} catch (TrainOverflow e) {
|
||||
System.out.println(e.getMessage());
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package ch.unibas.dmi.dbis.cs108.gamelogic;
|
||||
|
||||
/**
|
||||
* Handles the Event of Voting for Humans and Ghosts. Differentiates between day and night (human Ghost) and handles votes accordingly.
|
||||
* - Sends voting request to passengers that need to be concerned
|
||||
* - collects voting results
|
||||
* - calculates who was voted for
|
||||
* - decides consequence of vote:
|
||||
* - Is Og Ghost: Humans win
|
||||
* - Is last Human: Ghosts win
|
||||
* - Is just a human: Message "x is a human"
|
||||
* - Is a peasant Ghost -> kickoff
|
||||
*
|
||||
* (All messages going to Clients are handled via ServerGameInfoHandler)
|
||||
*
|
||||
* TODO: Think about if the timer needs to be implemented here or in the Game class
|
||||
*/
|
||||
|
||||
public class VoteHandler {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user