From 5c32b127d5adb507701534a4e61eb7cdfb234732 Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Wed, 20 Jul 2022 00:23:50 +0700 Subject: [PATCH 1/3] fix story nuke --- src/modules/game.ts | 128 +++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 61 deletions(-) diff --git a/src/modules/game.ts b/src/modules/game.ts index b130cd4..4183577 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -16,71 +16,77 @@ export default class GameModule extends Module { carId: body.carId } }); + let storyLose: boolean = false; switch (body.gameMode) { case wm.wm.protobuf.GameMode.MODE_STORY: { - let maxConsecutiveWins = car!.stConsecutiveWinsMax; - if (maxConsecutiveWins < body.stResult!.stConsecutiveWins!) { - maxConsecutiveWins = body.stResult!.stConsecutiveWins!; - } - let divcount = body.stResult?.stClearDivCount; - let saveEx: any = {}; - if (divcount !== null && divcount !== undefined && divcount !== 0) { - console.log(body.stResult?.stClearDivCount); - saveEx.stClearDivCount = divcount; - } else { - saveEx.stClearDivCount = car?.stClearDivCount; - } - if (body.stResult?.stClearBits !== null && body.stResult?.stClearBits !== undefined) { - saveEx.stClearBits = body.stResult?.stClearBits; - } else { - saveEx.stClearBits = car?.stClearBits; - } - if (body.stResult?.stPlayCount !== null && body.stResult?.stPlayCount !== undefined) { - saveEx.stPlayCount = body.stResult?.stPlayCount!; - } else { - saveEx.stPlayCount = car?.stPlayCount; - } - if (body.stResult?.stClearCount !== null && body.stResult?.stClearCount !== undefined) { - saveEx.stClearCount = body.stResult?.stClearCount!; - } else { - saveEx.stClearCount = car?.stClearCount; - } - if (body.stResult?.stLoseBits !== null && body.stResult?.stLoseBits !== undefined) { - let actualLoseBits = BigInt(0); - if (body.stResult?.stLoseBits! instanceof Long) { - actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.high); - actualLoseBits = actualLoseBits << BigInt(32); - actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.low); - saveEx.stLoseBits = actualLoseBits; - } - } else { - saveEx.stLoseBits = car?.stLoseBits; - } - if (body.stResult?.stConsecutiveWins !== null && body.stResult?.stConsecutiveWins !== undefined) { - saveEx.stConsecutiveWins = body.stResult?.stConsecutiveWins!; - } else { - saveEx.stConsecutiveWins = car?.stConsecutiveWins; - } - if (body.stResult?.tuningPoint !== null && body.stResult?.tuningPoint !== undefined) { - saveEx.tuningPoints = body.stResult?.tuningPoint!; - } else { - saveEx.tuningPoints = car?.tuningPoints; - } - if (body.stResult?.stCompleted_100Episodes !== null && body.stResult?.stCompleted_100Episodes !== undefined) { - saveEx.stCompleted100Episodes = body.stResult?.stCompleted_100Episodes!; - } else { - saveEx.stCompleted100Episodes = car?.stCompleted100Episodes; - } console.log(body); - console.log(saveEx); - let c = await prisma.car.update({ - where: { - carId: body.carId - }, - data: saveEx - }); - console.log(c); + if (!(body.retired)) { + let maxConsecutiveWins = car!.stConsecutiveWinsMax; + if (maxConsecutiveWins < body.stResult!.stConsecutiveWins!) { + maxConsecutiveWins = body.stResult!.stConsecutiveWins!; + } + let divcount = body.stResult?.stClearDivCount; + let saveEx: any = {}; + if (body.stResult?.stLoseBits !== null && body.stResult?.stLoseBits !== undefined) { + let actualLoseBits = BigInt(0); + if (body.stResult?.stLoseBits! instanceof Long) { + actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.high); + actualLoseBits = actualLoseBits << BigInt(32); + actualLoseBits = actualLoseBits | BigInt(body.stResult?.stLoseBits.low); + saveEx.stLoseBits = Number(actualLoseBits); + if(saveEx.stLoseBits > 0){ + storyLose = true; + } + } + } else { + saveEx.stLoseBits = car?.stLoseBits; + } + if (divcount !== null && divcount !== undefined && divcount !== 0) { + console.log(body.stResult?.stClearDivCount); + saveEx.stClearDivCount = divcount; + } else { + saveEx.stClearDivCount = car?.stClearDivCount; + } + if (body.stResult?.stClearBits !== null && body.stResult?.stClearBits !== undefined && storyLose !== true) { + saveEx.stClearBits = body.stResult?.stClearBits; + } else { + saveEx.stClearBits = car?.stClearBits; + } + if (body.stResult?.stPlayCount !== null && body.stResult?.stPlayCount !== undefined) { + saveEx.stPlayCount = body.stResult?.stPlayCount!; + } else { + saveEx.stPlayCount = car?.stPlayCount; + } + if (body.stResult?.stClearCount !== null && body.stResult?.stClearCount !== undefined && body.stResult?.stClearCount !== 0) { + saveEx.stClearCount = body.stResult?.stClearCount!; + } else { + saveEx.stClearCount = car?.stClearCount; + } + if (body.stResult?.stConsecutiveWins !== null && body.stResult?.stConsecutiveWins !== undefined) { + saveEx.stConsecutiveWins = body.stResult?.stConsecutiveWins!; + } else { + saveEx.stConsecutiveWins = car?.stConsecutiveWins; + } + if (body.stResult?.tuningPoint !== null && body.stResult?.tuningPoint !== undefined) { + saveEx.tuningPoints = body.stResult?.tuningPoint!; + } else { + saveEx.tuningPoints = car?.tuningPoints; + } + if (body.stResult?.stCompleted_100Episodes !== null && body.stResult?.stCompleted_100Episodes !== undefined) { + saveEx.stCompleted100Episodes = body.stResult?.stCompleted_100Episodes!; + } else { + saveEx.stCompleted100Episodes = car?.stCompleted100Episodes; + } + console.log(saveEx); + let c = await prisma.car.update({ + where: { + carId: body.carId + }, + data: saveEx + }); + console.log(c); + } break; } case wm.wm.protobuf.GameMode.MODE_TIME_ATTACK: From 83756b2f81cd79ae09ea7aec1a2f61e60f6aae7b Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Wed, 20 Jul 2022 08:47:54 +0700 Subject: [PATCH 2/3] fix nuke story --- src/modules/game.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/game.ts b/src/modules/game.ts index 4183577..b8d0eaf 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -20,7 +20,6 @@ export default class GameModule extends Module { switch (body.gameMode) { case wm.wm.protobuf.GameMode.MODE_STORY: { - console.log(body); if (!(body.retired)) { let maxConsecutiveWins = car!.stConsecutiveWinsMax; if (maxConsecutiveWins < body.stResult!.stConsecutiveWins!) { From 4fe646f9a511a267fe0bbe8eb5d41966eec5f859 Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Wed, 20 Jul 2022 12:27:37 +0700 Subject: [PATCH 3/3] fix story reward (meter and bgm) and change carItem db structure carId shouldn't be unique --- .gitignore | 4 +++- .../migrations/20220720050238_caritem/migration.sql | 9 +++++++++ prisma/schema.prisma | 4 ++-- src/modules/game.ts | 13 +++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20220720050238_caritem/migration.sql diff --git a/.gitignore b/.gitignore index 71d3f09..fe49650 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ dist/ cert.pfx key.pem config.json -ecosystem.config.js \ No newline at end of file +package-lock.json +ecosystem.config.js +prisma/public.sql \ No newline at end of file diff --git a/prisma/migrations/20220720050238_caritem/migration.sql b/prisma/migrations/20220720050238_caritem/migration.sql new file mode 100644 index 0000000..6a6e517 --- /dev/null +++ b/prisma/migrations/20220720050238_caritem/migration.sql @@ -0,0 +1,9 @@ +-- DropIndex +DROP INDEX "CarItem_carId_key"; + +-- AlterTable +ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- AlterTable +ALTER TABLE "CarItem" ADD COLUMN "dbId" SERIAL NOT NULL, +ADD CONSTRAINT "CarItem_pkey" PRIMARY KEY ("dbId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 06d42a9..95d9dad 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -106,8 +106,8 @@ model Car { model CarItem { Car Car? @relation(fields: [carId], references: [carId]) - carId Int @unique - + dbId Int @id @default(autoincrement()) + carId Int category Int itemId Int amount Int diff --git a/src/modules/game.ts b/src/modules/game.ts index b8d0eaf..52d4bfb 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -84,7 +84,19 @@ export default class GameModule extends Module { }, data: saveEx }); + console.log('-------'); console.log(c); + + for(let i=0; i