crown ghost saving work, ghost saving idk... no error handling yet
This commit is contained in:
parent
c6fb8434e4
commit
4eaea63a09
@ -1,29 +0,0 @@
|
||||
/*
|
||||
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;
|
@ -1,15 +1,8 @@
|
||||
/*
|
||||
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[];
|
||||
ALTER TABLE "CarCrown" ALTER COLUMN "trail" DROP DEFAULT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "GhostTrail" (
|
||||
@ -18,7 +11,13 @@ CREATE TABLE "GhostTrail" (
|
||||
"area" INTEGER NOT NULL,
|
||||
"ramp" INTEGER NOT NULL,
|
||||
"path" INTEGER NOT NULL,
|
||||
"trail" BIGINT[],
|
||||
"trail" BYTEA NOT NULL,
|
||||
"time" INTEGER,
|
||||
"driveData" BYTEA,
|
||||
"trendBinaryByArea" BYTEA,
|
||||
"tunePower" INTEGER NOT NULL,
|
||||
"tuneHandling" INTEGER NOT NULL,
|
||||
"playedAt" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "GhostTrail_pkey" PRIMARY KEY ("dbId")
|
||||
);
|
11
prisma/migrations/20220729152049_ghost_trail_2/migration.sql
Normal file
11
prisma/migrations/20220729152049_ghost_trail_2/migration.sql
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `crownBattle` to the `GhostTrail` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "GhostTrail" ADD COLUMN "crownBattle" BOOLEAN NOT NULL;
|
@ -222,11 +222,12 @@ model GhostTrail {
|
||||
area Int
|
||||
ramp Int
|
||||
path Int
|
||||
trail BigInt
|
||||
time Int
|
||||
driveData Bytes @db.ByteA
|
||||
trendBinaryByArea Bytes @db.ByteA
|
||||
trail Bytes
|
||||
time Int?
|
||||
driveData Bytes? @db.ByteA
|
||||
trendBinaryByArea Bytes? @db.ByteA
|
||||
tunePower Int
|
||||
tuneHandling Int
|
||||
playedAt Int
|
||||
crownBattle Boolean
|
||||
}
|
||||
|
@ -712,11 +712,14 @@ export default class GameModule extends Module {
|
||||
|
||||
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 crownBattles: boolean = false;
|
||||
if(body.trendBinaryByArea?.data === null && body.trendBinaryByArea?.data === undefined){
|
||||
crownBattles = true;
|
||||
}
|
||||
let saveEx: any = {};
|
||||
saveEx.carId = body.ghost!.car.carId;
|
||||
saveEx.carId = Number(body.ghost!.car.carId!);
|
||||
saveEx.crownBattle = crownBattles;
|
||||
if(body.ghost?.area !== null && body.ghost?.area !== undefined){
|
||||
saveEx.area = body.ghost?.area!;
|
||||
}
|
||||
@ -729,17 +732,19 @@ export default class GameModule extends Module {
|
||||
if(body.trail !== null && body.trail !== undefined){
|
||||
saveEx.trail = body.trail!;
|
||||
}
|
||||
if(body.time !== null && body.time !== undefined){
|
||||
saveEx.time = body.time!;
|
||||
if(crownBattles === false){
|
||||
if(body.time !== null && body.time !== undefined){
|
||||
saveEx.time = body.time!;
|
||||
}
|
||||
if(body.driveData?.data !== null && body.driveData?.data !== undefined){
|
||||
saveEx.driveData = body.driveData?.data!;
|
||||
}
|
||||
if(body.trendBinaryByArea?.data !== null && body.trendBinaryByArea?.data !== undefined){
|
||||
saveEx.trendBinaryByArea = body.trendBinaryByArea?.data!;
|
||||
}
|
||||
}
|
||||
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.lastPlayedAt !== null && body.ghost?.car.lastPlayedAt !== undefined){
|
||||
saveEx.playedAt = body.ghost?.car.lastPlayedAt!;
|
||||
}
|
||||
if(body.ghost?.car.tunePower !== null && body.ghost?.car.tunePower !== undefined){
|
||||
saveEx.tunePower = body.ghost?.car.tunePower!;
|
||||
@ -748,7 +753,7 @@ export default class GameModule extends Module {
|
||||
saveEx.tuneHandling = body.ghost?.car.tuneHandling!;
|
||||
}
|
||||
|
||||
await prisma.carCrown.create({
|
||||
await prisma.ghostTrail.create({
|
||||
data: saveEx
|
||||
});
|
||||
//----------------------------------------------------------
|
||||
@ -2477,6 +2482,14 @@ export default class GameModule extends Module {
|
||||
app.get('/resource/ghost_trail', async (req, res) => {
|
||||
let pCarId = Number(req.query.car_id);
|
||||
let pArea = Number(req.query.area);
|
||||
|
||||
let ghost_trails = await prisma.ghostTrail.findFirst({
|
||||
where: {
|
||||
carId: pCarId,
|
||||
area: pArea,
|
||||
crownBattle: true
|
||||
}
|
||||
});
|
||||
//---------------MAYBE NOT CORRECT---------------
|
||||
let rampVal = 0;
|
||||
let pathVal = 0;
|
||||
@ -2545,14 +2558,15 @@ export default class GameModule extends Module {
|
||||
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 trails = new Uint8Array([1, 2, 3, 4]); //wtf is this lmao
|
||||
|
||||
let msg = {
|
||||
carId: pCarId,
|
||||
area: pArea,
|
||||
ramp: rampVal,
|
||||
path: pathVal,
|
||||
playedAt: 0,
|
||||
trail: trails
|
||||
trail: new Uint8Array(ghost_trails!.trail)
|
||||
};
|
||||
//-----------------------------------------------
|
||||
let resp = wm.wm.protobuf.GhostTrail.encode(msg);
|
||||
@ -2564,5 +2578,9 @@ export default class GameModule extends Module {
|
||||
.status(200);
|
||||
r.send(Buffer.from(end));
|
||||
})
|
||||
|
||||
app.get('/method/load_paths_and_tunings', async (req, res) => {
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user