modularized common and core

This commit is contained in:
2022-02-01 00:50:47 +01:00
parent 8b1d001ac0
commit bd7588c0d8
63 changed files with 288 additions and 349 deletions

View File

@@ -8,10 +8,9 @@ import eu.jonahbauer.wizard.common.messages.player.ContinueMessage;
import eu.jonahbauer.wizard.common.messages.player.PlayerMessage;
import eu.jonahbauer.wizard.common.messages.server.*;
import eu.jonahbauer.wizard.common.model.Configuration;
import eu.jonahbauer.wizard.core.machine.Game;
import eu.jonahbauer.wizard.core.messages.Observer;
import eu.jonahbauer.wizard.core.model.Configurations;
import eu.jonahbauer.wizard.core.util.Pair;
import eu.jonahbauer.wizard.core.Game;
import eu.jonahbauer.wizard.core.Observer;
import eu.jonahbauer.wizard.common.util.Pair;
import eu.jonahbauer.wizard.server.machine.Player;
import eu.jonahbauer.wizard.server.management.SessionMBean;
import lombok.AccessLevel;
@@ -169,11 +168,7 @@ public class Session implements Observer, SessionMBean {
throw new NackException(NackMessage.GAME_NOT_YET_STARTED, "Game hat not yet started.");
} else {
try {
game.execute(s -> {
// start buffering while game is locked
player.buffer();
return s.onMessage(game, uuid, message);
});
game.onMessage(uuid, message, player::buffer);
player.send(new AckMessage());
} catch (IllegalStateException e) {
throw new NackException(NackMessage.ILLEGAL_STATE, e.getMessage());
@@ -186,7 +181,7 @@ public class Session implements Observer, SessionMBean {
protected void startGame() {
notifyPlayers(new StartingGameMessage());
messages.add(Pair.of(null, new StartingGameMessage()));
game = new Game(Configurations.get(configuration).withTimeout(timeout), this);
game = new Game(configuration, timeout, 10 * 60 * 1000, this);
game.start(List.copyOf(players.keySet()));
CompletableFuture.runAsync(() -> {
while (true) {