diff --git a/src/modules/cars.ts b/src/modules/cars.ts index a266f7c..c4d0434 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -107,7 +107,7 @@ export default class CarModule extends Module { let additionalInsert = getCarTune.additionalInsert; // Check created car and item used - let checkCreatedCars = await carFunctions.checkCreatedCar(body, itemId); + let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert, itemId); if(checkCreatedCars.cheated === true) { let msg = { diff --git a/src/modules/cars/functions.ts b/src/modules/cars/functions.ts index ac815ee..5d0afad 100644 --- a/src/modules/cars/functions.ts +++ b/src/modules/cars/functions.ts @@ -28,66 +28,14 @@ export async function getCar(carId: number) } }); - // Error handling if car tune is more than 34 game default - if(car!.tunePower + car!.tuneHandling > 34) + // Error handling if ghostLevel accidentally set to 0 or more than 10 + if(car!.ghostLevel < 1) { - car!.tunePower = 17; - car!.tuneHandling = 17; - - await prisma.car.update({ - where: { - carId: car!.carId - }, - data: { - tunePower: 17, - tuneHandling: 17 - } - }); - } - - // 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 - } - }); - } + if(car!.ghostLevel > 11) + { + car!.ghostLevel = 10; } // Convert the database lose bits to a Long @@ -702,8 +650,8 @@ export async function updateCarCustomWing(body: wm.protobuf.UpdateCarRequest) } -// Check Create Car -export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, itemId: number) +// Remove Used Ticket +export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any, itemId: number) { let cheated: boolean = false; @@ -756,7 +704,7 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, itemId // Check if user item id is not set and its a special car for(let i=0; i 15) { cheated = true; } } - else if(body.car.visualModel! === 130) + else if(car.visualModel === 130) { if(itemId < 22 || itemId > 27) { cheated = true; } } - else if(body.car.visualModel! === 131) + else if(car.visualModel === 131) { if(itemId < 28 || itemId > 36) { cheated = true; } } - else if(body.car.visualModel! === 137) + else if(car.visualModel === 137) { if(itemId !== 37) { cheated = true; } } - else if(body.car.visualModel! === 138) + else if(car.visualModel === 138) { if(itemId !== 39) { cheated = true; } } - else if(body.car.visualModel! === 139) + else if(car.visualModel === 139) { if(itemId !== 38) { cheated = true; } } - else if(body.car.visualModel! > 144) + else if(car.visualModel > 144) { cheated = true; } diff --git a/src/modules/game.ts b/src/modules/game.ts index 7834a24..811135a 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -239,8 +239,7 @@ export default class GameModule extends Module { // Check retire crown let getCarCrown = await prisma.carCrownDetect.findFirst({ where:{ - carId: body.carId, - playedAt: body.playedAt, + carId: body.carId } }); diff --git a/src/modules/game/ghost.ts b/src/modules/game/ghost.ts index db5e358..02f0cc3 100644 --- a/src/modules/game/ghost.ts +++ b/src/modules/game/ghost.ts @@ -49,15 +49,8 @@ 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 = { - name: common.sanitizeInput(cars.name), wheel: common.sanitizeInput(cars.wheel), wheelColor: common.sanitizeInput(cars.wheelColor), aero: common.sanitizeInput(cars.aero), @@ -305,76 +298,32 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ // Crown holder data available if(carCrowns) { - // Look For Existing Car Record Based On Area - let areaRecord = await prisma.carCrownDetect.findFirst({ - where: { + // Crown Finish Status + await prisma.carCrownDetect.create({ + data:{ carId: body.carId, - area: area + status: 'finish', + area: carCrowns.area, + ramp: carCrowns.ramp, + path: carCrowns.path, + playedAt: carCrowns.playedAt, + tunePower: carCrowns.tunePower, + tuneHandling: carCrowns.tuneHandling } }); - // 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 - } - }); - } + // 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 @@ -727,8 +676,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ await prisma.carCrownDetect.create({ data:{ carId: body.carId, - status: 'retire', - playedAt: body.playedAt + status: 'retire' } }); } diff --git a/src/modules/game/versus.ts b/src/modules/game/versus.ts index 0c80130..1746051 100644 --- a/src/modules/game/versus.ts +++ b/src/modules/game/versus.ts @@ -12,31 +12,15 @@ 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 (cars && vsResult) + if (vsResult) { // vs result update data let data : any = { - name: common.sanitizeInput(cars.name), - 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), @@ -60,23 +44,6 @@ 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 e20a24c..603fe6f 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 > 100) + if(participantLength > 50) { - participantLength = 100; + participantLength = 50; } // 16th - C1 diff --git a/src/modules/ghost_ocm.ts b/src/modules/ghost_ocm.ts index 9c6d5fe..39f4b61 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: Math.floor(Math.random() * 47) + 1, // Random Region, old code -> // 18, // IDN (福井) + regionId: 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: 'JPN', // Change to JPN, old code -> 'IDN', + country: 'IDN', lastPlayedPlace: playedPlace });