|
|
|
@ -1,11 +1,10 @@
|
|
|
|
|
package eu.jonahbauer.wizard.client.libgdx.state;
|
|
|
|
|
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.Client;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.screens.WaitingScreen;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.screens.SessionScreen;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.client.LeaveSessionMessage;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.client.ReadyMessage;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.data.PlayerData;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.data.SessionData;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.server.*;
|
|
|
|
|
import eu.jonahbauer.wizard.common.model.Configuration;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
@ -16,7 +15,7 @@ import java.util.*;
|
|
|
|
|
@Log4j2
|
|
|
|
|
@Getter
|
|
|
|
|
public final class Session extends BaseState {
|
|
|
|
|
private WaitingScreen sessionScreen;
|
|
|
|
|
private SessionScreen sessionScreen;
|
|
|
|
|
|
|
|
|
|
private final UUID self;
|
|
|
|
|
|
|
|
|
@ -28,14 +27,14 @@ public final class Session extends BaseState {
|
|
|
|
|
|
|
|
|
|
private boolean sending;
|
|
|
|
|
|
|
|
|
|
public Session(SessionData session, Collection<PlayerData> players, UUID self) {
|
|
|
|
|
this(session, players, self, false);
|
|
|
|
|
public Session(UUID session, String name, Configuration configuration, Collection<PlayerData> players, UUID self) {
|
|
|
|
|
this(session, name, configuration, players, self, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Session(SessionData session, Collection<PlayerData> players, UUID self, boolean dontSwitchScreen) {
|
|
|
|
|
this.session = session.getUuid();
|
|
|
|
|
this.sessionName = session.getName();
|
|
|
|
|
this.configuration = session.getConfiguration();
|
|
|
|
|
public Session(UUID session, String name, Configuration configuration, Collection<PlayerData> players, UUID self, boolean dontSwitchScreen) {
|
|
|
|
|
this.session = session;
|
|
|
|
|
this.sessionName = name;
|
|
|
|
|
this.configuration = configuration;
|
|
|
|
|
players.forEach(p -> this.players.put(p.getUuid(), p));
|
|
|
|
|
this.dontSwitchScreen = dontSwitchScreen;
|
|
|
|
|
|
|
|
|
@ -122,7 +121,7 @@ public final class Session extends BaseState {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Optional<ClientState> showInfoScreen(Client client) {
|
|
|
|
|
sessionScreen = new WaitingScreen(client.getGame());
|
|
|
|
|
sessionScreen = new SessionScreen(client.getGame());
|
|
|
|
|
client.getGame().setScreen(sessionScreen);
|
|
|
|
|
sessionScreen.setPlayers(players.values().toArray(new PlayerData[0]));
|
|
|
|
|
sessionScreen.setReady(players.get(self).isReady());
|
|
|
|
|