From 1ea17a1abf9d845ac64bc09e546c8351b48d5c88 Mon Sep 17 00:00:00 2001 From: ghkkk090 Date: Mon, 12 Sep 2022 12:35:50 +0700 Subject: [PATCH] hopefully fix ocm HoF --- src/api.ts | 12 ++++++------ src/modules/cars.ts | 38 +++++++++++++++++++++++++++++++++++--- src/modules/users.ts | 7 ++++++- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/api.ts b/src/api.ts index 33e99ad..497219b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -10,10 +10,12 @@ export default class ApiModule extends Module { extended: true })); + app.use(express.json({ type: '*/*' })); + // API Get Requests // Get Current Competition Id app.get('/api/get_competition_id', async (req, res) => { @@ -51,9 +53,6 @@ export default class ApiModule extends Module { if(ocmEventDate) { message.competitionId = ocmEventDate.competitionId; - - // Send the response to the client - res.send(message); } else{ ocmEventDate = await prisma.oCMEvent.findFirst({ @@ -66,12 +65,13 @@ export default class ApiModule extends Module { }); message.competitionId = ocmEventDate!.competitionId; - - // Send the response to the client - res.send(message); } + + // Send the response to the client + res.send(message); }); + // Get Competition Ranking app.get('/api/get_competition_ranking', async (req, res) => { diff --git a/src/modules/cars.ts b/src/modules/cars.ts index 2ba98dd..3859d44 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -37,10 +37,12 @@ export default class CarModule extends Module { }); // Error handling if ghostLevel accidentally set to 0 or more than 10 - if(car!.ghostLevel < 1){ + if(car!.ghostLevel < 1) + { car!.ghostLevel = 1; } - if(car!.ghostLevel > 11){ + if(car!.ghostLevel > 11) + { car!.ghostLevel = 10; } @@ -160,7 +162,37 @@ export default class CarModule extends Module { trailId: trailIdNo1 }); } - + else + { + ghostTrailNo1 = await prisma.oCMGhostTrail.findFirst({ + where:{ + carId: getNo1OCM.carId, + competitionId: ocmEventDate.competitionId + }, + orderBy:{ + playedAt: 'desc' + } + }); + + if(ghostTrailNo1) + { + console.log('Getting registered ghost trail from other table'); + + trailIdNo1 = ghostTrailNo1.dbId; + + ghostCarsNo1 = wm.wm.protobuf.GhostCar.create({ + car: { + ...cars!, + }, + area: ghostTrailNo1.area, + ramp: ghostTrailNo1.ramp, + path: ghostTrailNo1.path, + nonhuman: false, + type: wm.wm.protobuf.GhostType.GHOST_NORMAL, + trailId: trailIdNo1 + }); + } + } } } } diff --git a/src/modules/users.ts b/src/modules/users.ts index 036f88f..db8e421 100644 --- a/src/modules/users.ts +++ b/src/modules/users.ts @@ -487,7 +487,8 @@ export default class UserModule extends Module { { let checkRegisteredGhost = await prisma.ghostRegisteredFromTerminal.findFirst({ where:{ - carId: user.cars[i].carId + carId: user.cars[i].carId, + competitionId: ocmEventDate.competitionId } }); @@ -495,6 +496,10 @@ export default class UserModule extends Module { { carStates[i].hasOpponentGhost = true; } + else + { + carStates[i].hasOpponentGhost = false; + } } } }