1
0
mirror of synced 2025-01-22 19:32:05 +01:00

Merge pull request #57 from shiroikitsu8/master

merge to my master branch, connect file list to database
This commit is contained in:
Luna 2023-01-23 15:17:11 +00:00 committed by GitHub
commit c71b355ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 354 additions and 253 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ key.pem
config.json config.json
package-lock.json package-lock.json
ecosystem.config.js ecosystem.config.js
static/*

View File

@ -1,10 +1,6 @@
# Bayshore # Bayshore
Wangan Midnight Maximum Tune 6 server reimplementation written in TypeScript Wangan Midnight Maximum Tune 6 server reimplementation written in TypeScript
<p align="center">
<img src="https://repository-images.githubusercontent.com/523956269/9a72b45d-7b27-4237-8aeb-476865a6d6d6" width="640" title="hover text">
</p>
## Credits ## Credits
This software is part of [Project Asakura](https://github.com/ProjectAsakura). This software is part of [Project Asakura](https://github.com/ProjectAsakura).

View File

@ -11,6 +11,7 @@
"giftCarsFullyTuned": 0, "giftCarsFullyTuned": 0,
"scratchEnabled": 1, "scratchEnabled": 1,
"scratchType": 1, "scratchType": 1,
"giveMeterReward": 0 "giveMeterReward": 0,
"newCardsBanned": 0
} }
} }

View File

@ -32,7 +32,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.1", "body-parser": "^1.20.1",
"chancer": "^2.0.2",
"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",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0,
ALTER COLUMN "regionId" SET DEFAULT 1;

View File

@ -0,0 +1,16 @@
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0,
ALTER COLUMN "regionId" SET DEFAULT 18;
-- CreateTable
CREATE TABLE "FileList" (
"fileId" SERIAL NOT NULL,
"fileType" INTEGER NOT NULL,
"fileSize" INTEGER NOT NULL,
"urlFileName" TEXT NOT NULL,
"sha1sum" TEXT NOT NULL,
"notBefore" INTEGER NOT NULL,
"notAfter" INTEGER NOT NULL,
CONSTRAINT "FileList_pkey" PRIMARY KEY ("fileId")
);

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
-- AlterTable
ALTER TABLE "FileList" ADD COLUMN "filePath" TEXT NOT NULL DEFAULT '';

View File

@ -86,7 +86,7 @@ model Car {
rivalMarker Int @default(0) rivalMarker Int @default(0)
lastPlayedAt Int @default(0) lastPlayedAt Int @default(0)
aura Int @default(0) aura Int @default(0)
regionId Int @default(0) regionId Int @default(18)
country String @default("JPN") country String @default("JPN")
// This is more data about the car // This is more data about the car
@ -437,3 +437,14 @@ model PlaceList {
shopName String shopName String
country String country String
} }
model FileList {
fileId Int @id @default(autoincrement())
fileType Int
fileSize Int
urlFileName String
sha1sum String
notBefore Int
notAfter Int
filePath String @default("")
}

View File

@ -48,6 +48,11 @@ export interface GameOptions {
// Give meter reward every n*100 play // Give meter reward every n*100 play
giveMeterReward: number; //1 is on, 0 is off giveMeterReward: number; //1 is on, 0 is off
// if the new card is not in the User databese
// set this option to 1 will not create a new card
// and prevent new card registration
newCardsBanned: number;//1 is on, 0 is off
} }
export class Config { export class Config {

View File

@ -4,7 +4,6 @@ import { Module } from "module";
import { prisma } from ".."; import { prisma } from "..";
import { User } from "@prisma/client"; import { User } from "@prisma/client";
import Long from "long"; import Long from "long";
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -129,7 +128,19 @@ export default class CarModule extends Module {
console.log('Challengers Available'); console.log('Challengers Available');
// Randomize pick // Randomize pick
let random: number = MersenneTwister.int(0, opponentTargetCount - 1); let random: number = 1;
// Randomize it 5 times
for(let i=0; i<5; i++)
{
random = Math.floor(Math.random() * opponentTargetCount);
}
// Try randomize it again if it's 1
if(random === 1)
{
random = Math.floor(Math.random() * opponentTargetCount);
}
// Check opponents target // Check opponents target
let opponentTarget = await prisma.carStampTarget.findMany({ let opponentTarget = await prisma.carStampTarget.findMany({
@ -399,7 +410,18 @@ export default class CarModule extends Module {
// Randomize regionId // Randomize regionId
let regionId: number = 18; let regionId: number = 18;
regionId = MersenneTwister.int(1, 47);
// Randomize it 5 times
for(let i=0; i<5; i++)
{
regionId = Math.floor(Math.random() * 47) + 1;
}
// Try randomize it again if it's 1
if(regionId === 1)
{
regionId = Math.floor(Math.random() * 47) + 1;
}
// Default car values // Default car values
let carInsert = { let carInsert = {

View File

@ -2,7 +2,6 @@ import { Application } from "express";
import { Module } from "../module"; import { Module } from "../module";
import { prisma } from ".."; import { prisma } from "..";
import { Config } from "../config"; import { Config } from "../config";
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -136,12 +135,6 @@ export default class GameModule extends Module {
} }
} }
// Check region id is 0
if(body.car!.regionId! === 0)
{
body.car!.regionId = MersenneTwister.int(1, 47);
}
// Check playet at timestamp // Check playet at timestamp
let timestamps = 0; let timestamps = 0;
if(body.car?.lastPlayedAt !== undefined && body.car?.lastPlayedAt !== null) if(body.car?.lastPlayedAt !== undefined && body.car?.lastPlayedAt !== null)
@ -156,6 +149,16 @@ export default class GameModule extends Module {
} }
} }
// Check P & H must not more than 34 (fully tuned value)
let tunePower = 0;
let tuneHandling = 0;
let totalTune = body.car!.tunePower + body.car!.tuneHandling;
if(totalTune <= 34)
{
tunePower = body.car!.tunePower;
tuneHandling = body.car!.tuneHandling;
}
// Update car // Update car
await prisma.car.update({ await prisma.car.update({
where: { where: {
@ -168,8 +171,8 @@ export default class GameModule extends Module {
playCount: body.playCount, playCount: body.playCount,
level: body.car!.level!, level: body.car!.level!,
title: body.car!.title!, title: body.car!.title!,
tunePower: body.car!.tunePower!, tunePower: tunePower,
tuneHandling: body.car!.tuneHandling!, tuneHandling: tuneHandling,
windowSticker: body.car!.windowSticker!, windowSticker: body.car!.windowSticker!,
lastPlayedAt: timestamps, lastPlayedAt: timestamps,
regionId: body.car!.regionId!, regionId: body.car!.regionId!,
@ -256,7 +259,7 @@ export default class GameModule extends Module {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
// Set session for saving ghost trail Ghost Battle Mode or Crown Ghost Battle Mode // Set session for saving ghost trail Ghost Battle Mode or Crown Ghost Battle Mode
ghostSessionId: MersenneTwister.int(1, 100) ghostSessionId: Math.floor(Math.random() * 100) + 1
} }
} }
// OCM Battle game mode is completed // OCM Battle game mode is completed
@ -266,7 +269,7 @@ export default class GameModule extends Module {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
// Set session for saving ghost trail OCM Ghost Battle Mode // Set session for saving ghost trail OCM Ghost Battle Mode
ghostSessionId: MersenneTwister.int(101, 200) ghostSessionId: Math.floor(Math.random() * 100) + 101
} }
} }
// Story mode or TA mode is completed // Story mode or TA mode is completed
@ -436,11 +439,6 @@ export default class GameModule extends Module {
ghostOpponentCar!.country = 'GLB'; ghostOpponentCar!.country = 'GLB';
} }
if(ghostOpponentCar!.regionId === 0)
{
ghostOpponentCar!.regionId = MersenneTwister.int(1, 47);
}
// Get Opponent 1 tune // Get Opponent 1 tune
ghostOpponentCar!.tunePower = ghostHistoryData![i].opponent1TunePower!; ghostOpponentCar!.tunePower = ghostHistoryData![i].opponent1TunePower!;
ghostOpponentCar!.tuneHandling = ghostHistoryData![i].opponent1TuneHandling!; ghostOpponentCar!.tuneHandling = ghostHistoryData![i].opponent1TuneHandling!;
@ -478,11 +476,6 @@ export default class GameModule extends Module {
ghostOpponentCar2!.country = 'GLB'; ghostOpponentCar2!.country = 'GLB';
} }
if(ghostOpponentCar!.regionId === 0)
{
ghostOpponentCar2!.regionId = MersenneTwister.int(1, 47);
}
// Get Opponent 2 tune // Get Opponent 2 tune
ghostOpponentCar2!.tunePower = ghostHistoryData![i].opponent2TunePower!; ghostOpponentCar2!.tunePower = ghostHistoryData![i].opponent2TunePower!;
ghostOpponentCar2!.tuneHandling = ghostHistoryData![i].opponent2TuneHandling!; ghostOpponentCar2!.tuneHandling = ghostHistoryData![i].opponent2TuneHandling!;
@ -517,11 +510,6 @@ export default class GameModule extends Module {
ghostOpponentCar3!.country = 'GLB'; ghostOpponentCar3!.country = 'GLB';
} }
if(ghostOpponentCar!.regionId === 0)
{
ghostOpponentCar3!.regionId = MersenneTwister.int(1, 47);
}
// Get Opponent 3 tune // Get Opponent 3 tune
ghostOpponentCar3!.tunePower = ghostHistoryData![i].opponent3TunePower!; ghostOpponentCar3!.tunePower = ghostHistoryData![i].opponent3TunePower!;
ghostOpponentCar3!.tuneHandling = ghostHistoryData![i].opponent3TuneHandling!; ghostOpponentCar3!.tuneHandling = ghostHistoryData![i].opponent3TuneHandling!;

View File

@ -4,7 +4,6 @@ import { prisma } from "..";
import { CarPathandTuning } from "@prisma/client"; import { CarPathandTuning } from "@prisma/client";
import Long from "long"; import Long from "long";
import { Config } from "../config"; import { Config } from "../config";
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -357,18 +356,31 @@ export default class GhostModule extends Module {
// Choose the user's car data randomly to appear // Choose the user's car data randomly to appear
while(arr.length < maxNumber) while(arr.length < maxNumber)
{ {
// Pick random car Id // Randomize pick
let randomNumber = MersenneTwister.int(0, car.length-1); let random: number = 1;
if(arr.indexOf(randomNumber) === -1) // Randomize it 5 times
for(let i=0; i<5; i++)
{
random = Math.floor(Math.random() * car.length);
}
// Try randomize it again if it's 1
if(random === 1)
{
random = Math.floor(Math.random() * car.length);
}
if(arr.indexOf(random) === -1)
{ {
// Push current number to array // Push current number to array
arr.push(randomNumber); arr.push(random);
// Check if ghost trail for certain car is available // Check if ghost trail for certain car is available
let ghost_trails = await prisma.ghostTrail.findFirst({ let ghost_trails = await prisma.ghostTrail.findFirst({
where: { where: {
carId: car[randomNumber].carId, carId: car[random].carId,
area: body.area, area: body.area,
crownBattle: false crownBattle: false
}, },
@ -377,31 +389,25 @@ export default class GhostModule extends Module {
} }
}); });
// If regionId is 0 or not set, game will crash after defeating the ghost
if(car[randomNumber]!.regionId === 0)
{
car[randomNumber].regionId = MersenneTwister.int(1, 47);
}
// Push user's car data without ghost trail // Push user's car data without ghost trail
if(!(ghost_trails)) if(!(ghost_trails))
{ {
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({ lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
car: car[randomNumber] car: car[random]
})); }));
} }
// Push user's car data with ghost trail // Push user's car data with ghost trail
else else
{ {
// Set the tunePower used when playing certain area // Set the tunePower used when playing certain area
car[randomNumber].tunePower = ghost_trails!.tunePower; car[random].tunePower = ghost_trails!.tunePower;
// Set the tuneHandling used when playing certain area // Set the tuneHandling used when playing certain area
car[randomNumber].tuneHandling = ghost_trails!.tuneHandling; car[random].tuneHandling = ghost_trails!.tuneHandling;
// Push data to Ghost car proto // Push data to Ghost car proto
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({ lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
car: car[randomNumber], car: car[random],
nonhuman: false, nonhuman: false,
type: wm.wm.protobuf.GhostType.GHOST_NORMAL, type: wm.wm.protobuf.GhostType.GHOST_NORMAL,
trailId: ghost_trails!.dbId! trailId: ghost_trails!.dbId!
@ -417,6 +423,7 @@ export default class GhostModule extends Module {
{ {
// Get current date // Get current date
let date = Math.floor(new Date().getTime() / 1000); let date = Math.floor(new Date().getTime() / 1000);
let playedPlace = wm.wm.protobuf.Place.create({ let playedPlace = wm.wm.protobuf.Place.create({
placeId: Config.getConfig().placeId, placeId: Config.getConfig().placeId,
regionId: Config.getConfig().regionId, regionId: Config.getConfig().regionId,

View File

@ -2,7 +2,6 @@ import { Application } from "express";
import { Module } from "module"; import { Module } from "module";
import { prisma } from ".."; import { prisma } from "..";
import { Config } from "../config"; import { Config } from "../config";
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -182,7 +181,6 @@ export default class GhostModule extends Module {
// Get Current OCM Period // Get Current OCM Period
let OCMCurrentPeriod = await prisma.oCMPeriod.findFirst({ let OCMCurrentPeriod = await prisma.oCMPeriod.findFirst({
where: { where: {
competitionDbId: ocmEventDate!.dbId,
competitionId: ocmEventDate!.competitionId competitionId: ocmEventDate!.competitionId
}, },
orderBy: { orderBy: {
@ -421,11 +419,9 @@ export default class GhostModule extends Module {
if(!(ocmEventDate)) if(!(ocmEventDate))
{ {
ocmEventDate = await prisma.oCMEvent.findFirst({ ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: [ orderBy:{
{
competitionId: 'desc' competitionId: 'desc'
}, },
],
}); });
} }
@ -489,12 +485,6 @@ export default class GhostModule extends Module {
} }
}); });
// If regionId is 0 or not set, game will crash after defeating the ghost
if(cars!.regionId === 0)
{
cars!.regionId = MersenneTwister.int(1, 47);
}
// Set the tunePower used when playing ghost crown // Set the tunePower used when playing ghost crown
cars!.tunePower = ocmTallyRecord!.tunePower; cars!.tunePower = ocmTallyRecord!.tunePower;
@ -611,12 +601,6 @@ export default class GhostModule extends Module {
} }
}); });
// If regionId is 0 or not set, game will crash after defeating the ghost
if(cars!.regionId === 0)
{
cars!.regionId = MersenneTwister.int(1, 47);
}
// Set the tunePower used when playing ghost crown // Set the tunePower used when playing ghost crown
cars!.tunePower = ocmTallyRecord!.tunePower; cars!.tunePower = ocmTallyRecord!.tunePower;

View File

@ -1,9 +1,8 @@
import e, { Application } from "express"; import { Application } from "express";
import { Module } from "module"; import { Module } from "module";
import { Config } from "../config"; import { Config } from "../config";
import { prisma } from ".."; import { prisma } from "..";
import path from 'path'; import path from 'path';
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -133,8 +132,8 @@ export default class ResourceModule extends Module {
result: resultTime, result: resultTime,
name: '', name: '',
regionId: 1, // Hokkaido regionId: 1, // Hokkaido
model: MersenneTwister.int(0, 50), // Randomizing Car data model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: MersenneTwister.int(0, 100), // Randomizing Car data visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0, defaultColor: 0,
tunePower: 0, tunePower: 0,
tuneHandling: 0, tuneHandling: 0,
@ -171,8 +170,8 @@ export default class ResourceModule extends Module {
result: resulttime, result: resulttime,
name: '', name: '',
regionId: 1, // Hokkaido regionId: 1, // Hokkaido
model: MersenneTwister.int(0, 50), // Randomizing Car data model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: MersenneTwister.int(0, 100), // Randomizing Car data visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0, defaultColor: 0,
tunePower: 0, tunePower: 0,
tuneHandling: 0, tuneHandling: 0,
@ -235,8 +234,8 @@ export default class ResourceModule extends Module {
result: 0, result: 0,
name: '', name: '',
regionId: 1, // Hokkaido regionId: 1, // Hokkaido
model: MersenneTwister.int(0, 50), // Randomizing Car data model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: MersenneTwister.int(0, 100), // Randomizing Car data visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0, defaultColor: 0,
tunePower: 0, tunePower: 0,
tuneHandling: 0, tuneHandling: 0,
@ -298,8 +297,8 @@ export default class ResourceModule extends Module {
result: 0, result: 0,
name: '', name: '',
regionId: 1, // Hokkaido regionId: 1, // Hokkaido
model: MersenneTwister.int(0, 50), // Randomizing Car data model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: MersenneTwister.int(0, 100), // Randomizing Car data visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0, defaultColor: 0,
tunePower: 0, tunePower: 0,
tuneHandling: 0, tuneHandling: 0,
@ -496,12 +495,26 @@ export default class ResourceModule extends Module {
common.sendResponse(message, res); common.sendResponse(message, res);
}) })
app.use("/static", e.static(
path.join(__dirname, '..', '..', 'static'), // For File List
{ cacheControl: false } app.get('/static/:filename', async function(req, res){
));
// Static Files
let paths = await prisma.fileList.findFirst({
where:{
urlFileName: req.params.filename
},
select: {
filePath: true
}
});
res.sendFile(path.resolve(paths!.filePath, req.params.filename), { cacheControl: false });
});
// File List
app.get('/resource/file_list', async (req, res) => { app.get('/resource/file_list', async (req, res) => {
console.log('file_list'); console.log('file_list');
@ -510,15 +523,25 @@ export default class ResourceModule extends Module {
// This is literally just bare-bones so the shit boots // This is literally just bare-bones so the shit boots
let files: wm.wm.protobuf.FileList.FileInfo[] = []; let files: wm.wm.protobuf.FileList.FileInfo[] = [];
let fileList = await prisma.fileList.findMany({
orderBy:{
fileId: 'asc'
}
});
for(let i=0; i<fileList.length; i++)
{
files.push(wm.wm.protobuf.FileList.FileInfo.create({ files.push(wm.wm.protobuf.FileList.FileInfo.create({
fileId: 1, fileId: fileList[i].fileId,
fileType: wm.wm.protobuf.FileType.FILE_PROMOTION_ANNOUNCEMENT, fileType: fileList[i].fileType,
fileSize: 383791, fileSize: fileList[i].fileSize,
url: 'https://'+Config.getConfig().serverIp+':9002/static/000002-bayshore.bin', url: 'https://'+Config.getConfig().serverIp+':9002/static/' +fileList[i].urlFileName,
sha1sum: Buffer.from('F1A1AF6F7273F2BA5189CDB15165028B56E022E6', "hex"), sha1sum: Buffer.from(fileList[i].sha1sum, "hex"),
notBefore: 0, notBefore: fileList[i].notBefore,
notAfter: 2147483647, notAfter: fileList[i].notAfter,
})); }));
}
// Response data // Response data
let msg = { let msg = {
@ -535,6 +558,7 @@ export default class ResourceModule extends Module {
}) })
// Ghost List
app.get('/resource/ghost_list', async (req, res) => { app.get('/resource/ghost_list', async (req, res) => {
console.log('ghost_list'); console.log('ghost_list');

View File

@ -30,10 +30,9 @@ export default class StartupModule extends Module {
// competitionEndAt is greater than current date // competitionEndAt is greater than current date
competitionEndAt: { gte: date }, competitionEndAt: { gte: date },
}, },
orderBy: orderBy: {
{
competitionEndAt: 'desc', competitionEndAt: 'desc',
}, }
}); });
let pastEvent = 0; let pastEvent = 0;
@ -57,6 +56,8 @@ export default class StartupModule extends Module {
if(pastDay < 604800) if(pastDay < 604800)
{ {
console.log("OCM Event Available");
// Creating GhostCompetitionSchedule // Creating GhostCompetitionSchedule
competitionSchedule = wm.wm.protobuf.GhostCompetitionSchedule.create({ competitionSchedule = wm.wm.protobuf.GhostCompetitionSchedule.create({
@ -94,6 +95,8 @@ export default class StartupModule extends Module {
if(pastEvent === 1) if(pastEvent === 1)
{ {
console.log("Previous OCM Event Available");
lastCompetitionId = ocmEventDate.competitionId lastCompetitionId = ocmEventDate.competitionId
} }
} }

View File

@ -3,7 +3,6 @@ import { Config } from "../config";
import { Module } from "module"; import { Module } from "module";
import { prisma } from ".."; import { prisma } from "..";
import { Car } from "@prisma/client"; import { Car } from "@prisma/client";
let MersenneTwister = require('chancer');
// Import Proto // Import Proto
import * as wm from "../wmmt/wm.proto"; import * as wm from "../wmmt/wm.proto";
@ -249,14 +248,6 @@ export default class TerminalModule extends Module {
}); });
} }
for(let i=0; i<cars.length; i++)
{
if(cars[i].regionId === 0)
{
cars[i].regionId = MersenneTwister.int(1, 47);
}
}
let msg = { let msg = {
hitCount: cars.length, hitCount: cars.length,
cars: cars cars: cars

View File

@ -68,6 +68,12 @@ export default class UserModule extends Module {
return; return;
} }
// Check if new card registration is allowed or not
let newCardsBanned = Config.getConfig().gameOptions.newCardsBanned;
// New card registration is allowed
if (newCardsBanned === 0)
{
let user = await prisma.user.create({ let user = await prisma.user.create({
data: { data: {
chipId: body.cardChipId, chipId: body.cardChipId,
@ -77,7 +83,7 @@ export default class UserModule extends Module {
false, // TUTORIAL_ID_TIME_ATTACK = 1, false, // TUTORIAL_ID_TIME_ATTACK = 1,
false, // TUTORIAL_ID_GHOST = 2, false, // TUTORIAL_ID_GHOST = 2,
false, // TUTORIAL_ID_GHOST_CHALLENGE = 3, false, // TUTORIAL_ID_GHOST_CHALLENGE = 3,
false, //TUTORIAL_ID_GHOST_LEVEL = 4, false, // TUTORIAL_ID_UNUSED_4 = 4,
false, // TUTORIAL_ID_UNUSED_5 = 5, false, // TUTORIAL_ID_UNUSED_5 = 5,
false, // TUTORIAL_ID_GHOST_SEARCH = 6, false, // TUTORIAL_ID_GHOST_SEARCH = 6,
false, // TUTORIAL_ID_GHOST_COMPETITION = 7, false, // TUTORIAL_ID_GHOST_COMPETITION = 7,
@ -93,11 +99,11 @@ export default class UserModule extends Module {
false, // TUTORIAL_ID_UNUSED_17 = 17, false, // TUTORIAL_ID_UNUSED_17 = 17,
false, // TUTORIAL_ID_UNUSED_18 = 18, false, // TUTORIAL_ID_UNUSED_18 = 18,
false, // TUTORIAL_ID_UNUSED_19 = 19, false, // TUTORIAL_ID_UNUSED_19 = 19,
true, //TUTORIAL_ID_GHOST_STAMP = 20, false, // TUTORIAL_ID_GHOST_STAMP = 20,
true, //TUTORIAL_ID_GHOST_STAMP_DECLINED = 21, false, // TUTORIAL_ID_GHOST_STAMP_DECLINED = 21,
true, //TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22, false, // TUTORIAL_ID_GHOST_STAMP_FRIENDS = 22,
true, //TUTORIAL_ID_TERMINAL_SCRATCH = 23, false, // TUTORIAL_ID_TERMINAL_SCRATCH = 23,
true, //TUTORIAL_ID_TURN_SCRATCH_SHEET = 24, false, // TUTORIAL_ID_TURN_SCRATCH_SHEET = 24,
false, // TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN = 25, false, // TUTORIAL_ID_INVITE_FRIEND_CAMPAIGN = 25,
false, // TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE = 26, false, // TUTORIAL_ID_CAR_COUPON_FULL_TUNED_RECEIVABLE = 26,
false, // TUTORIAL_ID_VS_CONTINUE_TICKET = 27, false, // TUTORIAL_ID_VS_CONTINUE_TICKET = 27,
@ -105,11 +111,26 @@ export default class UserModule extends Module {
false, // TUTORIAL_ID_UNUSED_29 = 29, false, // TUTORIAL_ID_UNUSED_29 = 29,
false, // TUTORIAL_ID_UNUSED_30 = 30, false, // TUTORIAL_ID_UNUSED_30 = 30,
false, // TUTORIAL_ID_DRESS_UP = 31, false, // TUTORIAL_ID_DRESS_UP = 31,
true, //TUTORIAL_ID_MULTI_GHOST = 32, false, // TUTORIAL_ID_UNUSED_32 = 32,
true, //TUTORIAL_ID_STORY_NEW_FEATURE = 33, false, // TUTORIAL_ID_STORY_NEW_FEATURE = 33,
true, //TUTORIAL_ID_GHOST_NEW_FEATURE = 34, false, // TUTORIAL_ID_GHOST_NEW_FEATURE = 34,
true, //TUTORIAL_ID_GHOST_REGION_MAP = 35 false, // TUTORIAL_ID_UNUSED_35 = 35,
false, // TUTORIAL_ID_GHOST_EXPEDITION_NEW = 36,
false, // TUTORIAL_ID_GHOST_EXPEDITION_WANTED = 37,
false, // TUTORIAL_ID_GHOST_EXPEDITION_WANTED2 = 38,
false, // TUTORIAL_ID_GHOST_EXPEDITION_REWARD = 39,
false, // TUTORIAL_ID_MULTI_GHOST_VS_2 = 40,
false, // TUTORIAL_ID_MULTI_GHOST_VS_3 = 41,
false, // TUTORIAL_ID_GHOST_SELECT_BY_OTHER_PLACE = 42,
false, // TUTORIAL_ID_GHOST_SELECT_BY_MANUFACTURER = 43,
false, // TUTORIAL_ID_GHOST_SELECT_BY_OTHER_MANUFACTURER = 44,
false, // TUTORIAL_ID_GHOST_SELECT_BY_PLAYED = 45,
false, // TUTORIAL_ID_GHOST_HIGHWAY_NEW = 46,
false, // TUTORIAL_ID_GHOST_HIGHWAY_STATION = 47,
false, // TUTORIAL_ID_GHOST_HIGHWAY_BOSS = 48,
false, // TUTORIAL_ID_GHOST_TROPHY = 49,
false, // TUTORIAL_ID_GHOST_SELECT = 50,
false, // TUTORIAL_ID_GHOST_SELECT_BY_SAME_PLACE = 51
], ],
} }
}); });
@ -141,6 +162,14 @@ export default class UserModule extends Module {
console.log('Done!'); console.log('Done!');
} }
}
// New card registration is not allowed / closed
else
{
console.log('New card / user registration is closed');
msg.error = wm.wm.protobuf.ErrorCode.ERR_REQUEST;
}
// Encode the response // Encode the response
let message = wm.wm.protobuf.LoadUserResponse.encode(msg); let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
@ -258,6 +287,7 @@ export default class UserModule extends Module {
} }
// else{} User don't have a car... returning default windowStickerString and windowStickerFont value // else{} User don't have a car... returning default windowStickerString and windowStickerFont value
// Check if last played id is null
if(user.cars[0].lastPlayedPlaceId === null || user.cars[0].lastPlayedPlaceId === undefined) if(user.cars[0].lastPlayedPlaceId === null || user.cars[0].lastPlayedPlaceId === undefined)
{ {
for(let i=0; i<user.cars.length; i++) for(let i=0; i<user.cars.length; i++)
@ -481,20 +511,10 @@ export default class UserModule extends Module {
} }
} }
if(!ocmEventDate) // OCM HoF Ghost Registered from Terminal
{
let ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: {
competitionEndAt: 'desc',
}
});
if(ocmEventDate)
{
let checkRegisteredGhost = await prisma.ghostRegisteredFromTerminal.findFirst({ let checkRegisteredGhost = await prisma.ghostRegisteredFromTerminal.findFirst({
where:{ where:{
carId: user.cars[i].carId, carId: user.cars[i].carId,
competitionId: ocmEventDate.competitionId
} }
}); });
@ -507,8 +527,6 @@ export default class UserModule extends Module {
carStates[i].hasOpponentGhost = false; carStates[i].hasOpponentGhost = false;
} }
} }
}
}
// Participated to OCM Event // Participated to OCM Event
if(ParticipationMainDrawCounter > 0) if(ParticipationMainDrawCounter > 0)

View File

@ -43,18 +43,22 @@ export function getBigIntFromLong(n: Long)
return Number(bigInt); return Number(bigInt);
} }
// Undefined Input Sanitization
export function sanitizeInput(value: any) export function sanitizeInput(value: any)
{ {
return (value == null || value == undefined) ? undefined : value; return (value == null || value == undefined) ? undefined : value;
} }
// Undefined and Zero Input Sanitization
export function sanitizeInputNotZero(value: any) export function sanitizeInputNotZero(value: any)
{ {
return (value !== null && value !== undefined && value !== 0) ? value : undefined; return (value !== null && value !== undefined && value !== 0) ? value : undefined;
} }
// Get Time Stamp
export function getTimeStamp(date: Date = new Date()) export function getTimeStamp(date: Date = new Date())
{ {
// Return a timestamp string for the current / provided time // Return a timestamp string for the current / provided time

View File

@ -205,9 +205,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
if (ghostResultCrown) if (ghostResultCrown)
{ {
let carId: number = 0; let carId: number = 0;
if(body.car?.carId) if(body.carId)
{ {
carId = Number(body.car.carId); carId = Number(body.carId);
} }
// Ghost Crown update data // Ghost Crown update data
@ -338,6 +338,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
await ghost_history.saveGhostHistory(body); await ghost_history.saveGhostHistory(body);
// Return Stamp (Shuttle Match)
await ghost_stamp.shuttleReturnStamp(body);
break; break;
} }
@ -421,6 +424,35 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
break; break;
} }
// Ghost Battle Appointment (VS HoF Ghost) (9)
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_APPOINTMENT:
{
console.log('OCM Ghost Mode Found - Appointment (VS HoF Ghost)');
// Defeated HoF Ghost
if(body.rgResult!.opponents![0].result >= 0)
{
// Delete all the records
await prisma.ghostRegisteredFromTerminal.deleteMany({
where:{
carId: Number(body.carId)
}
});
}
break;
}
// Ghost Battle Default Opponent (10)
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_DEFAULT_OPPONENT:
{
console.log('Normal Ghost Mode Found - Default Opponent');
// TODO: idk
break;
}
// OCM Ghost Battle Mode (11) // OCM Ghost Battle Mode (11)
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_COMPETITION: case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_COMPETITION:
{ {
@ -484,10 +516,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
break; break;
} }
// Ghost Battle Select from Bookmars (12) // Ghost Battle Select from Bookmarks (12)
case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_BOOKMARKS: case wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_BOOKMARKS:
{ {
console.log('Normal Ghost Mode Found - Select from Bookmars'); console.log('Normal Ghost Mode Found - Select from Bookmarks');
ghost_historys = await ghost_history.saveGhostHistory(body); ghost_historys = await ghost_history.saveGhostHistory(body);

View File

@ -142,7 +142,7 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
saveExGhostHistory.result = rgResult.opponents[0].result; saveExGhostHistory.result = rgResult.opponents[0].result;
} }
// Get played Area // Get area
if(common.sanitizeInput(rgResult.path)) if(common.sanitizeInput(rgResult.path))
{ {
let getArea = await ghost_get_area_from_path.getArea(rgResult.path); let getArea = await ghost_get_area_from_path.getArea(rgResult.path);
@ -210,6 +210,7 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
if(countGBR!.result < saveExGhostHistory.result) if(countGBR!.result < saveExGhostHistory.result)
{ {
console.log('OCM Ghost Tally found'); console.log('OCM Ghost Tally found');
// 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)
{ {
@ -330,8 +331,7 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
// Get OCM Period ID // Get OCM Period ID
let OCM_periodId = await prisma.oCMPeriod.findFirst({ let OCM_periodId = await prisma.oCMPeriod.findFirst({
where:{ where:{
competitionDbId: ocmEventDate!.dbId, competitionId: ocmEventDate!.competitionId,
competitionId: ocmEventDate!.competitionId
}, },
orderBy:{ orderBy:{
periodId: 'desc' periodId: 'desc'
@ -360,6 +360,7 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
if(ocmTallyfind) if(ocmTallyfind)
{ {
console.log('Updating OCM Tally Record'); console.log('Updating OCM Tally Record');
// Update the OCM Tally Record // Update the OCM Tally Record
await prisma.oCMTally.update({ await prisma.oCMTally.update({
where:{ where:{

View File

@ -381,7 +381,8 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
} }
if(i === 0){ if(i === 0)
{
console.log('Making OCM Top 1 Ghost Data'); console.log('Making OCM Top 1 Ghost Data');
// Create Top 1 ghost data // Create Top 1 ghost data

View File

@ -24,12 +24,12 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
} }
// Get the area // Get the area
let area; let area: Number = 0;
if(rgResult.path) if(rgResult.path)
{ {
let getArea = await ghost_get_area_from_path.getArea(rgResult.path); let getArea = await ghost_get_area_from_path.getArea(rgResult.path);
area = getArea.area; area = Number(getArea.area);
} }
// Check how many opponents available // Check how many opponents available

View File

@ -1,5 +1,4 @@
import { prisma } from "../.."; import { prisma } from "../..";
import { OCMTop1GhostTrail } from "@prisma/client";
// Import Proto // Import Proto
import * as ghost_ocm_area from "./ghost_ocm_area"; import * as ghost_ocm_area from "./ghost_ocm_area";

View File

@ -1,2 +1,2 @@
yarn dev node dist
pause pause

View File

@ -1360,13 +1360,6 @@ chalk@^4.0.0:
ansi-styles "^4.1.0" ansi-styles "^4.1.0"
supports-color "^7.1.0" supports-color "^7.1.0"
chancer@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/chancer/-/chancer-2.0.2.tgz#20b5e6a2009a2987a639f64d93670532ac6f4868"
integrity sha512-MFRbifjvvkHTTDyWtDDv5tWhRyFfR6ZvWVuRxdMnycaGFipjn5MHZC593MTuhNZatyQlys1eAfW+eUX4L2eJpA==
dependencies:
mersenne-twister "^1.0.1"
charenc@0.0.2: charenc@0.0.2:
version "0.0.2" version "0.0.2"
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
@ -1964,11 +1957,6 @@ merge-descriptors@1.0.1:
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==
mersenne-twister@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a"
integrity sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA==
methods@~1.1.2: methods@~1.1.2:
version "1.1.2" version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"

1
yarn_build_protos.bat Normal file
View File

@ -0,0 +1 @@
yarn build_protos

1
yarn_dev.bat Normal file
View File

@ -0,0 +1 @@
yarn dev

2
yarn_prisma.bat Normal file
View File

@ -0,0 +1,2 @@
yarn prisma generate
yarn prisma migrate deploy