fix if value is 0 will not update to db
This commit is contained in:
parent
aed96ce32b
commit
8d7b3909f6
@ -530,24 +530,24 @@ export default class CarModule extends Module {
|
||||
{
|
||||
// Car update data
|
||||
data = {
|
||||
customColor: cars.customColor || undefined,
|
||||
wheel: cars.wheel || undefined,
|
||||
wheelColor: cars.wheelColor || undefined,
|
||||
aero: cars.aero || undefined,
|
||||
bonnet: cars.bonnet || undefined,
|
||||
wing: cars.wing || undefined,
|
||||
mirror: cars.mirror || undefined,
|
||||
neon: cars.neon || undefined,
|
||||
trunk: cars.trunk || undefined,
|
||||
plate: cars.plate || undefined,
|
||||
plateColor: cars.plateColor || undefined,
|
||||
plateNumber: cars.plateNumber || undefined,
|
||||
windowSticker: cars.windowSticker || undefined,
|
||||
windowDecoration: cars.windowDecoration || undefined,
|
||||
rivalMarker: cars.rivalMarker || undefined,
|
||||
aura: cars.aura || undefined,
|
||||
auraMotif: cars.auraMotif || undefined,
|
||||
rgStamp: body?.rgStamp! || undefined,
|
||||
customColor: common.sanitizeInput(cars.customColor),
|
||||
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),
|
||||
windowSticker: common.sanitizeInput(cars.windowSticker),
|
||||
windowDecoration: common.sanitizeInput(cars.windowDecoration),
|
||||
rivalMarker: common.sanitizeInput(cars.rivalMarker),
|
||||
aura: common.sanitizeInput(cars.aura),
|
||||
auraMotif: common.sanitizeInput(cars.auraMotif),
|
||||
rgStamp: common.sanitizeInput(body.rgStamp),
|
||||
}
|
||||
|
||||
// Update the car info
|
||||
@ -634,12 +634,12 @@ export default class CarModule extends Module {
|
||||
if (gtWing)
|
||||
{
|
||||
let dataGTWing : any = {
|
||||
pillar: gtWing.pillar || undefined,
|
||||
pillarMaterial: gtWing.pillarMaterial || undefined,
|
||||
mainWing: gtWing.mainWing || undefined,
|
||||
mainWingColor: gtWing.mainWingColor || undefined,
|
||||
wingTip: gtWing.wingTip || undefined,
|
||||
material: gtWing.material || undefined,
|
||||
pillar: common.sanitizeInput(gtWing.pillar),
|
||||
pillarMaterial: common.sanitizeInput(gtWing.pillarMaterial),
|
||||
mainWing: common.sanitizeInput(gtWing.mainWing),
|
||||
mainWingColor: common.sanitizeInput(gtWing.mainWingColor),
|
||||
wingTip: common.sanitizeInput(gtWing.wingTip),
|
||||
material: common.sanitizeInput(gtWing.material),
|
||||
}
|
||||
|
||||
await prisma.carGTWing.update({
|
||||
|
@ -41,4 +41,8 @@ export function getBigIntFromLong(n: Long)
|
||||
|
||||
// Return the finished value
|
||||
return Number(bigInt);
|
||||
}
|
||||
|
||||
export function sanitizeInput(value: any){
|
||||
return (value == null || value == undefined) ? undefined : value;
|
||||
}
|
@ -3,8 +3,10 @@ import { prisma } from "../..";
|
||||
// Import Proto
|
||||
import { wm } from "../../wmmt/wm.proto";
|
||||
import wmproto from "../../wmmt/wm.proto";
|
||||
import * as ghost_history from "../games/games_util/ghost_history";
|
||||
|
||||
// Import Util
|
||||
import * as common from "../../util/common";
|
||||
import * as ghost_history from "../games/games_util/ghost_history";
|
||||
|
||||
// Save ghost battle result
|
||||
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
|
||||
@ -34,10 +36,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
{
|
||||
// Ghost update data
|
||||
dataGhost = {
|
||||
rgRegionMapScore: ghostResult.rgRegionMapScore || undefined,
|
||||
rgPlayCount: ghostResult.rgPlayCount || undefined,
|
||||
dressupLevel: ghostResult.dressupLevel || undefined,
|
||||
dressupPoint: ghostResult.dressupPoint || undefined,
|
||||
rgRegionMapScore: common.sanitizeInput(ghostResult.rgRegionMapScore),
|
||||
rgPlayCount: common.sanitizeInput(ghostResult.rgPlayCount),
|
||||
dressupLevel: common.sanitizeInput(ghostResult.dressupLevel),
|
||||
dressupPoint: common.sanitizeInput(ghostResult.dressupPoint),
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,18 +64,18 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
|
||||
// Car update data
|
||||
dataCar = {
|
||||
wheel: cars.wheel || undefined,
|
||||
wheelColor: cars.wheelColor || undefined,
|
||||
aero: cars.aero || undefined,
|
||||
bonnet: cars.bonnet || undefined,
|
||||
wing: cars.wing || undefined,
|
||||
mirror: cars.mirror || undefined,
|
||||
neon: cars.neon || undefined,
|
||||
trunk: cars.trunk || undefined,
|
||||
plate: cars.plate || undefined,
|
||||
plateColor: cars.plateColor || undefined,
|
||||
plateNumber: cars.plateNumber || undefined,
|
||||
ghostLevel: cars.ghostLevel || undefined,
|
||||
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),
|
||||
ghostLevel: common.sanitizeInput(cars.ghostLevel),
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,9 +207,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
// Ghost Crown update data
|
||||
dataCrown = {
|
||||
carId: carId,
|
||||
playedAt: body.playedAt || undefined,
|
||||
tunePower: body.car?.tunePower || undefined,
|
||||
tuneHandling: body.car?.tuneHandling || undefined,
|
||||
playedAt: common.sanitizeInput(body.playedAt),
|
||||
tunePower: common.sanitizeInput(body.car?.tunePower),
|
||||
tuneHandling: common.sanitizeInput(body.car?.tuneHandling),
|
||||
}
|
||||
|
||||
// Get the area id and ramp id
|
||||
|
@ -23,12 +23,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
|
||||
{
|
||||
// Story update data
|
||||
let data : any = {
|
||||
stClearDivCount: storyResult.stClearDivCount || undefined,
|
||||
stPlayCount: storyResult.stPlayCount || undefined,
|
||||
stClearCount: storyResult.stClearCount || undefined,
|
||||
stConsecutiveWins: storyResult.stConsecutiveWins || undefined,
|
||||
tuningPoints: storyResult.tuningPoint || 0,
|
||||
stCompleted100Episodes: storyResult.stCompleted_100Episodes || undefined,
|
||||
stClearDivCount: common.sanitizeInput(storyResult.stClearDivCount),
|
||||
stPlayCount: common.sanitizeInput(storyResult.stPlayCount),
|
||||
stClearCount: common.sanitizeInput(storyResult.stClearCount),
|
||||
stConsecutiveWins: common.sanitizeInput(storyResult.stConsecutiveWins),
|
||||
tuningPoints: common.sanitizeInput(storyResult.tuningPoint),
|
||||
stCompleted100Episodes: common.sanitizeInput(storyResult.stCompleted_100Episodes),
|
||||
}
|
||||
|
||||
// If the current consecutive wins is greater than the previous max
|
||||
@ -53,8 +53,7 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
|
||||
}
|
||||
|
||||
// Check if clearBits is not null, and not lose the story
|
||||
if (storyResult.stClearBits !== null && storyResult.stClearBits !== undefined
|
||||
&& data.stLoseBits === 0)
|
||||
if (common.sanitizeInput(storyResult.stClearBits) && data.stLoseBits === 0)
|
||||
{
|
||||
data.stClearBits = storyResult.stClearBits;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user