Skip to content

Commit

Permalink
make disconnected state
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Dec 18, 2023
1 parent d1f4e7c commit 4c0d4f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/game/gameManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createGameManager(): GameManager {
playerId: null,

state: {
stateType: "outsideLobby"
stateType: "disconnected"
},

getMyName() {
Expand Down
6 changes: 4 additions & 2 deletions client/src/game/gameState.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { Role, RoleState } from "./roleState.d";
import { RoleOutline } from "./roleListState.d";


export type State = {
export type State = Disconnected | OutsideLobbyState | LobbyState | GameState;

} & (OutsideLobbyState | LobbyState | GameState);
export type Disconnected = {
stateType: "disconnected"
}

export type OutsideLobbyState = {
stateType: "outsideLobby"
Expand Down
10 changes: 5 additions & 5 deletions client/src/game/messageListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,24 @@ export default function messageListener(packet: ToClientPacket){
break;
case "roleList":
//list of role list entriy
if(GAME_MANAGER.state.stateType !== "outsideLobby")
if(GAME_MANAGER.state.stateType === "lobby" || GAME_MANAGER.state.stateType === "game")
GAME_MANAGER.state.roleList = packet.roleList;
break;
case "roleOutline":
//role list entriy
if(GAME_MANAGER.state.stateType !== "outsideLobby")
if(GAME_MANAGER.state.stateType === "lobby" || GAME_MANAGER.state.stateType === "game")
GAME_MANAGER.state.roleList[packet.index] = packet.roleOutline;
break;
case "phaseTime":
if(GAME_MANAGER.state.stateType !== "outsideLobby")
if(GAME_MANAGER.state.stateType === "lobby" || GAME_MANAGER.state.stateType === "game")
GAME_MANAGER.state.phaseTimes[packet.phase as keyof typeof GAME_MANAGER.state.phaseTimes] = packet.time;
break;
case "phaseTimes":
if(GAME_MANAGER.state.stateType !== "outsideLobby")
if(GAME_MANAGER.state.stateType === "lobby" || GAME_MANAGER.state.stateType === "game")
GAME_MANAGER.state.phaseTimes = packet.phaseTimeSettings;
break;
case "excludedRoles":
if(GAME_MANAGER.state.stateType !== "outsideLobby")
if(GAME_MANAGER.state.stateType === "lobby" || GAME_MANAGER.state.stateType === "game")
GAME_MANAGER.state.excludedRoles = packet.roles;
break;
case "phase":
Expand Down

0 comments on commit 4c0d4f8

Please sign in to comment.