diff --git a/src/modules/cars/functions.ts b/src/modules/cars/functions.ts index 5d0afad..9dceee9 100644 --- a/src/modules/cars/functions.ts +++ b/src/modules/cars/functions.ts @@ -28,14 +28,66 @@ export async function getCar(carId: number) } }); - // Error handling if ghostLevel accidentally set to 0 or more than 10 - if(car!.ghostLevel < 1) + // Error handling if car tune is more than 34 game default + if(car!.tunePower + car!.tuneHandling > 34) { - car!.ghostLevel = 1; + car!.tunePower = 17; + car!.tuneHandling = 17; + + await prisma.car.update({ + where: { + carId: car!.carId + }, + data: { + tunePower: 17, + tuneHandling: 17 + } + }); } - if(car!.ghostLevel > 11) - { - car!.ghostLevel = 10; + + // Error handling if ghostLevel accidentally set to 0 or more than 11 + if (car!.ghostLevel < 1) + { + car!.ghostLevel = 1; + + await prisma.car.update({ + where: { + carId: car!.carId + }, + data: { + ghostLevel: 1 + } + }); + } + + if (car!.ghostLevel > 12) + { + if(car!.rgWinCount > 1000) + { + car!.ghostLevel = 11; + + await prisma.car.update({ + where: { + carId: car!.carId + }, + data: { + ghostLevel: 11 + } + }); + } + else + { + car!.ghostLevel = 10; + + await prisma.car.update({ + where: { + carId: car!.carId + }, + data: { + ghostLevel: 10 + } + }); + } } // Convert the database lose bits to a Long diff --git a/src/modules/game.ts b/src/modules/game.ts index 811135a..7834a24 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -239,7 +239,8 @@ export default class GameModule extends Module { // Check retire crown let getCarCrown = await prisma.carCrownDetect.findFirst({ where:{ - carId: body.carId + carId: body.carId, + playedAt: body.playedAt, } }); diff --git a/src/modules/game/ghost.ts b/src/modules/game/ghost.ts index 02f0cc3..763ce13 100644 --- a/src/modules/game/ghost.ts +++ b/src/modules/game/ghost.ts @@ -49,6 +49,12 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ } } + // Error handling for equiping GT Wing in game after race + if(cars.wing > 127) + { + cars.wing = 127 + } + // Car update data dataCar = { wheel: common.sanitizeInput(cars.wheel), @@ -298,32 +304,76 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ // Crown holder data available if(carCrowns) { - // Crown Finish Status - await prisma.carCrownDetect.create({ - data:{ + // Look For Existing Car Record Based On Area + let areaRecord = await prisma.carCrownDetect.findFirst({ + where: { carId: body.carId, - status: 'finish', - area: carCrowns.area, - ramp: carCrowns.ramp, - path: carCrowns.path, - playedAt: carCrowns.playedAt, - tunePower: carCrowns.tunePower, - tuneHandling: carCrowns.tuneHandling + area: area } }); - // Update it to the new one - await prisma.carCrown.update({ - where: { - dbId: carCrowns.dbId - }, - data: { - ...dataCrown, - area: area, - ramp: ramp, - path: path - } - }); + // Record exist, update it + if(areaRecord) + { + // Update the record to Crown Finish Status + await prisma.carCrownDetect.update({ + where: { + id: areaRecord.id + }, + data: { + carId: body.carId, + status: 'finish', + area: carCrowns.area, + ramp: carCrowns.ramp, + path: carCrowns.path, + playedAt: carCrowns.playedAt, + tunePower: carCrowns.tunePower, + tuneHandling: carCrowns.tuneHandling + } + }); + + // Update it to the new one + await prisma.carCrown.update({ + where: { + dbId: carCrowns.dbId + }, + data: { + ...dataCrown, + area: area, + ramp: ramp, + path: path + } + }); + } + else + { + // Crown Finish Status + await prisma.carCrownDetect.create({ + data:{ + carId: body.carId, + status: 'finish', + area: carCrowns.area, + ramp: carCrowns.ramp, + path: carCrowns.path, + playedAt: carCrowns.playedAt, + tunePower: carCrowns.tunePower, + tuneHandling: carCrowns.tuneHandling + } + }); + + // Update it to the new one + await prisma.carCrown.update({ + where: { + dbId: carCrowns.dbId + }, + data: { + ...dataCrown, + area: area, + ramp: ramp, + path: path + } + }); + } } // Crown holder data not available or still default crown holder data else @@ -676,7 +726,8 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ await prisma.carCrownDetect.create({ data:{ carId: body.carId, - status: 'retire' + status: 'retire', + playedAt: body.playedAt } }); } diff --git a/src/modules/game/versus.ts b/src/modules/game/versus.ts index 1746051..961e9e8 100644 --- a/src/modules/game/versus.ts +++ b/src/modules/game/versus.ts @@ -12,15 +12,30 @@ export async function saveVersusBattleResult(body: wm.protobuf.SaveGameResultReq { if (!(body.retired)) { + // Get the car + let cars = body?.car; + // Get the vs result for the car let vsResult = body?.vsResult; // vs result is set - if (vsResult) + if (cars && vsResult) { // vs result update data let data : any = { + wheel: common.sanitizeInput(cars.wheel), + wheelColor: common.sanitizeInput(cars.wheelColor), + aero: common.sanitizeInput(cars.aero), + bonnet: common.sanitizeInput(cars.bonnet), + wing: common.sanitizeInput(cars.wing), + mirror: common.sanitizeInput(cars.mirror), + neon: common.sanitizeInput(cars.neon), + trunk: common.sanitizeInput(cars.trunk), + plate: common.sanitizeInput(cars.plate), + plateColor: common.sanitizeInput(cars.plateColor), + plateNumber: common.sanitizeInput(cars.plateNumber), vsPlayCount: common.sanitizeInput(vsResult.vsPlayCount), + aura: common.sanitizeInput(cars.aura), vsBurstCount: common.sanitizeInput(vsResult.vsBurstCount), vsStarCount: common.sanitizeInputNotZero(vsResult.vsStarCount), vsCoolOrWild: common.sanitizeInput(vsResult.vsCoolOrWild), @@ -44,6 +59,23 @@ export async function saveVersusBattleResult(body: wm.protobuf.SaveGameResultReq }, data: data }); + + // GT Wing stuff + let dataGTWing: any = { + pillar: common.sanitizeInput(body.car?.gtWing?.pillar), + pillarMaterial: common.sanitizeInput(body.car?.gtWing?.pillarMaterial), + mainWing: common.sanitizeInput(body.car?.gtWing?.mainWing), + mainWingColor: common.sanitizeInput(body.car?.gtWing?.mainWingColor), + wingTip: common.sanitizeInput(body.car?.gtWing?.wingTip), + material: common.sanitizeInput(body.car?.gtWing?.material), + }; + + await prisma.carGTWing.update({ + where: { + dbId: body.carId + }, + data: dataGTWing + }); } } } \ No newline at end of file diff --git a/src/modules/ghost/ghost_ocm.ts b/src/modules/ghost/ghost_ocm.ts index 603fe6f..e20a24c 100644 --- a/src/modules/ghost/ghost_ocm.ts +++ b/src/modules/ghost/ghost_ocm.ts @@ -589,9 +589,9 @@ export async function ocmGiveNamePlateReward(competitionId: number) let participantLength = getCarParticipant.length; // Participant is more than certain number (100 is default) - if(participantLength > 50) + if(participantLength > 100) { - participantLength = 50; + participantLength = 100; } // 16th - C1 diff --git a/src/modules/ghost_ocm.ts b/src/modules/ghost_ocm.ts index 39f4b61..9c6d5fe 100644 --- a/src/modules/ghost_ocm.ts +++ b/src/modules/ghost_ocm.ts @@ -518,7 +518,7 @@ export default class GhostModule extends Module { cars = wm.wm.protobuf.Car.create({ carId: 999999999, // Don't change this name: 'S660', - regionId: 18, // IDN (福井) + regionId: Math.floor(Math.random() * 47) + 1, // Random Region, old code -> // 18, // IDN (福井) manufacturer: 12, // HONDA model: 105, // S660 [JW5] visualModel: 130, // S660 [JW5] @@ -545,7 +545,7 @@ export default class GhostModule extends Module { title: 'Don\'t have S660?', level: 65, // SSSSS lastPlayedAt: checkGhostTrail!.playedAt, - country: 'IDN', + country: 'JPN', // Change to JPN, old code -> 'IDN', lastPlayedPlace: playedPlace });