feat: created classes for Login events

This commit is contained in:
Yannik Bretschneider 2021-06-03 16:12:21 +02:00
parent 40a0a0c0c5
commit 3daef53f21
15 changed files with 149 additions and 16 deletions

View File

@ -1,10 +0,0 @@
package uulm.teamname.marvelous.gamelibrary.messages;
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
/** Basic answer to a message. It contains */
public class BasicAnswer {
String userID;
MessageType messageType;
boolean optionals;
}

View File

@ -1,7 +1,5 @@
package uulm.teamname.marvelous.gamelibrary.messages; package uulm.teamname.marvelous.gamelibrary.messages;
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
/** /**
* The basic message from the standard, containing all possible expansion keys. In other words, one needs to check the * The basic message from the standard, containing all possible expansion keys. In other words, one needs to check the
* messageType, as fields that aren't sent are null. Note that ingame messages are not deserialized into the {@link * messageType, as fields that aren't sent are null. Note that ingame messages are not deserialized into the {@link
@ -9,9 +7,6 @@ import uulm.teamname.marvelous.gamelibrary.json.MessageType;
*/ */
public class BasicMessage { public class BasicMessage {
/** The user ID is (apparently) a MD5 hash made from the username and device IP. It is assigned by the server. */
String userID;
/** The messageType describes the type of message that might be sent */ /** The messageType describes the type of message that might be sent */
MessageType messageType; MessageType messageType;

View File

@ -0,0 +1,10 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class CharacterSelectionMessage extends BasicMessage {
/**
* Boolean array that conveys information about what characters (6)
* of the given characters (12) have been selected
*/
Boolean[] characters;
}

View File

@ -0,0 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class ConfirmSelectionMessage extends BasicMessage {
/** Whether the other player is also done with the selection already */
Boolean selectionComplete;
}

View File

@ -0,0 +1,10 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class ErrorMessage extends BasicMessage{
/** Some message telling the client what went wrong */
String message;
/** The type of the error that happened */
int type;
}

View File

@ -1,7 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.messages; package uulm.teamname.marvelous.gamelibrary.messages;
import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.json.MessageType;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;

View File

@ -0,0 +1,12 @@
package uulm.teamname.marvelous.gamelibrary.messages;
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
public class GameAssignmentMessage extends BasicMessage {
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
String gameID;
/** The characters the player can choose from */
CharacterConfig[] characterSelection;
}

View File

@ -0,0 +1,43 @@
package uulm.teamname.marvelous.gamelibrary.messages;
import com.fasterxml.jackson.annotation.JsonIgnore;
import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
import uulm.teamname.marvelous.gamelibrary.config.CharacterProperties;
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.stream.Stream;
public class GameStructureMessage extends BasicMessage {
// TODO: ADD ENUM FOR THIS
String assignment;
/** The name of the first player */
String playerOneName;
/** The name of the second player */
String playerTwoName;
/** The characters that the first player has chosen (and is therefore playing with in this match) */
CharacterProperties[] playerOneCharacters;
/** The characters that the second player has chosen (and is therefore playing with in this match) */
CharacterProperties[] playerTwoCharacters;
/** The {@link PartyConfig Party Configuration} of the current match */
PartyConfig matchconfig;
/** The {@link ScenarioConfig Scenario Configuration} of the current scenario */
ScenarioConfig scenarioconfig;
@JsonIgnore public CharacterConfig getCharacterConfig() {
CharacterConfig characterConfig = new CharacterConfig();
characterConfig.characters = Stream
.concat(Arrays.stream(playerOneCharacters), Arrays.stream(playerTwoCharacters))
.toArray(CharacterProperties[]::new);
return characterConfig;
}
}

View File

@ -0,0 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class GeneralAssignmentMessage extends BasicMessage {
/** The ID of the game that the client is connected to. What this is used for is kind of unknown. */
String gameID;
}

View File

@ -0,0 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class GoodbyeClientMessage extends BasicMessage {
/** A message sent to the client on disconnect */
String message;
}

View File

@ -0,0 +1,6 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class HelloClientMessage extends BasicMessage {
/** Whether there is a running game that the player disconnected from */
Boolean runningGame;
}

View File

@ -0,0 +1,10 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class HelloServerMessage extends BasicMessage{
/** User-chosen name, basically a PlayerName */
String name;
/** Device ID sent by the Client, might be anything, but used together with name to uniquely identify the client */
String deviceID;
}

View File

@ -0,0 +1,20 @@
package uulm.teamname.marvelous.gamelibrary.messages;
/**
* Enum describing all possible MessageTypes as defined by Standard document
*/
public enum MessageType {
HELLO_CLIENT,
HELLO_SERVER,
RECONNECT,
PLAYER_READY,
GAME_ASSIGNMENT,
GENERAL_ASSIGNMENT,
CHARACTER_SELECTION,
CONFIRM_SELECTION,
GAME_STRUCTURE,
REQUESTS,
EVENTS,
GOODBYE_CLIENT,
ERROR
}

View File

@ -0,0 +1,10 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class PlayerReadyMessage extends BasicMessage {
/** Whether the client wants to start the game. If this is false, the client gets disconnected. */
Boolean startGame;
/** The {@link RoleEnum Role} the client wants to take */
RoleEnum role;
}

View File

@ -0,0 +1,7 @@
package uulm.teamname.marvelous.gamelibrary.messages;
public class ReconnectMessage {
/** Whether the client wants to reconnect to the previously running game */
Boolean reconnect;
}