Merge pull request #54 from shiroikitsu8/master-asakura
fix broken gtWing saving, OCM HoF again
This commit is contained in:
commit
3a73a611b1
@ -423,7 +423,7 @@ export default class GhostModule extends Module {
|
||||
ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
orderBy: [
|
||||
{
|
||||
dbId: 'desc'
|
||||
competitionId: 'desc'
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -704,7 +704,8 @@ export default class GhostModule extends Module {
|
||||
let msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
competitionId: competition_id,
|
||||
ghostCar: ghostCars!,
|
||||
specialGhostId: competition_id,
|
||||
ghostCar: ghostCars,
|
||||
trailId: ghostTrailId,
|
||||
updatedAt: date,
|
||||
competitionSchedule: competitionSchedule || null
|
||||
|
@ -907,13 +907,16 @@ export default class TerminalModule extends Module {
|
||||
// Get the information from the request
|
||||
let body = wm.wm.protobuf.RegisterOpponentGhostRequest.decode(req.body);
|
||||
|
||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
let getHoFCarId = await prisma.oCMTop1Ghost.findFirst({
|
||||
where:{
|
||||
competitionId: body.specialGhostId,
|
||||
},
|
||||
orderBy: {
|
||||
competitionEndAt: 'desc',
|
||||
periodId: 'desc',
|
||||
}
|
||||
});
|
||||
|
||||
if(ocmEventDate)
|
||||
if(getHoFCarId)
|
||||
{
|
||||
let checkRegisteredGhost = await prisma.ghostRegisteredFromTerminal.findFirst({
|
||||
where:{
|
||||
@ -921,23 +924,13 @@ export default class TerminalModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
let getNo1OCM = await prisma.oCMTally.findFirst({
|
||||
where:{
|
||||
competitionId: ocmEventDate.competitionId,
|
||||
periodId: 999999999
|
||||
},
|
||||
orderBy:{
|
||||
competitionId: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
if(!(checkRegisteredGhost))
|
||||
{
|
||||
await prisma.ghostRegisteredFromTerminal.create({
|
||||
data:{
|
||||
carId: body.carId,
|
||||
competitionId: ocmEventDate!.competitionId,
|
||||
opponentCarId: getNo1OCM!.carId
|
||||
competitionId: body.specialGhostId,
|
||||
opponentCarId: getHoFCarId.carId,
|
||||
}
|
||||
});
|
||||
|
||||
@ -951,15 +944,13 @@ export default class TerminalModule extends Module {
|
||||
},
|
||||
data:{
|
||||
carId: body.carId,
|
||||
competitionId: ocmEventDate!.competitionId,
|
||||
opponentCarId: getNo1OCM!.carId
|
||||
competitionId: body.specialGhostId,
|
||||
opponentCarId: getHoFCarId.carId,
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Updating Register Ghost Opponent entry')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Response data
|
||||
@ -1021,6 +1012,24 @@ export default class TerminalModule extends Module {
|
||||
});
|
||||
|
||||
|
||||
app.post('/method/save_screenshot', async (req, res) => {
|
||||
|
||||
// Get the information from the request
|
||||
let body = wm.wm.protobuf.SaveScreenshotRequest.decode(req.body);
|
||||
|
||||
// Response data
|
||||
let msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
};
|
||||
|
||||
// Encode the response
|
||||
let message = wm.wm.protobuf.SaveScreenshotResponse.encode(msg);
|
||||
|
||||
// Send the response to the client
|
||||
common.sendResponse(message, res);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
app.post('/method/load_unreceived_user_items', async (req, res) => {
|
||||
|
||||
@ -1040,24 +1049,6 @@ export default class TerminalModule extends Module {
|
||||
})
|
||||
|
||||
|
||||
app.post('/method/save_screenshot', async (req, res) => {
|
||||
|
||||
// Get the information from the request
|
||||
let body = wm.wm.protobuf.SaveScreenshotRequest.decode(req.body);
|
||||
|
||||
// Response data
|
||||
let msg = {
|
||||
error: wmsrv.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
};
|
||||
|
||||
// Encode the response
|
||||
let message = wmsrv.wm.protobuf.SaveScreenshotResponse.encode(msg);
|
||||
|
||||
// Send the response to the client
|
||||
common.sendResponse(message, res);
|
||||
})
|
||||
|
||||
|
||||
app.post('/method/check_item_receivable_cars', async (req, res) => {
|
||||
|
||||
// Get the information from the request
|
||||
|
@ -134,10 +134,18 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
data: {
|
||||
...dataGhost,
|
||||
...dataCar,
|
||||
...dataCarGTWing,
|
||||
}
|
||||
});
|
||||
|
||||
await prisma.carGTWing.update({
|
||||
where: {
|
||||
dbId: body.carId
|
||||
},
|
||||
data:{
|
||||
...dataCarGTWing,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// --------------GHOST BATTLE SELECTION MODE--------------
|
||||
// Calling save ghost history battle function (BASE_PATH/src/util/games/games_util/ghost_history.ts)
|
||||
|
@ -6,93 +6,19 @@ import * as ghost_ocm_area from "./ghost_ocm_area";
|
||||
import * as ghost_area from "./ghost_area";
|
||||
|
||||
|
||||
// Save ghost battle result
|
||||
// Get OCM Ghost Trail
|
||||
export async function getOCMGhostTrail(carId: number, trailId: number)
|
||||
{
|
||||
// Get current date
|
||||
let date = Math.floor(new Date().getTime() / 1000);
|
||||
|
||||
// Get current / previous active OCM Event
|
||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
let ghost_trails = await prisma.oCMTop1GhostTrail.findFirst({
|
||||
where: {
|
||||
// qualifyingPeriodStartAt is less than current date
|
||||
qualifyingPeriodStartAt: { lte: date },
|
||||
|
||||
// competitionEndAt is greater than current date
|
||||
competitionEndAt: { gte: date },
|
||||
},
|
||||
orderBy:
|
||||
{
|
||||
competitionEndAt: 'desc',
|
||||
carId: carId,
|
||||
dbId: trailId,
|
||||
}
|
||||
});
|
||||
|
||||
if(!(ocmEventDate))
|
||||
{
|
||||
ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
orderBy:
|
||||
{
|
||||
competitionEndAt: 'desc',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let ghost_trails: OCMTop1GhostTrail | null;
|
||||
// Current date is OCM main draw
|
||||
if(ocmEventDate!.competitionStartAt < date && ocmEventDate!.competitionCloseAt > date)
|
||||
{
|
||||
// Get Current OCM Period
|
||||
let OCMCurrentPeriod = await prisma.oCMPeriod.findFirst({
|
||||
where: {
|
||||
competitionDbId: ocmEventDate!.dbId,
|
||||
startAt:
|
||||
{
|
||||
lte: date, // competitionStartAt is less than current date
|
||||
},
|
||||
closeAt:
|
||||
{
|
||||
gte: date, // competitionCloseAt is greater than current date
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ghost_trails = await prisma.oCMTop1GhostTrail.findFirst({
|
||||
where: {
|
||||
carId: carId,
|
||||
dbId: trailId,
|
||||
competitionId: ocmEventDate!.competitionId,
|
||||
periodId: OCMCurrentPeriod!.periodId
|
||||
},
|
||||
orderBy: {
|
||||
playedAt: 'desc'
|
||||
}
|
||||
});
|
||||
}
|
||||
// Current date is OCM qualifying day
|
||||
else if(ocmEventDate!.qualifyingPeriodStartAt < date && ocmEventDate!.qualifyingPeriodCloseAt > date)
|
||||
{
|
||||
ghost_trails = await prisma.oCMTop1GhostTrail.findFirst({
|
||||
where: {
|
||||
carId: carId,
|
||||
dbId: trailId,
|
||||
competitionId: ocmEventDate!.competitionId,
|
||||
periodId: 0
|
||||
},
|
||||
orderBy: {
|
||||
playedAt: 'desc'
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ghost_trails = await prisma.oCMTop1GhostTrail.findFirst({
|
||||
where: {
|
||||
carId: carId,
|
||||
dbId: trailId,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let areaVal = 0;
|
||||
let rampVal = 0;
|
||||
let pathVal = 0;
|
||||
@ -124,6 +50,21 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
|
||||
{
|
||||
console.log('OCM Ghost Trail not found');
|
||||
|
||||
// Get current / previous active OCM Event
|
||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
where: {
|
||||
// qualifyingPeriodStartAt is less than current date
|
||||
qualifyingPeriodStartAt: { lte: date },
|
||||
|
||||
// competitionEndAt is greater than current date
|
||||
competitionEndAt: { gte: date },
|
||||
},
|
||||
orderBy:
|
||||
{
|
||||
competitionEndAt: 'desc',
|
||||
}
|
||||
});
|
||||
|
||||
// Calling OCM Area function (BASE_PATH/src/util/games/ghost_ocm.ts)
|
||||
let OCMArea = await ghost_ocm_area.OCMArea(ocmEventDate!.competitionId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user