1
0
mirror of synced 2025-02-23 05:29:05 +01:00

¯\_(ツ)_/¯

This commit is contained in:
ghkkk090 2022-09-15 08:35:17 +07:00
parent e8c8982bfb
commit 8b55fe93bc
3 changed files with 69 additions and 207 deletions

View File

@ -25,7 +25,6 @@
"@sentry/tracing": "^7.7.0",
"@types/pem": "^1.9.6",
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"form-urlencoded": "^6.0.6",

View File

@ -1,7 +1,6 @@
import express, { Application } from "express";
import { prisma } from ".";
import { Module } from "./module";
const cors = require('cors');
export default class ApiModule extends Module {
@ -18,11 +17,6 @@ export default class ApiModule extends Module {
}));
app.use(cors({
origin: '*'
}));
// API Get Requests
// Get Current Bayshore Version
app.get('/api/bayshore_version', async (req, res) => {
@ -50,45 +44,6 @@ export default class ApiModule extends Module {
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
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
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
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);
})
}
}

View File

@ -607,88 +607,86 @@ export default class GhostModule extends Module {
carId: checkGhostTrail!.carId
},
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
if(cars.regionId === 0)
{
let randomRegionId = Math.floor(Math.random() * 47) + 1;
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
cars.tunePower = ocmTallyRecord!.tunePower;
if(checkShopName)
{
cars!.lastPlayedPlace!.shopName = checkShopName.playedShopName;
}
// 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
}
})
if(checkShopName)
{
cars.lastPlayedPlace!.shopName = checkShopName.playedShopName;
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
competitionId: competition_id
}
});
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
});
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
});
}
}
}
}