| 152 | } |
| 153 | |
| 154 | async createGameInDb() { |
| 155 | this.startTime = new Date(Date.now()); |
| 156 | this.lastMoveTime = this.startTime; |
| 157 | |
| 158 | const game = await db.game.create({ |
| 159 | data: { |
| 160 | id: this.gameId, |
| 161 | timeControl: 'CLASSICAL', |
| 162 | status: 'IN_PROGRESS', |
| 163 | startAt: this.startTime, |
| 164 | currentFen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', |
| 165 | whitePlayer: { |
| 166 | connect: { |
| 167 | id: this.player1UserId, |
| 168 | }, |
| 169 | }, |
| 170 | blackPlayer: { |
| 171 | connect: { |
| 172 | id: this.player2UserId ?? '', |
| 173 | }, |
| 174 | }, |
| 175 | }, |
| 176 | include: { |
| 177 | whitePlayer: true, |
| 178 | blackPlayer: true, |
| 179 | }, |
| 180 | }); |
| 181 | this.gameId = game.id; |
| 182 | } |
| 183 | |
| 184 | async addMoveToDb(move: Move, moveTimestamp: Date) { |
| 185 | |