fix user's stamp value when sending stamp
This commit is contained in:
parent
5641dbddca
commit
beb92ac4eb
@ -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();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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,6 +11,8 @@ 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(car.ghostLevel < 11)
|
||||||
|
{
|
||||||
if(currentStep >= 0 && currentStep <= 5)
|
if(currentStep >= 0 && currentStep <= 5)
|
||||||
{
|
{
|
||||||
ghostLevel = 1
|
ghostLevel = 1
|
||||||
@ -51,6 +53,7 @@ export async function checkCurrentStep(body: wm.protobuf.SaveGameResultRequest)
|
|||||||
{
|
{
|
||||||
ghostLevel = 10
|
ghostLevel = 10
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return the value to 'BASE_PATH/src/util/games/story.ts'
|
// Return the value to 'BASE_PATH/src/util/games/story.ts'
|
||||||
return {ghostLevel}
|
return {ghostLevel}
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -96,3 +96,25 @@ 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user