MCPcopy Create free account
hub / github.com/code100x/chess / addMoveToDb

Method addMoveToDb

apps/ws/src/Game.ts:184–209  ·  view source on GitHub ↗
(move: Move, moveTimestamp: Date)

Source from the content-addressed store, hash-verified

182 }
183
184 async addMoveToDb(move: Move, moveTimestamp: Date) {
185
186 await db.$transaction([
187 db.move.create({
188 data: {
189 gameId: this.gameId,
190 moveNumber: this.moveCount + 1,
191 from: move.from,
192 to: move.to,
193 before: move.before,
194 after: move.after,
195 createdAt: moveTimestamp,
196 timeTaken: moveTimestamp.getTime() - this.lastMoveTime.getTime(),
197 san: move.san
198 },
199 }),
200 db.game.update({
201 data: {
202 currentFen: move.after,
203 },
204 where: {
205 id: this.gameId,
206 },
207 }),
208 ]);
209 }
210
211 async makeMove(
212 user: User,

Callers 1

makeMoveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected