1
0
mirror of synced 2024-11-12 01:10:47 +01:00

fix ghost return stamp no stamp logo

This commit is contained in:
Shiroi Kitsu 2023-07-03 16:33:12 +07:00
parent b787aec0da
commit 47744d4647
2 changed files with 26 additions and 14 deletions

View File

@ -39,13 +39,17 @@ export default class GhostModule extends Module {
let getStampTargets = await ghostFunctions.getOpponentHistory(body.carId);
let opponentHistory = getStampTargets.opponentHistory;
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId);
let stampTarget = getStampTarget.stampTarget;
// ------------- STAMP STUFF -------------
// Must declare both
// Get Challengers
let getChallengers = await ghostFunctions.getChallengers(body.carId);
let challengers = getChallengers.challengers;
let arrayCarId = getChallengers.arrayCarId
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId, arrayCarId);
let stampTarget = getStampTarget.stampTarget;
// ---------------------------------------
// Response data
let msg = {
@ -98,14 +102,17 @@ export default class GhostModule extends Module {
// Get the request body for the load stamp target request
let body = wm.wm.protobuf.LoadStampTargetRequest.decode(req.body);
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId);
let stampTarget = getStampTarget.stampTarget;
// ------------- STAMP STUFF -------------
// Must declare both
// Get Challengers
let getChallengers = await ghostFunctions.getChallengers(body.carId);
let challengers = getChallengers.challengers;
let arrayCarId = getChallengers.arrayCarId
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId, arrayCarId);
let stampTarget = getStampTarget.stampTarget;
// ---------------------------------------
// Response data
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,

View File

@ -61,22 +61,22 @@ export async function getOpponentHistory(carId: number)
// Get Stamp Target
export async function getStampTarget(carId: number)
export async function getStampTarget(carId: number, arrayCarId: number[])
{
// Get all of the friend cars for the carId provided
let getStampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: carId,
recommended: true
recommended: true,
carId: { in: arrayCarId },
},
orderBy:{
locked: 'desc'
},
take: 10
});
let stampTarget: wmproto.wm.protobuf.StampTargetCar[] = [];
if(getStampTargets)
if(getStampTargets.length > 0)
{
for(let i=0; i<getStampTargets.length; i++)
{
@ -104,6 +104,8 @@ export async function getStampTarget(carId: number)
recommended: getStampTargets[i].recommended
})
);
}
}
@ -126,6 +128,7 @@ export async function getChallengers(carId: number)
});
let challengers: wmproto.wm.protobuf.ChallengerCar[] = [];
let arrChallengerCarId = [];
let arrayCarId = [];
// Push beated carId to array
for(let i=0; i<checkBeatedCar.length; i++)
@ -144,7 +147,7 @@ export async function getChallengers(carId: number)
take: 10
});
if(getChallengers)
if(getChallengers.length > 0)
{
for(let i=0; i<getChallengers.length; i++)
{
@ -181,10 +184,12 @@ export async function getChallengers(carId: number)
area: getChallengers[i].area
})
);
arrayCarId.push(getChallengers[i].challengerCarId);
}
}
return { challengers }
return { challengers, arrayCarId }
}