1
0
mirror of synced 2024-12-04 19:17:58 +01:00

get ghost trail req but saving still broken

This commit is contained in:
ghkkk090 2022-07-29 19:37:45 +07:00
parent b4a8a33674
commit c6fb8434e4
5 changed files with 173 additions and 31 deletions

View File

@ -0,0 +1,27 @@
/*
Warnings:
- The `trail` column on the `CarCrown` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
-- AlterTable
ALTER TABLE "CarCrown" DROP COLUMN "trail",
ADD COLUMN "trail" BIGINT[];
-- CreateTable
CREATE TABLE "GhostTrail" (
"dbId" SERIAL NOT NULL,
"carId" INTEGER NOT NULL,
"area" INTEGER NOT NULL,
"ramp" INTEGER NOT NULL,
"path" INTEGER NOT NULL,
"trail" BIGINT[],
CONSTRAINT "GhostTrail_pkey" PRIMARY KEY ("dbId")
);
-- AddForeignKey
ALTER TABLE "GhostTrail" ADD CONSTRAINT "GhostTrail_carId_fkey" FOREIGN KEY ("carId") REFERENCES "Car"("carId") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,29 @@
/*
Warnings:
- Changed the type of `trail` on the `CarCrown` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
- Added the required column `driveData` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Added the required column `playedAt` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Added the required column `time` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Added the required column `trendBinaryByArea` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Added the required column `tuneHandling` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Added the required column `tunePower` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
- Changed the type of `trail` on the `GhostTrail` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
-- AlterTable
ALTER TABLE "CarCrown" DROP COLUMN "trail",
ADD COLUMN "trail" BIGINT NOT NULL;
-- AlterTable
ALTER TABLE "GhostTrail" ADD COLUMN "driveData" BYTEA NOT NULL,
ADD COLUMN "playedAt" INTEGER NOT NULL,
ADD COLUMN "time" INTEGER NOT NULL,
ADD COLUMN "trendBinaryByArea" BYTEA NOT NULL,
ADD COLUMN "tuneHandling" INTEGER NOT NULL,
ADD COLUMN "tunePower" INTEGER NOT NULL,
DROP COLUMN "trail",
ADD COLUMN "trail" BIGINT NOT NULL;

View File

@ -29,7 +29,7 @@ model ScratchSheet {
id Int @id @default(autoincrement())
User User @relation(fields: [userId], references: [id])
userId Int
sheetNo Int // Player's sheet number (i.e. first sheet)
sheetNo Int // Player's sheet number (i.e. first sheet)
squares ScratchSquare[]
}
@ -124,25 +124,26 @@ model Car {
stConsecutiveWinsMax Int @default(0)
stCompleted100Episodes Boolean @default(false)
items CarItem[]
carGTWingDbId Int @unique
gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId])
carStateDbId Int @unique
state CarState @relation(fields: [carStateDbId], references: [dbId])
TimeAttackRecord TimeAttackRecord[]
CarCrown CarCrown[]
items CarItem[]
carGTWingDbId Int @unique
gtWing CarGTWing @relation(fields: [carGTWingDbId], references: [dbId])
carStateDbId Int @unique
state CarState @relation(fields: [carStateDbId], references: [dbId])
TimeAttackRecord TimeAttackRecord[]
CarCrown CarCrown[]
GhostTrail GhostTrail[]
}
model CarGTWing {
dbId Int @id @default(autoincrement())
car Car?
dbId Int @id @default(autoincrement())
car Car?
pillar Int @default(0)
pillarMaterial Int @default(0)
mainWing Int @default(0)
mainWingColor Int @default(0)
wingTip Int @default(0)
material Int @default(0)
pillar Int @default(0)
pillarMaterial Int @default(0)
mainWing Int @default(0)
mainWingColor Int @default(0)
wingTip Int @default(0)
material Int @default(0)
}
model CarItem {
@ -155,8 +156,8 @@ model CarItem {
}
model CarSettings {
dbId Int @id @default(autoincrement())
car Car?
dbId Int @id @default(autoincrement())
car Car?
view Boolean @default(true)
transmission Boolean @default(false)
@ -171,8 +172,8 @@ model CarSettings {
}
model CarState {
dbId Int @id @default(autoincrement())
car Car?
dbId Int @id @default(autoincrement())
car Car?
hasOpponentGhost Boolean @default(false)
eventJoined Boolean @default(false)
@ -181,12 +182,12 @@ model CarState {
}
model TimeAttackRecord {
dbId Int @id @default(autoincrement())
dbId Int @id @default(autoincrement())
car Car @relation(fields: [carId], references: [carId])
carId Int
car Car @relation(fields: [carId], references: [carId])
carId Int
model Int // Car model, literally just the `model` field from Car
model Int // Car model, literally just the `model` field from Car
time Int
course Int
isMorning Boolean
@ -202,14 +203,30 @@ model TimeAttackRecord {
}
model CarCrown {
dbId Int @id @default(autoincrement())
car Car @relation(fields: [carId], references: [carId])
dbId Int @id @default(autoincrement())
car Car @relation(fields: [carId], references: [carId])
carId Int
area Int @unique
area Int @unique
ramp Int
path Int
trail BigInt @default(0)
playedAt Int @default(0)
trail BigInt
playedAt Int @default(0)
tunePower Int
tuneHandling Int
}
model GhostTrail {
dbId Int @id @default(autoincrement())
car Car @relation(fields: [carId], references: [carId])
carId Int
area Int
ramp Int
path Int
trail BigInt
time Int
driveData Bytes @db.ByteA
trendBinaryByArea Bytes @db.ByteA
tunePower Int
tuneHandling Int
playedAt Int
}

View File

@ -23,6 +23,7 @@ export default class GameModule extends Module {
}
});
let storyLose: boolean = false;
let ghostModePlay: boolean = false;
switch (body.gameMode) {
case wm.wm.protobuf.GameMode.MODE_STORY:
{
@ -199,6 +200,7 @@ export default class GameModule extends Module {
case wm.wm.protobuf.GameMode.MODE_GHOST_BATTLE:
{
if (!(body.retired)) {
ghostModePlay = true;
let saveEx: any = {};
if (body.rgResult?.rgRegionMapScore !== null && body.rgResult?.rgRegionMapScore !== undefined) {
saveEx.rgRegionMapScore = body.rgResult?.rgRegionMapScore!;
@ -685,9 +687,19 @@ export default class GameModule extends Module {
});
}
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
let msg;
if(ghostModePlay === true){
msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
ghostSessionId: Math.floor(Math.random() * 1000) + 1
}
}
else{
msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS
}
}
let resp = wm.wm.protobuf.SaveGameResultResponse.encode(msg);
let end = resp.finish();
let r = res
@ -698,6 +710,62 @@ export default class GameModule extends Module {
r.send(Buffer.from(end));
})
app.post('/method/register_ghost_trail', async (req, res) => {
let body = wm.wm.protobuf.RegisterGhostTrailRequest.decode(req.body);
console.log(body);
//-----------------SAVING STILL NOT WORKING-----------------
let saveEx: any = {};
saveEx.carId = body.ghost!.car.carId;
if(body.ghost?.area !== null && body.ghost?.area !== undefined){
saveEx.area = body.ghost?.area!;
}
if(body.ghost?.ramp !== null && body.ghost?.ramp !== undefined){
saveEx.ramp = body.ghost?.ramp!;
}
if(body.ghost?.path !== null && body.ghost?.path !== undefined){
saveEx.path = body.ghost?.path!;
}
if(body.trail !== null && body.trail !== undefined){
saveEx.trail = body.trail!;
}
if(body.time !== null && body.time !== undefined){
saveEx.time = body.time!;
}
if(body.driveData !== null && body.driveData !== undefined){
saveEx.driveData = body.driveData!;
}
if(body.trendBinaryByArea !== null && body.trendBinaryByArea !== undefined){
saveEx.trendBinaryByArea = body.trendBinaryByArea!;
}
if(body.trendBinaryByArea !== null && body.trendBinaryByArea !== undefined){
saveEx.trendBinaryByArea = body.trendBinaryByArea!;
}
if(body.ghost?.car.tunePower !== null && body.ghost?.car.tunePower !== undefined){
saveEx.tunePower = body.ghost?.car.tunePower!;
}
if(body.ghost?.car.tuneHandling !== null && body.ghost?.car.tuneHandling !== undefined){
saveEx.tuneHandling = body.ghost?.car.tuneHandling!;
}
await prisma.carCrown.create({
data: saveEx
});
//----------------------------------------------------------
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS
}
let resp = wm.wm.protobuf.RegisterGhostTrailResponse.encode(msg);
let end = resp.finish();
let r = res
.header('Server', 'v388 wangan')
.header('Content-Type', 'application/x-protobuf; revision=8053')
.header('Content-Length', end.length.toString())
.status(200);
r.send(Buffer.from(end));
})
app.post('/method/load_user', async (req, res) => {
let body = wm.wm.protobuf.LoadUserRequest.decode(req.body);

View File

@ -329,6 +329,7 @@ export default class StartupModule extends Module {
unlockAt: 0,
}));
}
break
}
}
else{