1
0
mirror of synced 2025-01-31 20:15:24 +01:00

Merge pull request #43 from ghkkk090/master

More OCM Data (old event before mt6 and dev ghost), fix terminal ocm
This commit is contained in:
Luna 2022-09-18 18:35:28 +01:00 committed by GitHub
commit ee83a32ad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 264 additions and 333 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,236 +0,0 @@
import express, { Application } from "express";
import { prisma } from ".";
import { Module } from "./module";
export default class ApiModule extends Module {
register(app: Application): void {
app.use(express.urlencoded({
type: '*/*',
extended: true
}));
app.use(express.json({
type: '*/*'
}));
// API Get Requests
// Get Current Bayshore Version
app.get('/api/bayshore_version', async (req, res) => {
let message: any = {
error: null,
version: null
};
let myJSON = '{'+
'"version": "v1.0.0",'+
'"log":'+
'['+
'"• Fix ghost play count when retiring ocm",'+
'"• API for ocm ranking",'+
'"• Fix unlimited ghost stamp return (hopefully no more of this)",'+
'"• Fix give meter reward bug if playCount still 0",'+
'"• Hopefully fix ocm HoF bug"'+
'"• Fix duplicate id in carOrder"'+
'"• Fix OCM HoF wrong shopName"'+
']'+
'}';
message.version = JSON.parse(myJSON);
// Send the response to the client
res.send(message);
})
// Post Login
app.post('/api/login', async (req, res) => {
// Get the request body
let query = req.query;
// Message Response
let message: any = {
error: null,
user: null
};
// Get the user from the database
let user = await prisma.user.findFirst({
where: {
chipId: {
startsWith: query.cardChipId?.toString()
},
accessCode: query.accessCode?.toString()
},
include: {
cars: {
select: {
state: true,
gtWing: true,
lastPlayedPlace: true,
carId: true,
name: true,
defaultColor: true,
visualModel: true,
level: true,
title: true,
regionId: true,
}
}
}
});
if(user)
{
message.user = user;
}
else
{
message.error = 404
}
// Send the response to the client
res.send(message);
})
// Get Current Competition Id
app.get('/api/get_competition_id', async (req, res) => {
// Get current date
let date = Math.floor(new Date().getTime() / 1000);
// Message Response
let message: any = {
error: null,
competitionId: 1 // default
};
// Get current / previous active OCM Event
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
// qualifyingPeriodStartAt is less than current date
qualifyingPeriodStartAt: { lte: date },
// competitionEndAt is greater than current date
competitionEndAt: { gte: date },
},
orderBy: [
{
dbId: 'desc'
},
{
competitionEndAt: 'desc',
},
],
select:{
competitionId: true
}
});
if(ocmEventDate)
{
message.competitionId = ocmEventDate.competitionId;
}
else{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: {
dbId: 'desc'
},
select:{
competitionId: true
}
});
message.competitionId = ocmEventDate!.competitionId;
}
// Send the response to the client
res.send(message);
});
// Get Current Competition Id
app.get('/api/get_hof_competition_id', async (req, res) => {
// Message Response
let message: any = {
error: null,
competitionId: 1 // default
};
// Get current / previous active OCM Event
let ocmEventDate = await prisma.oCMTally.findFirst({
where:{
periodId: 999999999
},
orderBy: {
competitionId: 'desc'
},
select:{
competitionId: true
}
});
if(ocmEventDate)
{
message.competitionId = ocmEventDate.competitionId;
}
// Send the response to the client
res.send(message);
});
// Get Competition Ranking
app.get('/api/get_competition_ranking', async (req, res) => {
// Get url query
let competitionId = Number(req.query.competitionId);
// Message Response
let message: any = {
error: null,
cars: [],
lastPlayedPlace: 'Bayshore'
};
// Get all of the cars matching the query
message.cars = await prisma.oCMTally.findMany({
where:{
competitionId: competitionId
},
orderBy: {
result: 'desc'
},
include:{
car: {
select:{
carId: true,
name: true,
defaultColor: true,
visualModel: true,
level: true,
title: true,
regionId: true,
}
},
}
});
let getLastPlayedPlace = await prisma.oCMGhostBattleRecord.findFirst({
where:{
carId: message.cars[0].carId,
competitionId: competitionId
}
})
message.lastPlayedPlace = getLastPlayedPlace?.playedShopName;
// Send the response to the client
res.send(message);
});
}
}

View File

