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

alpha ocm

This commit is contained in:
ghkkk090 2022-08-15 15:05:43 +07:00
parent afacc0254e
commit 28e75762ad
5 changed files with 173 additions and 53 deletions

View File

@ -3,7 +3,7 @@
INSERT INTO "public"."OCMEvent" VALUES (dbId, competitionId, qualifyingPeriodStartAt, qualifyingPeriodCloseAt, competitionStartAt, competitionCloseAt, competitionEndAt, lengthOfPeriod, lengthOfInterval, area, minigamePattern);
// Query Example
INSERT INTO "public"."OCMEvent" VALUES (1, 4, 1659286800, 1660064400, 1660150800, 1660928400, 1661792400, 86400, 0, 0, 1);
INSERT INTO "public"."OCMEvent" VALUES (1, 1, 1659312000, 1660420740, 1660420800, 1661446800, 1661792400, 86400, 0, 0, 1);
// CompetitionId Reference :
BASE_PATH\src\util\games\games_util\ghost_ocm_area.ts
@ -20,7 +20,7 @@ lengthOfInterval = idk what this is (maybe interval for each period)
area = course area, not really important tbh.. set to 0 still works fine
minigamePattern = idk the correct value
---PLEASE DON'T CHANGE THE TIMETAMPS AFTER YOU SET YOURS OCM EVENT.. DO IT BEFORE YOU RUN THE QUERY---
######################## OCMPeriod TABLE ########################
@ -31,14 +31,14 @@ INSERT INTO "public"."OCMPeriod" VALUES (dbId, competitionDbId, competitionId, p
// Description
competitionId = OCM Event number (connected to OCMEvent table)
periodId = idk how to explain this...
periodId = idk how to explain this... how many period available for main draw
startAt = start timestamp (datetime) of each period
closeAt = end timestamp (datetime) of each period
// periodId formula (idk if this is correct) :
// periodId (idk if this is correct) :
1. x = competitionStartAt + lengthOfPeriod
2. if x is still less than competitionCloseAt, periodId = 1
2. if x is still less than competitionCloseAt, periodId = 1 (startAt = competitionStartAt, closeAt = x)
3. competitionStartAt = x + lengthOfInterval
4. do the count again (no 1)
5. if x is still less than competitionCloseAt, periodId = periodId + 1 (in this case is periodId = 2)
6. do it again until x is more than or same like competitionCloseAt (better make it same like competitionCloseAt)
4. if x is still less than competitionCloseAt, periodId = periodId + 1 (in this case is periodId = 2)
5. do the count again (no 1)
6. do it again until x is more than or same like competitionCloseAt (for last period, better make it same like competitionCloseAt)

View File

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Car" ADD COLUMN "country" TEXT NOT NULL DEFAULT 'JPN',
ALTER COLUMN "stLoseBits" SET DEFAULT 0;

View File

@ -61,6 +61,7 @@ model Car {
name String
manufacturer Int
regionId Int @default(0)
country String @default("JPN")
model Int
visualModel Int
customColor Int @default(0)

View File

@ -473,7 +473,7 @@ export default class GhostModule extends Module {
// Generate default S660 car data
cars = wm.wm.protobuf.Car.create({
carId: 999999999,
carId: 999999999, // Don't change this
name: '',
regionId: 18, // IDN (福井)
manufacturer: 12, // HONDA
@ -497,12 +497,12 @@ export default class GhostModule extends Module {
rivalMarker: 32,
aura: 551,
windowSticker: true,
windowStickerString: '', //
windowStickerString: '',
windowStickerFont: 0,
title: 'You don\'t have S660? LMAO',
level: 65, // SSSSS
lastPlayedAt: checkGhostTrail!.playedAt,
country: 'GLB'
});
// Set Ghost stuff Value

View File

@ -15,7 +15,7 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
if(periodId === 0)
{
console.log('Tallying');
console.log('Tallying data from Qualifying');
// Get user that playing OCM qualifying day
let gbRecordTally = await prisma.oCMGhostBattleRecord.findMany({
@ -39,7 +39,7 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
// Get the Top 1 Advantage
if(top1advantage === null)
{
top1advantage = gbRecordTally[i].result
top1advantage = gbRecordTally[i].result;
let getTrail = await prisma.oCMGhostTrail.findFirst({
where:{
@ -106,6 +106,8 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
});
if(i === 0){
console.log('Making OCM Top 1 Ghost Data');
// Create Top 1 ghost data
await prisma.oCMTop1Ghost.create({
data: data
@ -116,10 +118,11 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
}
else
{
console.log('Tallying data from previous Period');
// Get user that playing OCM qualifying day
let gbRecordTally = await prisma.oCMGhostBattleRecord.findMany({
let OCMTally = await prisma.oCMTally.findMany({
where:{
ocmMainDraw: true,
competitionId: body.competitionId,
periodId: periodId
},
@ -129,42 +132,98 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
});
// gbRecordTally is set
if(gbRecordTally)
if(OCMTally)
{
let top1advantage = 0;
for(let i=0; i<gbRecordTally.length; i++)
let top1advantage = null;
let currentResult = 0;
for(let i=0; i<OCMTally.length; i++)
{
// Get the Top 1 Advantage
if(top1advantage === 0)
if(top1advantage === null)
{
top1advantage = gbRecordTally[i].result
top1advantage = OCMTally[i].result;
let getTrail = await prisma.oCMGhostTrail.findFirst({
where:{
carId: OCMTally[i].carId,
competitionId: body.competitionId,
ocmMainDraw: true
}
})
if(getTrail)
{
await prisma.oCMTop1GhostTrail.create({
data: {
carId: getTrail.carId,
area: getTrail.area,
ramp: getTrail.ramp,
path: getTrail.path,
trail: getTrail.trail,
competitionId: getTrail.competitionId,
periodId: getTrail.periodId + 1,
playedAt: getTrail.playedAt,
tunePower: getTrail.tunePower,
tuneHandling: getTrail.tuneHandling,
ocmMainDraw: true
}
})
}
}
// User is lose VS Top 1 Qualifying Ghost (minus advantage like -10 meter)
if(gbRecordTally[i].result < 0)
// Get the Top 1 Advantage
if(top1advantage > 0)
{
gbRecordTally[i].result = top1advantage + Math.abs(gbRecordTally[i].result);
}
if(OCMTally[i].result <= 0)
{
currentResult = top1advantage + Math.abs(OCMTally[i].result);
// Get current Result after calculated
let currentResult = top1advantage - gbRecordTally[i].result
currentResult = -Math.abs(currentResult);
}
else
{
currentResult = OCMTally[i].result - top1advantage;
}
}
else
{
currentResult = top1advantage + Math.abs(OCMTally[i].result);
currentResult = -Math.abs(currentResult);
}
// Moving data to OCM Tally
let data : any = {
carId: gbRecordTally[i].carId,
carId: OCMTally[i].carId,
result: currentResult,
tunePower: gbRecordTally[i].tunePower,
tuneHandling: gbRecordTally[i].tuneHandling,
tunePower: OCMTally[i].tunePower,
tuneHandling: OCMTally[i].tuneHandling,
competitionId: body.competitionId,
periodId: periodId
periodId: periodId + 1
}
// Create the data
await prisma.oCMTally.create({
data: data
let checkOCMTally = await prisma.oCMTally.findFirst({
where: {
carId: OCMTally[i].carId,
competitionId: body.competitionId,
}
});
if(checkOCMTally)
{
// Update the tally data
await prisma.oCMTally.update({
where:{
dbId: checkOCMTally?.dbId
},
data: data
});
}
if(i === 0){
console.log('Making OCM Top 1 Ghost Data');
// Create Top 1 ghost data
await prisma.oCMTop1Ghost.create({
data: data
@ -177,10 +236,11 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
// OCM is ended
else
{
console.log('Tallying data for end of OCM');
// Get user that playing OCM qualifying day
let gbRecordTally = await prisma.oCMGhostBattleRecord.findMany({
let OCMTally = await prisma.oCMTally.findMany({
where:{
ocmMainDraw: true,
competitionId: body.competitionId,
periodId: periodId
},
@ -190,42 +250,98 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
});
// gbRecordTally is set
if(gbRecordTally)
if(OCMTally)
{
let top1advantage = 0;
for(let i=0; i<gbRecordTally.length; i++)
let top1advantage = null;
let currentResult = 0;
for(let i=0; i<OCMTally.length; i++)
{
// Get the Top 1 Advantage
if(top1advantage === 0)
if(top1advantage === null)
{
top1advantage = gbRecordTally[i].result
top1advantage = OCMTally[i].result;
let getTrail = await prisma.oCMGhostTrail.findFirst({
where:{
carId: OCMTally[i].carId,
competitionId: body.competitionId,
ocmMainDraw: true
}
})
if(getTrail)
{
await prisma.oCMTop1GhostTrail.create({
data: {
carId: getTrail.carId,
area: getTrail.area,
ramp: getTrail.ramp,
path: getTrail.path,
trail: getTrail.trail,
competitionId: getTrail.competitionId,
periodId: getTrail.periodId + 1,
playedAt: getTrail.playedAt,
tunePower: getTrail.tunePower,
tuneHandling: getTrail.tuneHandling,
ocmMainDraw: true
}
})
}
}
// User is lose VS Top 1 Qualifying Ghost (minus advantage like -10 meter)
if(gbRecordTally[i].result < 0)
// Get the Top 1 Advantage
if(top1advantage > 0)
{
gbRecordTally[i].result = top1advantage + Math.abs(gbRecordTally[i].result);
}
if(OCMTally[i].result <= 0)
{
currentResult = top1advantage + Math.abs(OCMTally[i].result);
// Get current Result after calculated
let currentResult = top1advantage - gbRecordTally[i].result
currentResult = -Math.abs(currentResult);
}
else
{
currentResult = OCMTally[i].result - top1advantage;
}
}
else
{
currentResult = top1advantage + Math.abs(OCMTally[i].result);
currentResult = -Math.abs(currentResult);
}
// Moving data to OCM Tally
let data : any = {
carId: gbRecordTally[i].carId,
carId: OCMTally[i].carId,
result: currentResult,
tunePower: gbRecordTally[i].tunePower,
tuneHandling: gbRecordTally[i].tuneHandling,
tunePower: OCMTally[i].tunePower,
tuneHandling: OCMTally[i].tuneHandling,
competitionId: body.competitionId,
periodId: periodId
periodId: periodId + 1
}
// Create the data
await prisma.oCMTally.create({
data: data
let checkOCMTally = await prisma.oCMTally.findFirst({
where: {
carId: OCMTally[i].carId,
competitionId: body.competitionId,
}
});
if(checkOCMTally)
{
// Update the tally data
await prisma.oCMTally.update({
where:{
dbId: checkOCMTally?.dbId
},
data: data
});
}
if(i === 0){
console.log('Making OCM Top 1 Ghost Data');
// Create Top 1 ghost data
await prisma.oCMTop1Ghost.create({
data: data