From fa7cd0835184a0ab4cb5818d140cb7f09fe763a1 Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Sat, 30 Jul 2022 21:37:42 +0700 Subject: [PATCH] fix crown ghost saving bug --- src/modules/game.ts | 95 ++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 70 deletions(-) diff --git a/src/modules/game.ts b/src/modules/game.ts index 52827e9..843f9f4 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -745,10 +745,29 @@ export default class GameModule extends Module { saveEx.playedAt = body.ghost?.car.lastPlayedAt!; } - await prisma.ghostTrail.create({ - data: saveEx + let gCount = await prisma.ghostTrail.findFirst({ + where:{ + carId: saveEx.carId, + area: saveEx.area, + crownBattle: true + } }); + if(gCount){ + let gdbId = gCount.dbId; + await prisma.ghostTrail.update({ + where: { + dbId: gdbId + }, + data: saveEx + }); + } + else{ + await prisma.ghostTrail.create({ + data: saveEx + }); + } + await prisma.carCrown.update({ where: { area: saveEx.area @@ -2490,78 +2509,14 @@ export default class GameModule extends Module { carId: pCarId, area: pArea, crownBattle: true - } + }, + orderBy: { + playedAt: 'desc' + }, }); //---------------MAYBE NOT CORRECT--------------- let rampVal = ghost_trails!.ramp; let pathVal = ghost_trails!.path; - console.log(rampVal +" "+ pathVal); - /*if(pArea === 0){ //GID_RUNAREA_C1 - rampVal = Math.floor(Math.random() * 4); - pathVal = Math.floor(Math.random() * 10); - } - else if(pArea === 1){ //GID_RUNAREA_RING - rampVal = Math.floor(Math.random() * 2) + 4; - pathVal = Math.floor(Math.random() * 6) + 10; - } - else if(pArea === 2){ //GID_RUNAREA_SUBTOKYO_3_4 - rampVal = Math.floor(Math.random() * 2) + 6; - pathVal = Math.floor(Math.random() * 2) + 16; - } - else if(pArea === 3){ //GID_RUNAREA_SUBTOKYO_5 - rampVal = Math.floor(Math.random() * 2) + 8; - pathVal = Math.floor(Math.random() * 2) + 18; - } - else if(pArea === 4){ //GID_RUNAREA_WANGAN - rampVal = Math.floor(Math.random() * 4) + 10; - pathVal = Math.floor(Math.random() * 7) + 20; - } - else if(pArea === 5){ //GID_RUNAREA_K1 - rampVal = Math.floor(Math.random() * 4) + 14; - pathVal = Math.floor(Math.random() * 7) + 27; - } - else if(pArea === 6){ //GID_RUNAREA_YAESU - rampVal = Math.floor(Math.random() * 3) + 18; - pathVal = Math.floor(Math.random() * 4) + 34; - } - else if(pArea === 7){ //GID_RUNAREA_YOKOHAMA - rampVal = Math.floor(Math.random() * 4) + 21; - pathVal = Math.floor(Math.random() * 11) + 38; - } - else if(pArea === 8){ //GID_RUNAREA_NAGOYA - rampVal = 25; - pathVal = 49; - } - else if(pArea === 9){ //GID_RUNAREA_OSAKA - rampVal = 26; - pathVal = Math.floor(Math.random() * 4) + 50; - } - else if(pArea === 10){ //GID_RUNAREA_KOBE - rampVal = Math.floor(Math.random() * 2) + 27; - pathVal = Math.floor(Math.random() * 2) + 54; - } - else if(pArea === 11){ //GID_RUNAREA_FUKUOKA - rampVal = Math.floor(Math.random() * 4) + 29; - pathVal = Math.floor(Math.random() * 4) + 58; - } - else if(pArea === 12){ //GID_RUNAREA_HAKONE - rampVal = Math.floor(Math.random() * 2) + 33; - pathVal = Math.floor(Math.random() * 2) + 62; - } - else if(pArea === 13){ //GID_RUNAREA_TURNPIKE - rampVal = Math.floor(Math.random() * 2) + 35; - pathVal = Math.floor(Math.random() * 2) + 64; - } - //14 - 16 are dummy area - else if(pArea === 17){ //GID_RUNAREA_C1_CLOSED - rampVal = Math.floor(Math.random() * 4); - pathVal = Math.floor(Math.random() * 10); //probably not correct - } - else if(pArea === 18){ //GID_RUNAREA_HIROSHIMA - rampVal = Math.floor(Math.random() * 2) + 37; - pathVal = Math.floor(Math.random() * 2) + 56; - }*/ - //let trails = new Uint8Array([1, 2, 3, 4]); //wtf is this lmao let msg = { carId: pCarId,