Skip to content

Commit

Permalink
Add a createBy property to state
Browse files Browse the repository at this point in the history
  • Loading branch information
kasbah committed Mar 6, 2022
1 parent 6aa329e commit 63e551f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions hathora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ types:
x: "int"
y: "int"
GameState:
createdBy: "UserId"
phase: "GamePhase"
signMap: "int[][]"
turn: "Color"
Expand Down
3 changes: 3 additions & 0 deletions server/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function isPass(obj: any): obj is Pass {
}

type InternalState = {
createdBy: UserId;
phase: GamePhase;
board: Board;
history: (Board | Pass)[];
Expand Down Expand Up @@ -53,6 +54,7 @@ function checkTurn(state: InternalState, playerColor: Color): Response {
export class Impl implements Methods<InternalState> {
initialize(userId: UserId, ctx: Context): InternalState {
return {
createdBy: userId,
phase: GamePhase.NotStarted,
board: Board.fromDimensions(9),
history: [],
Expand Down Expand Up @@ -292,6 +294,7 @@ export class Impl implements Methods<InternalState> {
}
getUserState(state: InternalState, userId: UserId): GameState {
return {
createdBy: state.createdBy,
phase: state.phase,
signMap: state.board.signMap,
captures: {
Expand Down

0 comments on commit 63e551f

Please sign in to comment.