¯\_(ツ)_/¯
This commit is contained in:
parent
e8c8982bfb
commit
8b55fe93bc
@ -25,7 +25,6 @@
|
|||||||
"@sentry/tracing": "^7.7.0",
|
"@sentry/tracing": "^7.7.0",
|
||||||
"@types/pem": "^1.9.6",
|
"@types/pem": "^1.9.6",
|
||||||
"body-parser": "^1.20.0",
|
"body-parser": "^1.20.0",
|
||||||
"cors": "^2.8.5",
|
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"form-urlencoded": "^6.0.6",
|
"form-urlencoded": "^6.0.6",
|
||||||
|
135
src/api.ts
135
src/api.ts
@ -1,7 +1,6 @@
|
|||||||
import express, { Application } from "express";
|
import express, { Application } from "express";
|
||||||
import { prisma } from ".";
|
import { prisma } from ".";
|
||||||
import { Module } from "./module";
|
import { Module } from "./module";
|
||||||
const cors = require('cors');
|
|
||||||
|
|
||||||
|
|
||||||
export default class ApiModule extends Module {
|
export default class ApiModule extends Module {
|
||||||
@ -18,11 +17,6 @@ export default class ApiModule extends Module {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
app.use(cors({
|
|
||||||
origin: '*'
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
// API Get Requests
|
// API Get Requests
|
||||||
// Get Current Bayshore Version
|
// Get Current Bayshore Version
|
||||||
app.get('/api/bayshore_version', async (req, res) => {
|
app.get('/api/bayshore_version', async (req, res) => {
|
||||||
@ -50,45 +44,6 @@ export default class ApiModule extends Module {
|
|||||||
res.send(message);
|
res.send(message);
|
||||||
})
|
})
|
||||||
|
|
||||||
// Post Login
|
|
||||||
app.post('/api/login', async (req, res) => {
|
|
||||||
|
|
||||||
// Get the request body
|
|
||||||
let query = req.body;
|
|
||||||
|
|
||||||
// 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()
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
id: true,
|
|
||||||
chipId: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(user)
|
|
||||||
{
|
|
||||||
message.user = user;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message.error = 404
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the response to the client
|
|
||||||
res.send(message);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Get Lastest Competition Id
|
// Get Lastest Competition Id
|
||||||
app.get('/api/get_competition_id', async (req, res) => {
|
app.get('/api/get_competition_id', async (req, res) => {
|
||||||
@ -146,38 +101,6 @@ export default class ApiModule extends Module {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Get Lastest HoF 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
|
// Get Competition Ranking
|
||||||
app.get('/api/get_competition_ranking', async (req, res) => {
|
app.get('/api/get_competition_ranking', async (req, res) => {
|
||||||
|
|
||||||
@ -226,63 +149,5 @@ export default class ApiModule extends Module {
|
|||||||
// Send the response to the client
|
// Send the response to the client
|
||||||
res.send(message);
|
res.send(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Get Car List
|
|
||||||
app.post('/api/get_carlist', async (req, res) => {
|
|
||||||
|
|
||||||
// Get the request body
|
|
||||||
let query = req.body;
|
|
||||||
|
|
||||||
// Message Response
|
|
||||||
let message: any = {
|
|
||||||
error: null,
|
|
||||||
cars: [],
|
|
||||||
carsOrder: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
let user = await prisma.user.findFirst({
|
|
||||||
where:{
|
|
||||||
id: Number(query.userId),
|
|
||||||
chipId: query.cardChipId.toString()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if(user)
|
|
||||||
{
|
|
||||||
// Get all of the cars matching the query
|
|
||||||
message.cars = await prisma.car.findMany({
|
|
||||||
where:{
|
|
||||||
userId: Number(query.userId),
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
carId: true,
|
|
||||||
name: true,
|
|
||||||
defaultColor: true,
|
|
||||||
visualModel: true,
|
|
||||||
level: true,
|
|
||||||
title: true,
|
|
||||||
regionId: true,
|
|
||||||
},
|
|
||||||
orderBy:{
|
|
||||||
carId: 'asc'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let getCarOrder = await prisma.user.findFirst({
|
|
||||||
where:{
|
|
||||||
id: Number(query.userId)
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
carOrder: true
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
message.carsOrder = getCarOrder?.carOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the response to the client
|
|
||||||
res.send(message);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -607,88 +607,86 @@ 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(cars!.regionId === 0)
|
||||||
{
|
{
|
||||||
// If regionId is 0 or not set, game will crash after defeating the ghost
|
let randomRegionId = Math.floor(Math.random() * 47) + 1;
|
||||||
if(cars.regionId === 0)
|
cars!.regionId = randomRegionId;
|
||||||
{
|
}
|
||||||
let randomRegionId = Math.floor(Math.random() * 47) + 1;
|
|
||||||
cars.regionId = randomRegionId;
|
// Set the tunePower used when playing ghost crown
|
||||||
|
cars!.tunePower = ocmTallyRecord!.tunePower;
|
||||||
|
|
||||||
|
// Set the tuneHandling used when playing ghost crown
|
||||||
|
cars!.tuneHandling = ocmTallyRecord!.tuneHandling;
|
||||||
|
|
||||||
|
// Set Ghost stuff Value
|
||||||
|
cars!.lastPlayedAt = checkGhostTrail.playedAt
|
||||||
|
ghostTrailId = checkGhostTrail.dbId!;
|
||||||
|
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
|
||||||
|
|
||||||
|
let checkShopName = await prisma.oCMGhostBattleRecord.findFirst({
|
||||||
|
where:{
|
||||||
|
carId: checkGhostTrail!.carId,
|
||||||
|
competitionId: competition_id
|
||||||
|
},
|
||||||
|
select:{
|
||||||
|
playedShopName: true
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Set the tunePower used when playing ghost crown
|
if(checkShopName)
|
||||||
cars.tunePower = ocmTallyRecord!.tunePower;
|
{
|
||||||
|
cars!.lastPlayedPlace!.shopName = checkShopName.playedShopName;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the tuneHandling used when playing ghost crown
|
|
||||||
cars.tuneHandling = ocmTallyRecord!.tuneHandling;
|
|
||||||
|
|
||||||
// Set Ghost stuff Value
|
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||||
cars.lastPlayedAt = checkGhostTrail.playedAt;
|
where: {
|
||||||
ghostTrailId = checkGhostTrail.dbId!;
|
competitionId: competition_id
|
||||||
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
|
|
||||||
|
|
||||||
let checkShopName = await prisma.oCMGhostBattleRecord.findFirst({
|
|
||||||
where:{
|
|
||||||
carId: checkGhostTrail!.carId,
|
|
||||||
competitionId: competition_id
|
|
||||||
},
|
|
||||||
select:{
|
|
||||||
playedShopName: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if(checkShopName)
|
|
||||||
{
|
|
||||||
cars.lastPlayedPlace!.shopName = checkShopName.playedShopName;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
if(ocmEventDate)
|
||||||
where: {
|
{
|
||||||
competitionId: competition_id
|
// 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
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user