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

fix HoF always picking last opponent bug

This commit is contained in:
Shiroi Kitsu 2023-01-03 14:16:50 +07:00
parent 70f4455784
commit 7952897e61
4 changed files with 57 additions and 27 deletions

View File

@ -716,11 +716,45 @@ export default class GhostModule extends Module {
// Get the trail data
let ghost_trails = await ghost_trail.getOCMGhostTrail(pCarId, pTrailId);
pArea = ghost_trails.areaVal;
rampVal = ghost_trails.rampVal;
pathVal = ghost_trails.pathVal;
playedAt = ghost_trails.playedAt;
ghostTrail = ghost_trails.ghostTrail;
// Qualifiers or Main Draw OCM
if(ghost_trails.ghostFound === true)
{
pArea = ghost_trails.areaVal;
rampVal = ghost_trails.rampVal;
pathVal = ghost_trails.pathVal;
playedAt = ghost_trails.playedAt;
ghostTrail = ghost_trails.ghostTrail;
}
// HoF OCM
else
{
console.log("Getting HoF Ghost Trail")
let ghost_trail = await prisma.oCMTop1GhostTrail.findFirst({
where:{
dbId: pTrailId
}
});
if(ghost_trail)
{
pArea = ghost_trail.area;
rampVal = ghost_trail.ramp;
pathVal = ghost_trail.path;
playedAt = ghost_trail.playedAt;
ghostTrail = ghost_trail.trail;
}
// HoF Not Found
else
{
pArea = ghost_trails.areaVal;
rampVal = ghost_trails.rampVal;
pathVal = ghost_trails.pathVal;
playedAt = ghost_trails.playedAt;
ghostTrail = ghost_trails.ghostTrail;
}
}
}
// Query parameter from Crown Ghost Battle available
else

View File

@ -423,7 +423,7 @@ export default class GhostModule extends Module {
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: [
{
dbId: 'desc'
competitionId: 'desc'
},
],
});
@ -704,7 +704,8 @@ export default class GhostModule extends Module {
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
competitionId: competition_id,
ghostCar: ghostCars!,
specialGhostId: competition_id,
ghostCar: ghostCars,
trailId: ghostTrailId,
updatedAt: date,
competitionSchedule: competitionSchedule || null

View File

@ -907,13 +907,16 @@ export default class TerminalModule extends Module {
// Get the information from the request
let body = wm.wm.protobuf.RegisterOpponentGhostRequest.decode(req.body);
let ocmEventDate = await prisma.oCMEvent.findFirst({
let getHoFCarId = await prisma.oCMTop1Ghost.findFirst({
where:{
competitionId: body.specialGhostId,
},
orderBy: {
competitionEndAt: 'desc',
periodId: 'desc',
}
});
if(ocmEventDate)
if(getHoFCarId)
{
let checkRegisteredGhost = await prisma.ghostRegisteredFromTerminal.findFirst({
where:{
@ -921,23 +924,13 @@ export default class TerminalModule extends Module {
}
});
let getNo1OCM = await prisma.oCMTally.findFirst({
where:{
competitionId: ocmEventDate.competitionId,
periodId: 999999999
},
orderBy:{
competitionId: 'desc'
}
});
if(!(checkRegisteredGhost))
{
await prisma.ghostRegisteredFromTerminal.create({
data:{
carId: body.carId,
competitionId: ocmEventDate!.competitionId,
opponentCarId: getNo1OCM!.carId
competitionId: body.specialGhostId,
opponentCarId: getHoFCarId.carId,
}
});
@ -951,15 +944,13 @@ export default class TerminalModule extends Module {
},
data:{
carId: body.carId,
competitionId: ocmEventDate!.competitionId,
opponentCarId: getNo1OCM!.carId
competitionId: body.specialGhostId,
opponentCarId: getHoFCarId.carId,
}
});
console.log('Updating Register Ghost Opponent entry')
}
}
// Response data

View File

@ -98,6 +98,7 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
let pathVal = 0;
let playedAt = 0;
let ghostTrail;
let ghostFound: boolean = false;
// Trails data for certain area is available
if(ghost_trails)
@ -118,6 +119,9 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
// Set to OCM trail data
ghostTrail = ghost_trails!.trail;
// Set OCM ghost trail found
ghostFound = true;
}
// Trails data for certain area is not available
else
@ -137,7 +141,7 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
ghostTrail = new Uint8Array([1, 2, 3, 4]);
}
return { areaVal, rampVal, pathVal, playedAt, ghostTrail }
return { areaVal, rampVal, pathVal, playedAt, ghostTrail, ghostFound }
}