From f530e3a06d39da2e8a4a367dfd4f0239c4ad896a Mon Sep 17 00:00:00 2001 From: ghkkk090 Date: Fri, 28 Oct 2022 20:48:28 +0700 Subject: [PATCH] fix story nuke when clearing story that already cleared --- src/util/games/story.ts | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/util/games/story.ts b/src/util/games/story.ts index 1dde625..d4f6830 100644 --- a/src/util/games/story.ts +++ b/src/util/games/story.ts @@ -15,9 +15,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c // If the game was not retired / timed out if (!(body.retired || body.timeup)) { + console.log('Game not retired / timed out, continuing ...') + console.log(body); + // Get the story result for the car let storyResult = body?.stResult; - let stLoseBits = 0; + let stLoseBits; // storyResult is set if (storyResult) @@ -54,6 +57,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c } } + // Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts) + let check_steps = await check_step.checkCurrentStep(body); + + // Set the ghost level to the correct level + data.ghostLevel = check_steps.ghostLevel; + // Check if clearBits is not null, and not lose the story if(storyResult.stClearBits !== null && storyResult.stClearBits !== undefined) { @@ -63,19 +72,19 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c } } - // Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts) - let check_steps = await check_step.checkCurrentStep(body); - - // Set the ghost level to the correct level - data.ghostLevel = check_steps.ghostLevel; - - // Update the car properties - await prisma.car.update({ - where: { - carId: body.carId - }, - data: data - }); + + if(data.stClearCount || stLoseBits) + { + console.log('Updating story data'); + + // Update the car properties + await prisma.car.update({ + where: { + carId: body.carId + }, + data: data + }); + } } } } \ No newline at end of file