proper force finish detection(hopefully)
This commit is contained in:
parent
3f3b330a6a
commit
18530e9d50
@ -239,7 +239,8 @@ export default class GameModule extends Module {
|
|||||||
// Check retire crown
|
// Check retire crown
|
||||||
let getCarCrown = await prisma.carCrownDetect.findFirst({
|
let getCarCrown = await prisma.carCrownDetect.findFirst({
|
||||||
where:{
|
where:{
|
||||||
carId: body.carId
|
carId: body.carId,
|
||||||
|
playedAt: body.playedAt,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import wmproto from "../../wmmt/wm.proto";
|
|||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
import * as ghost_history from "../ghost/ghost_history";
|
import * as ghost_history from "../ghost/ghost_history";
|
||||||
import * as ghost_stamp from "../ghost/ghost_stamp";
|
import * as ghost_stamp from "../ghost/ghost_stamp";
|
||||||
import * as carFunctions from "../cars/functions";
|
|
||||||
|
|
||||||
// Save ghost battle result
|
// Save ghost battle result
|
||||||
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
|
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
|
||||||
@ -305,6 +304,49 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
|
|
||||||
// Crown holder data available
|
// Crown holder data available
|
||||||
if(carCrowns)
|
if(carCrowns)
|
||||||
|
{
|
||||||
|
// Look For Existing Car Record Based On Area
|
||||||
|
let areaRecord = await prisma.carCrownDetect.findFirst({
|
||||||
|
where: {
|
||||||
|
carId: body.carId,
|
||||||
|
area: area
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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
|
// Crown Finish Status
|
||||||
await prisma.carCrownDetect.create({
|
await prisma.carCrownDetect.create({
|
||||||
@ -333,6 +375,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Crown holder data not available or still default crown holder data
|
// Crown holder data not available or still default crown holder data
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -684,7 +727,8 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
|||||||
await prisma.carCrownDetect.create({
|
await prisma.carCrownDetect.create({
|
||||||
data:{
|
data:{
|
||||||
carId: body.carId,
|
carId: body.carId,
|
||||||
status: 'retire'
|
status: 'retire',
|
||||||
|
playedAt: body.playedAt
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import { wm } from "../../wmmt/wm.proto";
|
|||||||
|
|
||||||
// Import Util
|
// Import Util
|
||||||
import * as common from "../util/common";
|
import * as common from "../util/common";
|
||||||
import * as carFunctions from "../cars/functions";
|
|
||||||
|
|
||||||
|
|
||||||
// Save versus battle result
|
// Save versus battle result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user