1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2025-02-01 05:45:43 +01:00

ghost stamp

This commit is contained in:
ghkkk090 2022-08-24 23:41:46 +07:00
parent c18762b83e
commit d32101e4e2
5 changed files with 83 additions and 44 deletions

View File

@ -176,8 +176,8 @@ export default class CarModule extends Module {
// Get all of the friend cars for the carId provided // Get all of the friend cars for the carId provided
let challengers = await prisma.carChallenger.findFirst({ let challengers = await prisma.carChallenger.findFirst({
where: { where: {
challengerCarId: body.carId, challengerCarId: opponentTarget[0].carId,
carId: opponentTarget[0].carId carId: body.carId
}, },
orderBy:{ orderBy:{
id: 'desc' id: 'desc'
@ -190,7 +190,7 @@ export default class CarModule extends Module {
let carTarget = await prisma.car.findFirst({ let carTarget = await prisma.car.findFirst({
where:{ where:{
carId: challengers.carId carId: challengers.challengerCarId
}, },
include:{ include:{
gtWing: true, gtWing: true,

View File

@ -173,7 +173,8 @@ export default class GameModule extends Module {
windowSticker: body.car!.windowSticker!, windowSticker: body.car!.windowSticker!,
lastPlayedAt: timestamps, lastPlayedAt: timestamps,
regionId: body.car!.regionId!, regionId: body.car!.regionId!,
rgStamp: common.sanitizeInputNotZero(body.rgResult?.rgStamp) rgStamp: common.sanitizeInputNotZero(body.rgResult?.rgStamp),
stampSheetCount: common.sanitizeInputNotZero(body.rgResult?.stampSheetCount)
} }
}) })

View File

@ -3,7 +3,6 @@ import { Module } from "module";
import { prisma } from ".."; import { prisma } from "..";
import { CarPathandTuning } from "@prisma/client"; import { CarPathandTuning } from "@prisma/client";
import Long from "long"; import Long from "long";
import { Config } from "../config";
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.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 // Get all of the friend cars for the carId provided
let challengers = await prisma.carChallenger.findMany({ let challengers = await prisma.carChallenger.findMany({
where: { where: {
challengerCarId: body.carId carId: body.carId
} }
}); });
@ -104,7 +103,7 @@ export default class GhostModule extends Module {
{ {
let carTarget = await prisma.car.findFirst({ let carTarget = await prisma.car.findFirst({
where:{ where:{
carId: challengers[i].carId carId: challengers[i].challengerCarId
}, },
include:{ include:{
gtWing: true, gtWing: true,
@ -126,8 +125,8 @@ export default class GhostModule extends Module {
// Response data // Response data
let msg = { let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
stampTargetCars: carsStamp, stampTargetCars: carsStamp || null,
challengers: carsChallenger, challengers: carsChallenger || null,
stampSheetCount: car!.stampSheetCount, stampSheetCount: car!.stampSheetCount,
stampSheet: car?.stampSheet || null, stampSheet: car?.stampSheet || null,
stampReturnStats: car?.stampSheet || null, stampReturnStats: car?.stampSheet || null,

View File

@ -189,6 +189,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
ghost_historys = await ghost_history.saveGhostHistory(body); ghost_historys = await ghost_history.saveGhostHistory(body);
// Return Stamp (Shuttle Match)
await ghost_stamp.shuttleReturnStamp(body);
// Update the updateNewTrail value // Update the updateNewTrail value
updateNewTrail = ghost_historys.updateNewTrail; updateNewTrail = ghost_historys.updateNewTrail;

View File

@ -21,6 +21,7 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
rgResult.rgStamp = 1; rgResult.rgStamp = 1;
} }
// Get the area
let area; let area;
if(rgResult.path) if(rgResult.path)
{ {
@ -47,20 +48,20 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
if(checkCar) if(checkCar)
{ {
let returnCounts = 1; // Create Challenger data
let dataChallenger: any = { let dataChallenger: any = {
carId: body.carId, carId: rgResult.opponents![i].carId,
challengerCarId: rgResult.opponents![i].carId, challengerCarId: body.carId,
stamp: rgResult.rgStamp, stamp: rgResult.rgStamp,
result: rgResult.opponents![i].result, result: rgResult.opponents![i].result,
area: area area: area
} }
// Create Stamp Target data
let dataStampTarget: any = { let dataStampTarget: any = {
carId: body.carId, carId: body.carId,
stampTargetCarId: rgResult.opponents![i].carId, stampTargetCarId: rgResult.opponents![i].carId,
returnCount: returnCounts, returnCount: 1,
locked: false, locked: false,
recommended: true recommended: true
} }
@ -73,27 +74,8 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
} }
}) })
if(stampTarget) // No record found
{ 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
{ {
console.log('Creating new stamp entry'); console.log('Creating new stamp entry');
@ -125,6 +107,15 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
rgResult.rgStamp = 1; 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 // Check how many opponents available
for(let i=0; i<rgResult.opponents!.length; i++) for(let i=0; i<rgResult.opponents!.length; i++)
{ {
@ -143,24 +134,69 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
if(checkCar) if(checkCar)
{ {
// Check opponents target // Return the stamp
let opponentTarget = await prisma.carStampTarget.findFirst({ let stampTarget = await prisma.carStampTarget.findFirst({
where:{ where:{
stampTargetCarId: body.carId,
carId: rgResult.opponents![i].carId, carId: rgResult.opponents![i].carId,
stampTargetCarId: body.carId,
} }
}) })
if(opponentTarget) if(stampTarget)
{ {
await prisma.carStampTarget.update({ let returnCount = stampTarget.returnCount + 1;
where: {
id: opponentTarget.id let dataChallenger: any = {
}, carId: rgResult.opponents![i].carId,
data:{ 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, locked: true,
recommended: false 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: stampReturned.id
},
data: {
locked: false,
recommended: true
}
}) })
} }
} }