@ -9,7 +9,6 @@ import fs from 'fs';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import AllnetModule from './allnet'; import AllnetModule from './allnet';
import MuchaModule from './mucha'; import MuchaModule from './mucha';
import ApiModule from './api';
import { Config } from './config'; import { Config } from './config';
import process from 'process'; import process from 'process';
import * as Sentry from '@sentry/node'; import * as Sentry from '@sentry/node';
@ -36,7 +35,6 @@ const PORT_API = 9003;
const app = express(); const app = express();
const muchaApp = express(); const muchaApp = express();
const allnetApp = express(); const allnetApp = express();
const apiApp = express();
app.use(bodyParser.raw({ app.use(bodyParser.raw({
type: '*/*' type: '*/*'
@ -80,11 +78,6 @@ allnetApp.use((req, res, next) => {
next() next()
}); });
/*apiApp.use((req, res, next) => {
console.log(timestamp+` [ API] ${req.method} ${req.url}`);
next()
});*/
// Get all of the files in the modules directory // Get all of the files in the modules directory
let dirs = fs.readdirSync('dist/modules'); let dirs = fs.readdirSync('dist/modules');
// Loop over the files // Loop over the files
@ -116,7 +109,6 @@ app.all('*', (req, res) => {
// Register the ALL.NET / Mucha Server // Register the ALL.NET / Mucha Server
new AllnetModule().register(allnetApp); new AllnetModule().register(allnetApp);
new MuchaModule().register(muchaApp); new MuchaModule().register(muchaApp);
new ApiModule().register(apiApp);
// Sentry is in use // Sentry is in use
if (useSentry) if (useSentry)
@ -150,8 +142,3 @@ https.createServer({key, cert}, muchaApp).listen(PORT_MUCHA, '0.0.0.0', 511, ()
https.createServer({key, cert}, app).listen(PORT_BNGI, '0.0.0.0', 511, () => { https.createServer({key, cert}, app).listen(PORT_BNGI, '0.0.0.0', 511, () => {
console.log(`Game server listening on port ${PORT_BNGI}!`); console.log(`Game server listening on port ${PORT_BNGI}!`);
}) })
// Create the API server
http.createServer(apiApp).listen(PORT_API, '0.0.0.0', 4369, () => {
console.log(`API server listening on port ${PORT_API}!`);
})

View File

@ -711,6 +711,8 @@ export default class GhostModule extends Module {
// Query parameter from OCM Battle available // Query parameter from OCM Battle available
if(pTrailId) if(pTrailId)
{ {
console.log('Requesting OCM Ghost Trail');
// Get the trail data // Get the trail data
let ghost_trails = await ghost_trail.getOCMGhostTrail(pCarId, pTrailId); let ghost_trails = await ghost_trail.getOCMGhostTrail(pCarId, pTrailId);
@ -723,6 +725,8 @@ export default class GhostModule extends Module {
// Query parameter from Crown Ghost Battle available // Query parameter from Crown Ghost Battle available
else else
{ {
console.log('Requesting Crown Ghost Trail');
// Get the crown trail data // Get the crown trail data
let ghost_trails = await ghost_trail.getCrownGhostTrail(pCarId, pArea); let ghost_trails = await ghost_trail.getCrownGhostTrail(pCarId, pArea);

View File

@ -226,7 +226,7 @@ export default class GhostModule extends Module {
{ {
let itemId = 0; let itemId = 0;
// 16th - C1 // 16th - C1 Outbound
if(ocmEventDate.competitionId === 1) if(ocmEventDate.competitionId === 1)
{ {
itemId = 204; itemId = 204;
@ -246,7 +246,7 @@ export default class GhostModule extends Module {
{ {
itemId = 222; itemId = 222;
} }
// 6th - C1 // 6th - C1 Inbound
else if(ocmEventDate.competitionId === 5) else if(ocmEventDate.competitionId === 5)
{ {
itemId = 35; itemId = 35;
@ -271,7 +271,7 @@ export default class GhostModule extends Module {
{ {
itemId = 47; itemId = 47;
} }
// 1st - C1 // 1st - C1 Outbound
else if(ocmEventDate.competitionId === 10) else if(ocmEventDate.competitionId === 10)
{ {
itemId = 5; itemId = 5;
@ -607,28 +607,26 @@ export default class GhostModule extends Module {
carId: checkGhostTrail!.carId carId: checkGhostTrail!.carId
}, },
include:{ include:{
lastPlayedPlace: true, gtWing: true,
gtWing: true lastPlayedPlace: true
} }
}); });
if(cars)
{
// If regionId is 0 or not set, game will crash after defeating the ghost // If regionId is 0 or not set, game will crash after defeating the ghost
if(cars.regionId === 0) if(cars!.regionId === 0)
{ {
let randomRegionId = Math.floor(Math.random() * 47) + 1; let randomRegionId = Math.floor(Math.random() * 47) + 1;
cars.regionId = randomRegionId; cars!.regionId = randomRegionId;
} }
// Set the tunePower used when playing ghost crown // Set the tunePower used when playing ghost crown
cars.tunePower = ocmTallyRecord!.tunePower; cars!.tunePower = ocmTallyRecord!.tunePower;
// Set the tuneHandling used when playing ghost crown // Set the tuneHandling used when playing ghost crown
cars.tuneHandling = ocmTallyRecord!.tuneHandling; cars!.tuneHandling = ocmTallyRecord!.tuneHandling;
// Set Ghost stuff Value // Set Ghost stuff Value
cars.lastPlayedAt = checkGhostTrail.playedAt; cars!.lastPlayedAt = checkGhostTrail.playedAt
ghostTrailId = checkGhostTrail.dbId!; ghostTrailId = checkGhostTrail.dbId!;
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL; ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
@ -644,9 +642,10 @@ export default class GhostModule extends Module {
if(checkShopName) if(checkShopName)
{ {
cars.lastPlayedPlace!.shopName = checkShopName.playedShopName; cars!.lastPlayedPlace!.shopName = checkShopName.playedShopName;
} }
let ocmEventDate = await prisma.oCMEvent.findFirst({ let ocmEventDate = await prisma.oCMEvent.findFirst({
where: { where: {
competitionId: competition_id competitionId: competition_id
@ -691,7 +690,6 @@ export default class GhostModule extends Module {
} }
} }
} }
}
// Push the Top 1 OCM ghost car data // Push the Top 1 OCM ghost car data
ghostCars = wm.wm.protobuf.GhostCar.create({ ghostCars = wm.wm.protobuf.GhostCar.create({

View File

@ -582,7 +582,8 @@ export default class TerminalModule extends Module {
let compeSch; let compeSch;
let msg: any; let msg: any;
if(ocmEventDate){ if(ocmEventDate)
{
// Creating GhostCompetitionSchedule // Creating GhostCompetitionSchedule
compeSch = wm.wm.protobuf.GhostCompetitionSchedule.create({ compeSch = wm.wm.protobuf.GhostCompetitionSchedule.create({
@ -623,6 +624,7 @@ export default class TerminalModule extends Module {
let periodId: number = 0; let periodId: number = 0;
let ownRecords; let ownRecords;
let topRecords: wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry[] = []; let topRecords: wm.wm.protobuf.LoadGhostCompetitionRankingResponse.Entry[] = [];
let playedShopName = Config.getConfig().shopName;
// Current date is OCM main draw // Current date is OCM main draw
if(ocmEventDate!.competitionStartAt < date && ocmEventDate!.competitionCloseAt > date) if(ocmEventDate!.competitionStartAt < date && ocmEventDate!.competitionCloseAt > date)
@ -675,11 +677,16 @@ export default class TerminalModule extends Module {
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,
} }
}); });
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
@ -695,7 +702,7 @@ export default class TerminalModule extends Module {
title: cars!.title, title: cars!.title,
level: cars!.level, level: cars!.level,
windowStickerString: cars!.windowStickerString, windowStickerString: cars!.windowStickerString,
playedShopName: ocmGhostrecord!.playedShopName, playedShopName: playedShopName,
playedAt: ocmGhostrecord!.playedAt playedAt: ocmGhostrecord!.playedAt
}); });
@ -715,7 +722,7 @@ export default class TerminalModule extends Module {
title: cars!.title, title: cars!.title,
level: cars!.level, level: cars!.level,
windowStickerString: cars!.windowStickerString, windowStickerString: cars!.windowStickerString,
playedShopName: ocmGhostrecord!.playedShopName, playedShopName: playedShopName,
playedAt: ocmGhostrecord!.playedAt playedAt: ocmGhostrecord!.playedAt
})); }));
} }
@ -829,7 +836,7 @@ export default class TerminalModule extends Module {
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,
} }
}); });

View File

@ -1,5 +1,3 @@
import { wm } from "../../wmmt/wm.proto";
// OCM Area // OCM Area
export async function GhostArea(area: number) export async function GhostArea(area: number)
{ {

View File

@ -125,6 +125,7 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
// Check if someone is retiring or use cheat engine time up // Check if someone is retiring or use cheat engine time up
let checkPlayRecord = await prisma.oCMPlayRecord.findMany({ let checkPlayRecord = await prisma.oCMPlayRecord.findMany({
where:{ where:{
competitionId: body.competitionId,
NOT: { NOT: {
carId:{ in: arr } carId:{ in: arr }
} }

View File

@ -5,7 +5,7 @@ export async function OCMArea(competition_id: number)
let rampVal = 0; let rampVal = 0;
let pathVal = 0; let pathVal = 0;
// 16th - C1 // 16th - C1 Outbound
if(competition_id === 1) if(competition_id === 1)
{ {
// GID_RUNAREA_C1 // GID_RUNAREA_C1
@ -53,7 +53,7 @@ export async function OCMArea(competition_id: number)
// GID_PATH_NGR_MARUNOUCHI // GID_PATH_NGR_MARUNOUCHI
pathVal = 49; pathVal = 49;
} }
// 6th - C1 // 6th - C1 Inbound
else if(competition_id === 5) else if(competition_id === 5)
{ {
// GID_RUNAREA_C1 // GID_RUNAREA_C1
@ -113,6 +113,150 @@ export async function OCMArea(competition_id: number)
// GID_PATH_HKFOR // GID_PATH_HKFOR
pathVal = 62; pathVal = 62;
} }
// 1st - C1 Outbound
else if(competition_id === 10)
{
// GID_RUNAREA_C1
areaVal = 0;
// GID_RAMP_C1_OUT_SHIBA
rampVal = 3;
// GID_PATH_C1OUT_KANDABASHI03
pathVal = 9;
}
// 2nd - Osaka
else if(competition_id === 11)
{
// GID_RUNAREA_OSAKA
areaVal = 9;
// GID_RAMP_OOSAKA_DOUTONBORI
rampVal = 26;
// GID_PATH_OS_TONBORI03
pathVal = 52;
}
// 3rd - Fukuoka
else if(competition_id === 12)
{
// GID_RUNAREA_FUKUOKA
areaVal = 11;
// GID_RAMP_FUKUOKA_EAST_NISHI
rampVal = 31
// GID_PATH_FK_NISHIKOUEN;
pathVal = 60;
}
// 4th - Nagoya
else if(competition_id === 13)
{
// GID_RUNAREA_NAGOYA
areaVal = 8;
// GID_RAMP_NAGOYA_MARUNOUCHI
rampVal = 25;
// GID_PATH_NGR_MARUNOUCHI
pathVal = 49;
}
// 5th - Yaesu
else if(competition_id === 14)
{
// GID_RUNAREA_YAESU
areaVal = 6;
// GID_RAMP_YAESU_SHIODOME
rampVal = 18;
// GID_PATH_YSIN_SHIODOME01
pathVal = 34;
}
// 9th - Hakone (Mt. Taikan)
else if(competition_id === 15)
{
// GID_RUNAREA_TURNPIKE
areaVal = 13;
// GID_RAMP_TURNPIKE_UP
rampVal = 35;
// GID_PATH_TP_BOTTOM
pathVal = 64;
}
//10th - Sub-center(Shibuya/Shinjuku)
else if(competition_id === 16)
{
// GID_RUNAREA_SUBTOKYO_3_4
areaVal = 2;
// GID_RAMP_SUBTOKYO_GAIEN
rampVal = 7;
// GID_PATH_WTWEST_GAIEN
pathVal = 17;
}
// 11th - Sub-center(Ikebukuro)
else if(competition_id === 17)
{
// GID_RUNAREA_SUBTOKYO_5
areaVal = 3;
// GID_RAMP_SUBTOKYO_DAIKANCHOU
rampVal = 8;
// GID_PATH_WTUP_DAIKANCHOU
pathVal = 18;
}
// 12th - Kobe
else if(competition_id === 18)
{
// GID_RUNAREA_KOBE
areaVal = 10;
// GID_RAMP_KOBE_NADAOOHASHI
rampVal = 28;
// GID_PATH_KB_NADA
pathVal = 55;
}
// 13th - New Belt Line
else if(competition_id === 19)
{
// GID_RUNAREA_RING
areaVal = 1;
// GID_RAMP_RING_LEFT_ARIAKE
rampVal = 4;
// GID_PATH_N9IN_ARIAKE02
pathVal = 11;
}
// 14th - Yokohama
else if(competition_id === 20)
{
// GID_RUNAREA_YOKOHAMA
areaVal = 7;
// GID_RAMP_MINATOMIRAI_OUT_SHINYAMASHITA
rampVal = 23;
// GID_PATH_KGUP_SHINYAMASHITA03
pathVal = 45;
}
// 15th - Hiroshima
else if(competition_id === 21)
{
// GID_RUNAREA_HIROSHIMA
areaVal = 18;
// GID_RAMP_HIROSHIMA_UJINA
rampVal = 38;
// GID_PATH_HS_UJINA
pathVal = 57;
}
// Return the value to 'BASE_PATH/src/modules/ghost_ocm.ts' // Return the value to 'BASE_PATH/src/modules/ghost_ocm.ts'
return {areaVal, rampVal, pathVal}; return {areaVal, rampVal, pathVal};