From 488f530df192d7f34ff938eb1cd1921293f35858 Mon Sep 17 00:00:00 2001 From: ghkkk090 <108461408+ghkkk090@users.noreply.github.com> Date: Thu, 4 Aug 2022 19:14:26 +0700 Subject: [PATCH] ghost battle history --- .../migration.sql | 30 +++ prisma/schema.prisma | 24 +++ src/modules/game.ts | 187 +++++++++++++++++- src/modules/startup.ts | 3 +- 4 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20220804052450_ghost_battle_record/migration.sql diff --git a/prisma/migrations/20220804052450_ghost_battle_record/migration.sql b/prisma/migrations/20220804052450_ghost_battle_record/migration.sql new file mode 100644 index 0000000..d22d79d --- /dev/null +++ b/prisma/migrations/20220804052450_ghost_battle_record/migration.sql @@ -0,0 +1,30 @@ +-- AlterTable +ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0; + +-- CreateTable +CREATE TABLE "GhostBattleRecord" ( + "dbId" SERIAL NOT NULL, + "carId" INTEGER NOT NULL, + "tunePower" INTEGER NOT NULL DEFAULT 0, + "tuneHandling" INTEGER NOT NULL DEFAULT 0, + "opponent1CarId" INTEGER NOT NULL, + "opponent1Result" INTEGER NOT NULL, + "opponent1TunePower" INTEGER NOT NULL, + "opponent1TuneHandling" INTEGER NOT NULL, + "opponent2CarId" INTEGER, + "opponent2Result" INTEGER, + "opponent2TunePower" INTEGER, + "opponent2TuneHandling" INTEGER, + "opponent3CarId" INTEGER, + "opponent3Result" INTEGER, + "opponent3TunePower" INTEGER, + "opponent3TuneHandling" INTEGER, + "area" INTEGER NOT NULL DEFAULT 0, + "playedAt" INTEGER NOT NULL DEFAULT 0, + "playedShopName" TEXT NOT NULL DEFAULT 'Bayshore', + + CONSTRAINT "GhostBattleRecord_pkey" PRIMARY KEY ("dbId") +); + +-- AddForeignKey +ALTER TABLE "GhostBattleRecord" ADD CONSTRAINT "GhostBattleRecord_carId_fkey" FOREIGN KEY ("carId") REFERENCES "Car"("carId") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 81bcbd8..0dca4a4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -132,6 +132,7 @@ model Car { TimeAttackRecord TimeAttackRecord[] CarCrown CarCrown[] GhostTrail GhostTrail[] + GhostBattleRecord GhostBattleRecord[] } model CarGTWing { @@ -236,3 +237,26 @@ model GhostTrail { tuneHandling Int @default(0) crownBattle Boolean @default(false) } + +model GhostBattleRecord { + dbId Int @id @default(autoincrement()) + car Car @relation(fields: [carId], references: [carId]) + carId Int + tunePower Int @default(0) + tuneHandling Int @default(0) + opponent1CarId Int + opponent1Result Int + opponent1TunePower Int + opponent1TuneHandling Int + opponent2CarId Int? + opponent2Result Int? + opponent2TunePower Int? + opponent2TuneHandling Int? + opponent3CarId Int? + opponent3Result Int? + opponent3TunePower Int? + opponent3TuneHandling Int? + area Int @default(0) + playedAt Int @default(0) + playedShopName String @default("Bayshore") +} diff --git a/src/modules/game.ts b/src/modules/game.ts index 7f8e5ae..5ac9c82 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -399,6 +399,92 @@ export default class GameModule extends Module { } } } + + let saveExGhostHistory: any = {}; + if (body.car?.carId !== null && body.car?.carId !== undefined) { + saveExGhostHistory.carId = body.car?.carId!; + } + if (body.car?.tunePower !== null && body.car?.tunePower !== undefined) { + saveExGhostHistory.tunePower = body.car?.tunePower!; + } + if (body.car?.tuneHandling !== null && body.car?.tuneHandling !== undefined) { + saveExGhostHistory.tuneHandling = body.car?.tuneHandling!; + } + for(let i=0; i