In joinGame, gameRestert, and leaveFromGame methods define the logic of joining the game, leaving, and game restarting system.
The library has a default restarting system, to enable it, you must create RestertingGameState and define your restart logic.
The GameManage must be set in your name class by method. setGameManager(new MyGameManager());
GameManager methods:
Optional<Game>getGameByPlayer(Player player); // Gets game by playerOptional<Game>getGameByArenaName(String arenaName); //Gets game by arena nameStringrandomGame(); //Draws arena namevoidgameRestart(Game game); //Restart game voidjoinGame(Arena arena,Player player); //Joins player to arenavoidleaveFromGame(Game game,Player player); //Leaves player from gameSet<Game>getGames(); //Gets list of arenas
How to define your own GameManager to define game logic?
Every game manager must extend AbstractGameManager.
publicclassMyGameManagerextendsAbstractGameManager { @OverridepublicStringrandomGame() {//Define your logic of drawing new arena namereturn""; } @OverridepublicvoidjoinGame(Arena arena,Player player) {//Define your logic of joining to arena } @OverridepublicvoidleaveFromGame(Game game,Player player) {//Define your logic of leaving from arena }}
How to enable the default restarting system?
@OverrideprotectedGameStategetRestartingGameState(Game game) {//enables default game restarting systemreturnnewRestartingGameState(this, game);}
Define your restarting system.
@OverridepublicvoidgameRestart(Game game) {//define your own logic of restarting game }
How to use rejoin feature ? (The documentation is not completed)