diff --git a/src/modules/cars.ts b/src/modules/cars.ts index 149e4cc..046f42d 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -103,6 +103,8 @@ export default class CarModule extends Module { if(checkRegisteredGhost) { + console.log('OCM Ghost Registered From Terminal'); + let getNo1OCM = await prisma.oCMTally.findFirst({ where:{ competitionId: ocmEventDate.competitionId, @@ -115,12 +117,10 @@ export default class CarModule extends Module { if(getNo1OCM) { - let carId = getNo1OCM.carId - // Get Car Data let cars = await prisma.car.findFirst({ where:{ - carId: carId + carId: getNo1OCM.carId }, include:{ gtWing: true, @@ -131,25 +131,33 @@ export default class CarModule extends Module { // Get Ghost Trail let ghostTrailNo1 = await prisma.oCMTop1GhostTrail.findFirst({ where:{ - carId: carId, - competitionId: ocmEventDate.competitionId, - periodId: 999999999 + carId: getNo1OCM.carId, + competitionId: ocmEventDate.competitionId + }, + orderBy:{ + dbId: 'asc' } }); - trailIdNo1 = ghostTrailNo1!.dbId; + if(ghostTrailNo1) + { + console.log('Getting registered ghost trail'); - 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 - }); + 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/ghost.ts b/src/modules/ghost.ts index 2cd5a09..1711e2f 100644 --- a/src/modules/ghost.ts +++ b/src/modules/ghost.ts @@ -76,7 +76,8 @@ export default class GhostModule extends Module { // Get all of the friend cars for the carId provided let stampTargets = await prisma.carStampTarget.findMany({ where: { - stampTargetCarId: body.carId + stampTargetCarId: body.carId, + locked: false } }); @@ -177,7 +178,8 @@ export default class GhostModule extends Module { // Get all of the friend cars for the carId provided let stampTargets = await prisma.carStampTarget.findMany({ where: { - carId: body.carId + stampTargetCarId: body.carId, + locked: false } }); @@ -187,7 +189,7 @@ export default class GhostModule extends Module { { let carTarget = await prisma.car.findFirst({ where:{ - carId: stampTargets[i].stampTargetCarId + carId: stampTargets[i].carId }, include:{ gtWing: true,