1
0
mirror of synced 2024-12-05 03:27:57 +01:00

fix terminal ocm

This commit is contained in:
ghkkk090 2022-08-31 09:36:00 +07:00
parent 62e8ef9350
commit 414b64f9e1
5 changed files with 73 additions and 26 deletions

View File

@ -117,6 +117,8 @@ export default class CarModule extends Module {
if(getNo1OCM)
{
console.log('Getting registered car data');
// Get Car Data
let cars = await prisma.car.findFirst({
where:{

View File

@ -359,6 +359,14 @@ export default class GhostModule extends Module {
closed: true
};
}
else
{
// Response data
msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
closed: true
};
}
}
// No OCM Event
else{
@ -399,8 +407,6 @@ export default class GhostModule extends Module {
// Get currently active OCM event
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
competitionId: competition_id,
// qualifyingPeriodStartAt is less than current date
qualifyingPeriodStartAt: { lte: date },
@ -419,9 +425,6 @@ export default class GhostModule extends Module {
{
dbId: 'desc'
},
{
competitionEndAt: 'desc',
},
],
});
}
@ -436,6 +439,7 @@ export default class GhostModule extends Module {
shopName: Config.getConfig().shopName,
country: Config.getConfig().country
});
let competitionSchedule;
// Get default trail id
let ghostTrailId = 0;
@ -586,12 +590,8 @@ export default class GhostModule extends Module {
// Get Top 1 qualifying ghost trail id
let checkGhostTrail = await prisma.oCMTop1GhostTrail.findFirst({
where:{
carId: ocmTallyRecord!.carId,
competitionId: ocmEventDate!.competitionId,
competitionId: competition_id,
periodId: 999999999,
area: areaVal,
ramp: rampVal,
path: pathVal,
},
orderBy:{
playedAt: 'desc'
@ -601,6 +601,7 @@ export default class GhostModule extends Module {
// Top 1 OCM Ghost trail data available
if(checkGhostTrail)
{
console.log('go here');
// Get the Top 1 OCM car data
cars = await prisma.car.findFirst({
where:{
@ -629,6 +630,49 @@ export default class GhostModule extends Module {
cars!.lastPlayedAt = checkGhostTrail.playedAt
ghostTrailId = checkGhostTrail.dbId!;
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
competitionId: competition_id
}
});
if(ocmEventDate)
{
// Creating GhostCompetitionSchedule
competitionSchedule = wm.wm.protobuf.GhostCompetitionSchedule.create({
// OCM Competition ID (1 = C1 (Round 16), 4 = Nagoya (Round 19), 8 = Hiroshima (Round 21))
competitionId: ocmEventDate.competitionId,
// OCM Qualifying Start Timestamp
qualifyingPeriodStartAt: ocmEventDate.qualifyingPeriodStartAt,
// OCM Qualifying Close Timestamp
qualifyingPeriodCloseAt: ocmEventDate.qualifyingPeriodCloseAt,
// OCM Competition (Main Draw) Start Timestamp
competitionStartAt: ocmEventDate.competitionStartAt,
// OCM Competition (Main Draw) Close Timestamp
competitionCloseAt: ocmEventDate.competitionCloseAt,
// OCM Competition (Main Draw) End Timestamp
competitionEndAt: ocmEventDate.competitionEndAt,
// idk what this is
lengthOfPeriod: ocmEventDate.lengthOfPeriod,
// idk what this is
lengthOfInterval: ocmEventDate.lengthOfInterval,
// Area for the event (GID_RUNAREA_*, 8 is GID_RUNAREA_NAGOYA)
area: ocmEventDate.area,
// idk what this is
minigamePatternId: ocmEventDate.minigamePatternId
});
}
}
}
@ -640,7 +684,8 @@ export default class GhostModule extends Module {
path: pathVal,
nonhuman: false,
type: ghostTypes,
trailId: ghostTrailId
trailId: ghostTrailId,
});
// Response data
@ -649,7 +694,8 @@ export default class GhostModule extends Module {
competitionId: competition_id,
ghostCar: ghostCars!,
trailId: ghostTrailId,
updatedAt: date
updatedAt: date,
competitionSchedule: competitionSchedule || null
};
// Encode the response

View File

@ -44,14 +44,9 @@ export default class StartupModule extends Module {
if(!(ocmEventDate))
{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: [
{
dbId: 'desc'
},
{
competitionEndAt: 'desc',
},
],
orderBy:{
dbId: 'desc'
}
});
pastEvent = 1;

View File

@ -581,8 +581,8 @@ export default class TerminalModule extends Module {
if(!(ocmEventDate))
{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy:{
dbId: 'desc'
where:{
competitionId: body.competitionId
}
});

View File

@ -141,18 +141,21 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
// Get the Top 1 Advantage
if(top1advantage === null)
{
top1advantage = OCMTally[i].result;
top1advantage = OCMTally[0].result;
let getTrail = await prisma.oCMGhostTrail.findFirst({
where:{
carId: OCMTally[i].carId,
carId: OCMTally[0].carId,
competitionId: body.competitionId,
ocmMainDraw: true
},
orderBy:{
playedAt: 'desc'
}
})
if(getTrail)
{
console.log('Creating Trail');
await prisma.oCMTop1GhostTrail.create({
data: {
carId: getTrail.carId,
@ -221,7 +224,8 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
}
if(i === 0){
if(i === 0)
{
console.log('Making OCM Top 1 Ghost Data');
// Create Top 1 ghost data