1
0
mirror of synced 2024-12-05 03:27:57 +01:00

Merge pull request #80 from anthonyng43/master

allow player rename
This commit is contained in:
Sylvie Nightshade 2024-08-22 21:03:18 +01:00 committed by GitHub
commit db68d107b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 185 additions and 47 deletions

View File

@ -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, carInsert, itemId);
let checkCreatedCars = await carFunctions.checkCreatedCar(body, itemId);
if(checkCreatedCars.cheated === true)
{
let msg = {

View File

@ -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
@ -650,8 +702,8 @@ export async function updateCarCustomWing(body: wm.protobuf.UpdateCarRequest)
}
// Remove Used Ticket
export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any, itemId: number)
// Check Create Car
export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, itemId: number)
{
let cheated: boolean = false;
@ -704,7 +756,7 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
// Check if user item id is not set and its a special car
for(let i=0; i<allCarVisualModel.length; i++)
{
if(!(body.userItemId) && car.visualModel === allCarVisualModel[i])
if(!(body.userItemId) && body.car.visualModel === allCarVisualModel[i])
{
cheated = true;
@ -715,7 +767,7 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
// Check if user item id is set and its a special car cannot be created from ticket
for(let i=0; i<carVisualModelWithoutItem.length; i++)
{
if(body.userItemId && car.visualModel === carVisualModelWithoutItem[i])
if(body.userItemId && body.car.visualModel! === carVisualModelWithoutItem[i])
{
cheated = true;
@ -724,49 +776,49 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
}
// Check if user item id is set and its a special car created from ticket
if(car.visualModel === 122)
if(body.car.visualModel! === 122)
{
if(itemId < 7 || itemId > 15)
{
cheated = true;
}
}
else if(car.visualModel === 130)
else if(body.car.visualModel! === 130)
{
if(itemId < 22 || itemId > 27)
{
cheated = true;
}
}
else if(car.visualModel === 131)
else if(body.car.visualModel! === 131)
{
if(itemId < 28 || itemId > 36)
{
cheated = true;
}
}
else if(car.visualModel === 137)
else if(body.car.visualModel! === 137)
{
if(itemId !== 37)
{
cheated = true;
}
}
else if(car.visualModel === 138)
else if(body.car.visualModel! === 138)
{
if(itemId !== 39)
{
cheated = true;
}
}
else if(car.visualModel === 139)
else if(body.car.visualModel! === 139)
{
if(itemId !== 38)
{
cheated = true;
}
}
else if(car.visualModel > 144)
else if(body.car.visualModel! > 144)
{
cheated = true;
}

View File

@ -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,
}
});

View File

@ -49,8 +49,15 @@ 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),
@ -298,32 +305,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 +727,8 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
await prisma.carCrownDetect.create({
data:{
carId: body.carId,
status: 'retire'
status: 'retire',
playedAt: body.playedAt
}
});
}

View File

@ -12,15 +12,31 @@ 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 = {
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),
@ -44,6 +60,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
});
}
}
}

View File

@ -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

View File

@ -518,7 +518,7 @@ export default class GhostModule extends Module {
cars = wm.wm.protobuf.Car.create({
carId: 999999999, // Don't change this
name: '',
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
});