1
0
mirror of synced 2025-02-23 21:43:21 +01:00

fix user's stamp value when sending stamp

This commit is contained in:
Shiroi Kitsu 2023-05-27 10:06:29 +07:00
parent 5641dbddca
commit beb92ac4eb
5 changed files with 93 additions and 51 deletions

View File

@ -96,17 +96,17 @@ if (useSentry) {
} }
app.use((req, res, next) => { app.use((req, res, next) => {
console.log(timestamp+` [ MAIN] ${req.method} ${req.url}`); common.writeLog(`[ MAIN] ${req.method} ${req.url}`);
next() next()
}); });
muchaApp.use((req, res, next) => { muchaApp.use((req, res, next) => {
console.log(timestamp+` [ MUCHA] ${req.method} ${req.url}`); common.writeLog(`[ MUCHA] ${req.method} ${req.url}`);
next() next()
}); });
allnetApp.use((req, res, next) => { allnetApp.use((req, res, next) => {
console.log(timestamp+` [ALLNET] ${req.method} ${req.url}`); common.writeLog(`[ALLNET] ${req.method} ${req.url}`);
next() next()
}); });
@ -134,7 +134,7 @@ app.use('/', appRouter);
app.use('/wmmt6/', appRouter); app.use('/wmmt6/', appRouter);
app.all('*', (req, res) => { app.all('*', (req, res) => {
console.log(timestamp+` [ MAIN] ${req.method} ${req.url} is unhandled`); common.writeLog(`[ MAIN] ${req.method} ${req.url} is unhandled`);
res.status(200).end(); res.status(200).end();
}) })

View File

@ -3,7 +3,7 @@ import { wm } from "../../../wmmt/wm.proto";
// Save story result // Save story result
export async function checkCurrentStep(body: wm.protobuf.SaveGameResultRequest) export async function checkCurrentStep(body: wm.protobuf.SaveGameResultRequest, car: any)
{ {
// Get current step for updating the user's ghost level // Get current step for updating the user's ghost level
let currentStep = 0; let currentStep = 0;
@ -11,45 +11,48 @@ export async function checkCurrentStep(body: wm.protobuf.SaveGameResultRequest)
// Set current ghost level based on current step // Set current ghost level based on current step
let ghostLevel = 1; let ghostLevel = 1;
if(currentStep >= 0 && currentStep <= 5) if(car.ghostLevel < 11)
{ {
ghostLevel = 1 if(currentStep >= 0 && currentStep <= 5)
} {
else if(currentStep >= 6 && currentStep <= 10) ghostLevel = 1
{ }
ghostLevel = 2 else if(currentStep >= 6 && currentStep <= 10)
} {
else if(currentStep >= 11 && currentStep <= 15) ghostLevel = 2
{ }
ghostLevel = 3 else if(currentStep >= 11 && currentStep <= 15)
} {
else if(currentStep >= 16 && currentStep <= 20) ghostLevel = 3
{ }
ghostLevel = 4 else if(currentStep >= 16 && currentStep <= 20)
} {
else if(currentStep >= 21 && currentStep <= 26) ghostLevel = 4
{ }
ghostLevel = 5 else if(currentStep >= 21 && currentStep <= 26)
} {
else if(currentStep >= 27 && currentStep <= 28) ghostLevel = 5
{ }
ghostLevel = 6 else if(currentStep >= 27 && currentStep <= 28)
} {
else if(currentStep >= 29 && currentStep <= 30) ghostLevel = 6
{ }
ghostLevel = 7 else if(currentStep >= 29 && currentStep <= 30)
} {
else if(currentStep === 31) ghostLevel = 7
{ }
ghostLevel = 8 else if(currentStep === 31)
} {
else if(currentStep >= 32 && currentStep <= 33) ghostLevel = 8
{ }
ghostLevel = 9 else if(currentStep >= 32 && currentStep <= 33)
} {
else if(currentStep === 34) ghostLevel = 9
{ }
ghostLevel = 10 else if(currentStep === 34)
{
ghostLevel = 10
}
} }
// Return the value to 'BASE_PATH/src/util/games/story.ts' // Return the value to 'BASE_PATH/src/util/games/story.ts'

View File

@ -57,7 +57,7 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
} }
// Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts) // Calling check step function (BASE_PATH/src/util/games/games_util/check_step.ts)
let check_steps = await check_step.checkCurrentStep(body); let check_steps = await check_step.checkCurrentStep(body, car);
// Set the ghost level to the correct level // Set the ghost level to the correct level
data.ghostLevel = check_steps.ghostLevel; data.ghostLevel = check_steps.ghostLevel;

View File

@ -16,15 +16,23 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
if(rgResult) if(rgResult)
{ {
// Stamp must bigger than 0 // Get Sender Stamp Data
let rgStamp = rgResult.rgStamp; let carStamp = await prisma.car.findFirst({
where:{
carId: body.carId
},
select:{
rgStamp: true
}
});
let rgStamp:number = carStamp!.rgStamp;
if(rgStamp === 0) if(rgStamp === 0)
{ {
rgStamp = 1; rgStamp = 1;
} }
// Get the area // Get the area
let area: Number = 0; 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);
@ -110,20 +118,29 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
if(rgResult) if(rgResult)
{ {
// Stamp must bigger than 0 // Get Sender Stamp Data
let rgStamp = rgResult.rgStamp; let carStamp = await prisma.car.findFirst({
where:{
carId: body.carId
},
select:{
rgStamp: true
}
})
let rgStamp:number = carStamp!.rgStamp;
if(rgStamp === 0) if(rgStamp === 0)
{ {
rgStamp = 1; rgStamp = 1;
} }
// 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

@ -95,4 +95,26 @@ 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
return String("[" + date.toLocaleString() + "]"); return String("[" + date.toLocaleString() + "]");
}
// Write Log
export async function writeLog(message: string)
{
try {
// Get the current timestamp
const timestamp: string = getTimeStamp();
// Full message placeholder
let fullMessage: string;
// Generate the message content, write to console
fullMessage = timestamp + ': ' + message;
// Log
console.log(fullMessage);
}
catch {
// Failed
}
} }