1
0
mirror of synced 2024-12-04 19:17:58 +01:00

update ocm tally

This commit is contained in:
ghkkk090 2022-09-04 19:03:11 +07:00
parent dbd0e8bfc8
commit 1c473e7211
2 changed files with 39 additions and 2 deletions

View File

@ -339,8 +339,8 @@ export default class GhostModule extends Module {
{ {
// Pick random car Id // Pick random car Id
let randomNumber: number = Math.floor(Math.random() * car.length); let randomNumber: number = Math.floor(Math.random() * car.length);
if(arr.indexOf(randomNumber) === -1){ if(arr.indexOf(randomNumber) === -1)
{
// Push current number to array // Push current number to array
arr.push(randomNumber); arr.push(randomNumber);

View File

@ -13,6 +13,7 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
{ {
periodId = periodId - 1; periodId = periodId - 1;
// Current day is main draw and tallying qualifying period
if(periodId === 0) if(periodId === 0)
{ {
console.log('Tallying data from Qualifying'); console.log('Tallying data from Qualifying');
@ -28,12 +29,14 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
result: 'desc', result: 'desc',
} }
}); });
let arr = [];
// gbRecordTally is set // gbRecordTally is set
if(gbRecordTally) if(gbRecordTally)
{ {
let top1advantage = null; let top1advantage = null;
let currentResult = 0; let currentResult = 0;
for(let i=0; i<gbRecordTally.length; i++) for(let i=0; i<gbRecordTally.length; i++)
{ {
// Get the Top 1 Advantage // Get the Top 1 Advantage
@ -90,6 +93,9 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
currentResult = -Math.abs(currentResult); currentResult = -Math.abs(currentResult);
} }
// Pushing carId to array
arr.push(gbRecordTally[i].carId);
// Moving data to OCM Tally // Moving data to OCM Tally
let data : any = { let data : any = {
carId: gbRecordTally[i].carId, carId: gbRecordTally[i].carId,
@ -113,9 +119,40 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
data: data data: data
}); });
} }
}
}
// Check if someone is retiring or use cheat engine time up
let checkPlayRecord = await prisma.oCMPlayRecord.findMany({
where:{
NOT: {
carId:{ in: arr }
}
}
});
if(checkPlayRecord)
{
for(let i=0; i<checkPlayRecord.length; i++)
{
// Moving data to OCM Tally
let dataLeft : any = {
carId: checkPlayRecord[i].carId,
result: -9999999,
tunePower: 17,
tuneHandling: 17,
competitionId: body.competitionId,
periodId: periodId + 1
}
// Create the data
await prisma.oCMTally.create({
data: dataLeft
});
} }
} }
} }
// Current day is main draw period 2 (and so on..) and tallying main draw period 1 (and so on..)
else else
{ {
console.log('Tallying data from previous Period'); console.log('Tallying data from previous Period');