Skip to content

Commit

Permalink
fixing userRole for demo game
Browse files Browse the repository at this point in the history
  • Loading branch information
jajakob committed Jun 13, 2024
1 parent 1942390 commit 82918f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/platform/src/services/GameService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { nanoid } from 'nanoid'
import { none, repeat } from 'ramda'
import * as yup from 'yup'
import log from '../lib/logger'
import {
CtxWithFacts,
CtxWithFactsAndSchema,
CtxWithPrisma,
UserRole,
} from '../types'
import { CtxWithFacts, CtxWithFactsAndSchema, CtxWithPrisma } from '../types'
import * as EventService from './EventService'

type Context = CtxWithPrisma<PrismaClient>
Expand Down Expand Up @@ -997,12 +992,7 @@ export function computePeriodStartResults(
const { result: facts, actions } = reducers.PeriodResult.apply(result, {
type: reducers.PeriodResult.ActionTypes.PERIOD_RESULTS_START,
payload: {
// playerRole: result.player.role ?? result.player.connect.role,
// TODO(JJ):
// - The game doesn't go to the next period because playerRole = null
// - Double-check with RS: shouldn't the player role always be
// UserRole.PLAYER?
playerRole: UserRole.PLAYER,
playerRole: result.player.role ?? result.player.connect.role,
periodFacts,
},
})
Expand Down Expand Up @@ -1048,7 +1038,7 @@ export function computePeriodStartResults(
{
type: reducers.PeriodResult.ActionTypes.PERIOD_RESULTS_INITIALIZE,
payload: {
playerRole: player.role ?? UserRole.PLAYER,
playerRole: player.role,
periodFacts,
},
}
Expand Down
2 changes: 2 additions & 0 deletions packages/platform/src/types/Mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ interface GenerateBaseMutationsArgs {
reducers?: any
schemas?: any
inputTypes?: any
// TODO(JJ): is returning void right here? It should return a UserRole, no?
roleAssigner?: (ix: number) => void
}

export function generateBaseMutations<PeriodFacts, PeriodSegmentFacts>({
reducers = defaultReducers,
// TODO(JJ): What Is Unset? Why string?
roleAssigner = () => 'UNSET',
schemas = defaultSchemas,
inputTypes = defaultInputTypes,
Expand Down

0 comments on commit 82918f6

Please sign in to comment.