1
0
mirror of synced 2025-02-23 21:43:21 +01:00

fix story nuke when clearing story that already cleared

This commit is contained in:
ghkkk090 2022-10-28 20:48:28 +07:00
parent b977ff21bc
commit f530e3a06d

View File

@ -15,9 +15,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
// If the game was not retired / timed out // If the game was not retired / timed out
if (!(body.retired || body.timeup)) if (!(body.retired || body.timeup))
{ {
console.log('Game not retired / timed out, continuing ...')
console.log(body);
// Get the story result for the car // Get the story result for the car
let storyResult = body?.stResult; let storyResult = body?.stResult;
let stLoseBits = 0; let stLoseBits;
// storyResult is set // storyResult is set
if (storyResult) 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 // Check if clearBits is not null, and not lose the story
if(storyResult.stClearBits !== null && storyResult.stClearBits !== undefined) 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); if(data.stClearCount || stLoseBits)
{
// Set the ghost level to the correct level console.log('Updating story data');
data.ghostLevel = check_steps.ghostLevel;
// Update the car properties
// Update the car properties await prisma.car.update({
await prisma.car.update({ where: {
where: { carId: body.carId
carId: body.carId },
}, data: data
data: data });
}); }
} }
} }
} }