1- import { GameService , UserRole } from '@gbl-uzh/platform'
1+ import { GameService , Reducers , UserRole } from '@gbl-uzh/platform'
22import { PrismaClient } from '@prisma/client'
3+ import { PeriodFacts , PeriodFactsSchema } from '../src/graphql/types'
4+ import * as reds from '../src/reducers'
5+
6+ // TODO(Jakob):
7+ // - Check where we get the facts from to addPeriod
8+ // - flag for clearing the prisma db and do from scratch -> only over cli?
9+
10+ // - Why do we always provide all reducers for every function in GameServie?
11+
12+ // - Add state machine in the platform code and add it here
13+ // - Use the functions in util and GameService and alter them iteratively
14+ // in order to use the state machine -> also check how to use the actor
315
416describe ( 'Testing Demo Game' , ( ) => {
517 const nameGame = 'TestDemoGame'
@@ -10,6 +22,28 @@ describe('Testing Demo Game', () => {
1022 const userSub = '716f7632-ed33-4701-a281-0f27bd4f6e82'
1123 const roleAssigner = ( ix : number ) : UserRole => UserRole . PLAYER
1224 const prisma = new PrismaClient ( )
25+ const reducers : Reducers < PrismaClient > = {
26+ Actions : {
27+ apply : reds . Actions . apply ,
28+ ActionTypes : reds . Actions . ActionTypes ,
29+ } ,
30+ Period : {
31+ apply : reds . Period . apply ,
32+ ActionTypes : reds . Period . ActionTypes ,
33+ } ,
34+ PeriodResult : {
35+ apply : reds . PeriodResult . apply ,
36+ ActionTypes : reds . PeriodResult . ActionTypes ,
37+ } ,
38+ Segment : {
39+ apply : reds . Segment . apply ,
40+ ActionTypes : reds . Segment . ActionTypes ,
41+ } ,
42+ SegmentResult : {
43+ apply : reds . SegmentResult . apply ,
44+ ActionTypes : reds . SegmentResult . ActionTypes ,
45+ } ,
46+ }
1347
1448 let ctx : GameService . Context = {
1549 prisma : prisma ,
@@ -58,14 +92,6 @@ describe('Testing Demo Game', () => {
5892 } )
5993 }
6094
61- // TODO(Jakob):
62- // - flag for clearing the prisma db and do from scratch
63- // - what is the return of GameService.createGame and what is it used for?
64-
65- // - Add state machine in the platform code and add it here
66- // - Use the functions in util and GameService and alter them iteratively
67- // in order to use the state machine -> also check how to use the actor
68-
6995 it ( 'creates a new Game' , async ( ) => {
7096 if ( createNewGame ) {
7197 game = await GameService . createGame (
@@ -77,6 +103,22 @@ describe('Testing Demo Game', () => {
77103 } else {
78104 game = await findGame ( gameId )
79105 }
106+
107+ let facts = {
108+ rollsPerSegment : 1 ,
109+ scenario : {
110+ bankReturn : 1 ,
111+ seed : 1 ,
112+ trendStocks : 1 ,
113+ trendBonds : 1 ,
114+ gapStocks : 1 ,
115+ gapBonds : 1 ,
116+ } ,
117+ }
118+ GameService . addGamePeriod < PeriodFacts > ( { gameId, facts } , ctx , {
119+ schema : PeriodFactsSchema ,
120+ reducers,
121+ } )
80122 } )
81123} )
82124
0 commit comments