mirror of
https://github.com/shiroikitsu8/Bayshore_6r_legacy.git
synced 2025-03-03 20:03:46 +01:00
fix terminal ocm rank
This commit is contained in:
parent
d941452cbb
commit
8fb7dfdc78
@ -639,23 +639,18 @@ export default class TerminalModule extends Module {
|
|||||||
car: true
|
car: true
|
||||||
},
|
},
|
||||||
distinct: ["carId"],
|
distinct: ["carId"],
|
||||||
|
take: 50
|
||||||
})
|
})
|
||||||
|
|
||||||
numOfParticipants = ocmParticipant.length;
|
numOfParticipants = ocmParticipant.length;
|
||||||
periodId = 0;
|
periodId = 0;
|
||||||
let ranking = 0;
|
let ranking = 0;
|
||||||
let maxNumber = 150;
|
|
||||||
|
|
||||||
if(numOfParticipants < 151)
|
|
||||||
{
|
|
||||||
maxNumber = numOfParticipants;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(numOfParticipants > 0)
|
if(numOfParticipants > 0)
|
||||||
{
|
{
|
||||||
periodId = ocmParticipant[0].periodId;
|
periodId = ocmParticipant[0].periodId;
|
||||||
|
|
||||||
for(let i=0; i<maxNumber; i++)
|
for(let i=0; i<ocmParticipant.length; i++)
|
||||||
{
|
{
|
||||||
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
||||||
where:{
|
where:{
|
||||||
@ -715,39 +710,48 @@ export default class TerminalModule extends Module {
|
|||||||
|
|
||||||
if(!(ownRecords))
|
if(!(ownRecords))
|
||||||
{
|
{
|
||||||
for(let i=150; i<numOfParticipants; i++)
|
let ocmPersonalRank = [{ result: 0, position: 0 }];
|
||||||
|
|
||||||
|
ocmPersonalRank = await prisma.$queryRaw`
|
||||||
|
select "result", "position" from
|
||||||
|
(select *, row_number() over(order by "result" DESC) as "position" from "OCMTally"
|
||||||
|
where "competitionId" = ${body.competitionId}) "OCMTally" where "carId" = ${body.carId}`;
|
||||||
|
|
||||||
|
if(ocmPersonalRank.length > 0)
|
||||||
{
|
{
|
||||||
if(ocmParticipant[i].carId === body.carId)
|
let userCar = await prisma.car.findFirst({
|
||||||
{
|
where:{
|
||||||
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
carId: body.carId
|
||||||
where:{
|
}
|
||||||
carId: body.carId,
|
});
|
||||||
competitionId: ocmEventDate!.competitionId,
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
playedAt: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// User car setting
|
let userPlayedAt = await prisma.ghostBattleRecord.findFirst({
|
||||||
ownRecords = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry.create({
|
where:{
|
||||||
rank: i + 1,
|
carId: body.carId
|
||||||
result: ocmParticipant[i].result,
|
},
|
||||||
carId: ocmParticipant[i].carId,
|
select:{
|
||||||
name: ocmParticipant[i].car.name,
|
playedAt: true
|
||||||
regionId: ocmParticipant[i].car.regionId,
|
}
|
||||||
model: ocmParticipant[i].car.model,
|
});
|
||||||
visualModel: ocmParticipant[i].car.visualModel,
|
|
||||||
defaultColor: ocmParticipant[i].car.defaultColor,
|
|
||||||
title: ocmParticipant[i].car.title,
|
|
||||||
level: ocmParticipant[i].car.level,
|
|
||||||
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
|
||||||
playedShopName: playedShopName,
|
|
||||||
playedAt: ocmGhostrecord!.playedAt
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
let myRank = Number(ocmPersonalRank[0].position);
|
||||||
}
|
let myResult = Number(ocmPersonalRank[0].result);
|
||||||
|
|
||||||
|
ownRecords = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry.create({
|
||||||
|
rank: myRank,
|
||||||
|
result: myResult,
|
||||||
|
carId: userCar!.carId,
|
||||||
|
name: userCar!.name,
|
||||||
|
regionId: userCar!.regionId,
|
||||||
|
model: userCar!.model,
|
||||||
|
visualModel: userCar!.visualModel,
|
||||||
|
defaultColor: userCar!.defaultColor,
|
||||||
|
title: userCar!.title,
|
||||||
|
level: userCar!.level,
|
||||||
|
windowStickerString: userCar!.windowStickerString,
|
||||||
|
playedShopName: playedShopName,
|
||||||
|
playedAt: userPlayedAt?.playedAt || 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -808,37 +812,39 @@ export default class TerminalModule extends Module {
|
|||||||
{
|
{
|
||||||
console.log('Current / Previous OCM Day : OCM has Ended');
|
console.log('Current / Previous OCM Day : OCM has Ended');
|
||||||
|
|
||||||
|
// Get Current OCM Period and All User's Record
|
||||||
let ocmParticipant = await prisma.oCMTally.findMany({
|
let ocmParticipant = await prisma.oCMTally.findMany({
|
||||||
where:{
|
where:{
|
||||||
competitionId: ocmEventDate!.competitionId,
|
competitionId: ocmEventDate!.competitionId,
|
||||||
periodId: 999999999
|
|
||||||
},
|
|
||||||
orderBy: {
|
|
||||||
result: 'desc'
|
|
||||||
},
|
},
|
||||||
|
orderBy: [
|
||||||
|
{
|
||||||
|
result: 'desc'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
periodId: 'desc'
|
||||||
|
}
|
||||||
|
],
|
||||||
include:{
|
include:{
|
||||||
car: true
|
car: true
|
||||||
},
|
},
|
||||||
distinct: ["carId"]
|
distinct: ["carId"],
|
||||||
|
take: 10
|
||||||
})
|
})
|
||||||
|
|
||||||
numOfParticipants = ocmParticipant.length;
|
numOfParticipants = ocmParticipant.length;
|
||||||
periodId = 0;
|
periodId = 0;
|
||||||
let ranking = 0;
|
let ranking = 0;
|
||||||
let maxNumber = 150;
|
|
||||||
|
|
||||||
if(numOfParticipants < 151)
|
|
||||||
{
|
|
||||||
maxNumber = numOfParticipants;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(numOfParticipants > 0)
|
if(numOfParticipants > 0)
|
||||||
{
|
{
|
||||||
for(let i=0; i<maxNumber; i++)
|
periodId = ocmParticipant[0].periodId;
|
||||||
|
|
||||||
|
for(let i=0; i<ocmParticipant.length; i++)
|
||||||
{
|
{
|
||||||
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
||||||
where:{
|
where:{
|
||||||
carId: ocmParticipant[i].carId,
|
carId: ocmParticipant[0].carId,
|
||||||
competitionId: ocmEventDate!.competitionId,
|
competitionId: ocmEventDate!.competitionId,
|
||||||
},
|
},
|
||||||
select:{
|
select:{
|
||||||
@ -847,6 +853,11 @@ export default class TerminalModule extends Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(ocmGhostrecord?.playedShopName !== null && ocmGhostrecord?.playedShopName !== undefined)
|
||||||
|
{
|
||||||
|
playedShopName = ocmGhostrecord.playedShopName;
|
||||||
|
}
|
||||||
|
|
||||||
if(ocmParticipant[i].carId === body.carId && ranking === 0)
|
if(ocmParticipant[i].carId === body.carId && ranking === 0)
|
||||||
{
|
{
|
||||||
// User car setting
|
// User car setting
|
||||||
@ -862,7 +873,7 @@ export default class TerminalModule extends Module {
|
|||||||
title: ocmParticipant[i].car.title,
|
title: ocmParticipant[i].car.title,
|
||||||
level: ocmParticipant[i].car.level,
|
level: ocmParticipant[i].car.level,
|
||||||
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
||||||
playedShopName: ocmGhostrecord!.playedShopName,
|
playedShopName: playedShopName,
|
||||||
playedAt: ocmGhostrecord!.playedAt
|
playedAt: ocmGhostrecord!.playedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -882,46 +893,55 @@ export default class TerminalModule extends Module {
|
|||||||
title: ocmParticipant[i].car.title,
|
title: ocmParticipant[i].car.title,
|
||||||
level: ocmParticipant[i].car.level,
|
level: ocmParticipant[i].car.level,
|
||||||
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
||||||
playedShopName: ocmGhostrecord!.playedShopName,
|
playedShopName: playedShopName,
|
||||||
playedAt: ocmGhostrecord!.playedAt
|
playedAt: ocmGhostrecord!.playedAt
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(ownRecords))
|
if(!(ownRecords))
|
||||||
{
|
{
|
||||||
for(let i=maxNumber; i<numOfParticipants; i++)
|
let ocmPersonalRank = [{ result: 0, position: 0 }];
|
||||||
|
|
||||||
|
ocmPersonalRank = await prisma.$queryRaw`
|
||||||
|
select "result", "position" from
|
||||||
|
(select *, row_number() over(order by "result" DESC) as "position" from "OCMTally"
|
||||||
|
where "competitionId" = ${body.competitionId}) "OCMTally" where "carId" = ${body.carId}`;
|
||||||
|
|
||||||
|
if(ocmPersonalRank.length > 0)
|
||||||
{
|
{
|
||||||
if(ocmParticipant[i].carId === body.carId)
|
let userCar = await prisma.car.findFirst({
|
||||||
{
|
where:{
|
||||||
let ocmGhostrecord = await prisma.oCMGhostBattleRecord.findFirst({
|
carId: body.carId
|
||||||
where:{
|
}
|
||||||
carId: body.carId,
|
});
|
||||||
competitionId: ocmEventDate!.competitionId,
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
playedAt: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// User car setting
|
let userPlayedAt = await prisma.ghostBattleRecord.findFirst({
|
||||||
ownRecords = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry.create({
|
where:{
|
||||||
rank: i + 1,
|
carId: body.carId
|
||||||
result: ocmParticipant[i].result,
|
},
|
||||||
carId: ocmParticipant[i].carId,
|
select:{
|
||||||
name: ocmParticipant[i].car.name,
|
playedAt: true
|
||||||
regionId: ocmParticipant[i].car.regionId,
|
}
|
||||||
model: ocmParticipant[i].car.model,
|
});
|
||||||
visualModel: ocmParticipant[i].car.visualModel,
|
|
||||||
defaultColor: ocmParticipant[i].car.defaultColor,
|
|
||||||
title: ocmParticipant[i].car.title,
|
|
||||||
level: ocmParticipant[i].car.level,
|
|
||||||
windowStickerString: ocmParticipant[i].car.windowStickerString,
|
|
||||||
playedShopName: playedShopName,
|
|
||||||
playedAt: ocmGhostrecord!.playedAt
|
|
||||||
});
|
|
||||||
|
|
||||||
break;
|
let myRank = Number(ocmPersonalRank[0].position);
|
||||||
}
|
let myResult = Number(ocmPersonalRank[0].result);
|
||||||
|
|
||||||
|
ownRecords = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry.create({
|
||||||
|
rank: myRank,
|
||||||
|
result: myResult,
|
||||||
|
carId: userCar!.carId,
|
||||||
|
name: userCar!.name,
|
||||||
|
regionId: userCar!.regionId,
|
||||||
|
model: userCar!.model,
|
||||||
|
visualModel: userCar!.visualModel,
|
||||||
|
defaultColor: userCar!.defaultColor,
|
||||||
|
title: userCar!.title,
|
||||||
|
level: userCar!.level,
|
||||||
|
windowStickerString: userCar!.windowStickerString,
|
||||||
|
playedShopName: playedShopName,
|
||||||
|
playedAt: userPlayedAt?.playedAt || 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user