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

Merge pull request #34 from ghkkk090/master

fix story clear div count back to 0 agian
This commit is contained in:
Luna 2022-08-23 18:21:16 +01:00 committed by GitHub
commit 87bc26d25d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 39 deletions

View File

@ -45,4 +45,8 @@ export function getBigIntFromLong(n: Long)
export function sanitizeInput(value: any){
return (value == null || value == undefined) ? undefined : value;
}
export function sanitizeInputNotZero(value: any){
return (value !== null && value !== undefined && value !== 0) ? value : undefined;
}

View File

@ -23,19 +23,19 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
{
// Story update data
let data : any = {
stClearDivCount: common.sanitizeInput(storyResult.stClearDivCount),
stClearDivCount: common.sanitizeInputNotZero(storyResult.stClearDivCount),
stPlayCount: common.sanitizeInput(storyResult.stPlayCount),
stClearCount: common.sanitizeInput(storyResult.stClearCount),
stClearCount: common.sanitizeInputNotZero(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
if (body.stResult!.stConsecutiveWins! > car!.stConsecutiveWinsMax)
if (storyResult.stConsecutiveWins! > car!.stConsecutiveWinsMax)
{
// Update the maximum consecutive wins;
data.stConsecutiveWinsMax = body.stResult!.stConsecutiveWins!;
data.stConsecutiveWinsMax = storyResult.stConsecutiveWins;
}
// If the lose bits are set, and are long data

View File

@ -3,53 +3,39 @@ import { prisma } from "../..";
// Import Proto
import { wm } from "../../wmmt/wm.proto";
// Import Util
import * as common from "../common";
// Save versus battle result
export async function saveVersusBattleResult(body: wm.protobuf.SaveGameResultRequest)
export async function saveVersusBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
{
if (!(body.retired))
{
// Get the vs result for the car
let vsResult = body?.vsResult;
// storyResult is set
// vs result is set
if (vsResult)
{
// Check if vsTripleStarMedals is not 0
let vsTripleStarMedals = undefined;
if(vsResult.vsTripleStarMedals && vsResult.vsTripleStarMedals !== 0){
vsTripleStarMedals = vsResult.vsTripleStarMedals!;
}
// Check if vsDoubleStarMedals is not 0
let vsDoubleStarMedals = undefined;
if(vsResult.vsDoubleStarMedals && vsResult.vsDoubleStarMedals !== 0){
vsDoubleStarMedals = vsResult.vsDoubleStarMedals!;
}
// Check if vsSingleStarMedals is not 0
let vsSingleStarMedals = undefined;
if(vsResult.vsSingleStarMedals && vsResult.vsSingleStarMedals !== 0){
vsSingleStarMedals = vsResult.vsSingleStarMedals!;
}
// Check if vsPlainMedals is not 0
let vsPlainMedals = undefined;
if(vsResult.vsPlainMedals && vsResult.vsPlainMedals !== 0){
vsPlainMedals = vsResult.vsPlainMedals!;
}
// vs result update data
let data : any = {
vsPlayCount: vsResult.vsPlayCount || undefined,
vsBurstCount: vsResult.vsBurstCount || undefined,
vsStarCount: vsResult.vsStarCount || undefined,
vsCoolOrWild: vsResult.vsCoolOrWild || undefined,
vsSmoothOrRough: vsResult.vsSmoothOrRough || undefined,
vsTripleStarMedals: vsTripleStarMedals || undefined,
vsDoubleStarMedals: vsDoubleStarMedals || undefined,
vsSingleStarMedals: vsSingleStarMedals || undefined,
vsPlainMedals: vsPlainMedals || undefined,
vsPlayCount: common.sanitizeInput(vsResult.vsPlayCount),
vsBurstCount: common.sanitizeInput(vsResult.vsBurstCount),
vsStarCount: common.sanitizeInput(vsResult.vsStarCount),
vsCoolOrWild: common.sanitizeInput(vsResult.vsCoolOrWild),
vsSmoothOrRough: common.sanitizeInput(vsResult.vsSmoothOrRough),
vsTripleStarMedals: common.sanitizeInputNotZero(vsResult.vsTripleStarMedals),
vsDoubleStarMedals: common.sanitizeInputNotZero(vsResult.vsDoubleStarMedals),
vsSingleStarMedals: common.sanitizeInputNotZero(vsResult.vsSingleStarMedals),
vsPlainMedals: common.sanitizeInputNotZero(vsResult.vsPlainMedals),
}
// If the current versus star count is greater than the maximum
if (data.vsStarCount && (car.vsStarCountMax < data.vsStarCount))
{
// Update the maximum versus star count
data.vsStarCountMax = data.vsStarCount;
}
await prisma.car.update({