ghost stamp
This commit is contained in:
parent
c18762b83e
commit
d32101e4e2
@ -176,8 +176,8 @@ export default class CarModule extends Module {
|
||||
// Get all of the friend cars for the carId provided
|
||||
let challengers = await prisma.carChallenger.findFirst({
|
||||
where: {
|
||||
challengerCarId: body.carId,
|
||||
carId: opponentTarget[0].carId
|
||||
challengerCarId: opponentTarget[0].carId,
|
||||
carId: body.carId
|
||||
},
|
||||
orderBy:{
|
||||
id: 'desc'
|
||||
@ -190,7 +190,7 @@ export default class CarModule extends Module {
|
||||
|
||||
let carTarget = await prisma.car.findFirst({
|
||||
where:{
|
||||
carId: challengers.carId
|
||||
carId: challengers.challengerCarId
|
||||
},
|
||||
include:{
|
||||
gtWing: true,
|
||||
|
@ -173,7 +173,8 @@ export default class GameModule extends Module {
|
||||
windowSticker: body.car!.windowSticker!,
|
||||
lastPlayedAt: timestamps,
|
||||
regionId: body.car!.regionId!,
|
||||
rgStamp: common.sanitizeInputNotZero(body.rgResult?.rgStamp)
|
||||
rgStamp: common.sanitizeInputNotZero(body.rgResult?.rgStamp),
|
||||
stampSheetCount: common.sanitizeInputNotZero(body.rgResult?.stampSheetCount)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -3,7 +3,6 @@ import { Module } from "module";
|
||||
import { prisma } from "..";
|
||||
import { CarPathandTuning } from "@prisma/client";
|
||||
import Long from "long";
|
||||
import { Config } from "../config";
|
||||
|
||||
// Import Proto
|
||||
import * as wm from "../wmmt/wm.proto";
|
||||
@ -94,7 +93,7 @@ export default class GhostModule extends Module {
|
||||
// Get all of the friend cars for the carId provided
|
||||
let challengers = await prisma.carChallenger.findMany({
|
||||
where: {
|
||||
challengerCarId: body.carId
|
||||
carId: body.carId
|
||||
}
|
||||
});
|
||||
|
||||
@ -104,7 +103,7 @@ export default class GhostModule extends Module {
|
||||
{
|
||||
let carTarget = await prisma.car.findFirst({
|
||||
where:{
|
||||
carId: challengers[i].carId
|
||||
carId: challengers[i].challengerCarId
|
||||
},
|
||||
include:{
|
||||
gtWing: true,
|
||||
@ -126,8 +125,8 @@ export default class GhostModule extends Module {
|
||||
// Response data
|
||||
let msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
stampTargetCars: carsStamp,
|
||||
challengers: carsChallenger,
|
||||
stampTargetCars: carsStamp || null,
|
||||
challengers: carsChallenger || null,
|
||||
stampSheetCount: car!.stampSheetCount,
|
||||
stampSheet: car?.stampSheet || null,
|
||||
stampReturnStats: car?.stampSheet || null,
|
||||
|
@ -189,6 +189,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
|
||||
ghost_historys = await ghost_history.saveGhostHistory(body);
|
||||
|
||||
// Return Stamp (Shuttle Match)
|
||||
await ghost_stamp.shuttleReturnStamp(body);
|
||||
|
||||
// Update the updateNewTrail value
|
||||
updateNewTrail = ghost_historys.updateNewTrail;
|
||||
|
||||
|
@ -21,6 +21,7 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
|
||||
rgResult.rgStamp = 1;
|
||||
}
|
||||
|
||||
// Get the area
|
||||
let area;
|
||||
if(rgResult.path)
|
||||
{
|
||||
@ -47,20 +48,20 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
|
||||
|
||||
if(checkCar)
|
||||
{
|
||||
let returnCounts = 1;
|
||||
|
||||
// Create Challenger data
|
||||
let dataChallenger: any = {
|
||||
carId: body.carId,
|
||||
challengerCarId: rgResult.opponents![i].carId,
|
||||
carId: rgResult.opponents![i].carId,
|
||||
challengerCarId: body.carId,
|
||||
stamp: rgResult.rgStamp,
|
||||
result: rgResult.opponents![i].result,
|
||||
area: area
|
||||
}
|
||||
|
||||
// Create Stamp Target data
|
||||
let dataStampTarget: any = {
|
||||
carId: body.carId,
|
||||
stampTargetCarId: rgResult.opponents![i].carId,
|
||||
returnCount: returnCounts,
|
||||
returnCount: 1,
|
||||
locked: false,
|
||||
recommended: true
|
||||
}
|
||||
@ -73,27 +74,8 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
|
||||
}
|
||||
})
|
||||
|
||||
if(stampTarget)
|
||||
{
|
||||
dataStampTarget.returnCount = stampTarget.returnCount + 1;
|
||||
|
||||
console.log('Updating stamp entry');
|
||||
|
||||
await prisma.carChallenger.update({
|
||||
where:{
|
||||
id: stampTarget.id
|
||||
},
|
||||
data: dataChallenger
|
||||
})
|
||||
|
||||
await prisma.carStampTarget.update({
|
||||
where:{
|
||||
id: stampTarget.id
|
||||
},
|
||||
data: dataStampTarget
|
||||
})
|
||||
}
|
||||
else
|
||||
// No record found
|
||||
if(!(stampTarget))
|
||||
{
|
||||
console.log('Creating new stamp entry');
|
||||
|
||||
@ -125,6 +107,15 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
|
||||
rgResult.rgStamp = 1;
|
||||
}
|
||||
|
||||
// Get the area
|
||||
let area;
|
||||
if(rgResult.path)
|
||||
{
|
||||
let getArea = await ghost_get_area_from_path.getArea(rgResult.path);
|
||||
|
||||
area = getArea.area;
|
||||
}
|
||||
|
||||
// Check how many opponents available
|
||||
for(let i=0; i<rgResult.opponents!.length; i++)
|
||||
{
|
||||
@ -143,23 +134,68 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
|
||||
|
||||
if(checkCar)
|
||||
{
|
||||
// Check opponents target
|
||||
let opponentTarget = await prisma.carStampTarget.findFirst({
|
||||
// Return the stamp
|
||||
let stampTarget = await prisma.carStampTarget.findFirst({
|
||||
where:{
|
||||
stampTargetCarId: body.carId,
|
||||
carId: rgResult.opponents![i].carId,
|
||||
stampTargetCarId: body.carId,
|
||||
}
|
||||
})
|
||||
|
||||
if(opponentTarget)
|
||||
if(stampTarget)
|
||||
{
|
||||
let returnCount = stampTarget.returnCount + 1;
|
||||
|
||||
let dataChallenger: any = {
|
||||
carId: rgResult.opponents![i].carId,
|
||||
challengerCarId: body.carId,
|
||||
stamp: rgResult.rgStamp,
|
||||
result: rgResult.opponents![i].result,
|
||||
area: area
|
||||
}
|
||||
|
||||
let dataStampTarget: any = {
|
||||
carId: rgResult.opponents![i].carId,
|
||||
stampTargetCarId: body.carId,
|
||||
returnCount: returnCount,
|
||||
locked: true,
|
||||
recommended: false
|
||||
}
|
||||
|
||||
console.log('Updating stamp entry');
|
||||
|
||||
await prisma.carChallenger.update({
|
||||
where:{
|
||||
id: stampTarget.id
|
||||
},
|
||||
data: dataChallenger
|
||||
})
|
||||
|
||||
await prisma.carStampTarget.update({
|
||||
where:{
|
||||
id: stampTarget.id
|
||||
},
|
||||
data: dataStampTarget
|
||||
})
|
||||
}
|
||||
|
||||
// Stamp Returned
|
||||
let stampReturned = await prisma.carStampTarget.findFirst({
|
||||
where:{
|
||||
carId: body.carId,
|
||||
stampTargetCarId: rgResult.opponents![i].carId,
|
||||
}
|
||||
})
|
||||
|
||||
if(stampReturned)
|
||||
{
|
||||
await prisma.carStampTarget.update({
|
||||
where: {
|
||||
id: opponentTarget.id
|
||||
where:{
|
||||
id: stampReturned.id
|
||||
},
|
||||
data:{
|
||||
locked: true,
|
||||
recommended: false
|
||||
data: {
|
||||
locked: false,
|
||||
recommended: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user