Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"revisionCheck": 1,
"enableScreenshot": 0,
"ghostTrailAutodeleteDays": 0
}
},
"notices": []
}
5 changes: 1 addition & 4 deletions src/modules/cars/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,7 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
126, // DIABLO
130, // JW5
131, // AP2
133, // PS13
137, // NDERC
138, // UF31
139, // GS130
133 // PS13
];

let carVisualModelWithoutItem = [
Expand Down
17 changes: 14 additions & 3 deletions src/modules/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,15 @@ export default class GameModule {
// Perform the save screenshot request for the car
await gameFunction.saveScreenshot(body);

if (body.imageType == 7)
if (body.imageType == 1)
{
if (body.ghostMetadata!.opponents!.length > 1) return // skip check if is opponent is more than 1
// Check obtained crown
let getCarCrown = await prisma.carCrownDetect.findFirst({
where:{
carId: body.carId,
playedAt: body.playedAt
area: body.ghostMetadata?.area,
opponentCarId: body.ghostMetadata?.opponents![0].carId
}
});

Expand All @@ -283,7 +285,7 @@ export default class GameModule {
{
let timestamp = body.playedAt - body.timestamp;

if(timestamp <= 30)
if(timestamp <= 60)
{
console.log('Crown Force Finish Detected');

Expand Down Expand Up @@ -359,6 +361,15 @@ export default class GameModule {
}
});
}
else
{
// Delete after legit check
await prisma.carCrownDetect.delete({
where: {
id: getCarCrown.id
}
});
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/modules/game/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ export async function getGhostBattleRecord(body: wm.protobuf.LoadGameHistoryRequ
});

// If opponent is default ghost or random ghost
if(!(ghostOpponentCar))
{
if(!ghostOpponentCar)
{
ghostOpponentCar = await prisma.car.findFirst({});
ghostOpponentCar!.name = 'S660';
ghostOpponentCar!.manufacturer = 12;
Expand Down Expand Up @@ -366,7 +366,7 @@ export async function getGhostBattleRecord(body: wm.protobuf.LoadGameHistoryRequ
});

// If opponent is default ghost or random ghost
if(!(ghostOpponentCar2))
if(!ghostOpponentCar2)
{
ghostOpponentCar2 = await prisma.car.findFirst({});
ghostOpponentCar2!.name = 'S660';
Expand Down Expand Up @@ -401,8 +401,8 @@ export async function getGhostBattleRecord(body: wm.protobuf.LoadGameHistoryRequ
});

// If opponent is default ghost or random ghost
if(!(ghostOpponentCar3))
{
if(!ghostOpponentCar3)
{
ghostOpponentCar3 = await prisma.car.findFirst({});
ghostOpponentCar3!.name = 'S660';
ghostOpponentCar3!.manufacturer = 12;
Expand Down
24 changes: 14 additions & 10 deletions src/modules/game/ghost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
let OCMModePlay: boolean = false;

// If the game was not retired / timed out
if (!(body.retired || body.timeup))
if (!(body.retired || body.timeup))
{
console.log('Saving Ghost Battle Result');

Expand Down Expand Up @@ -323,10 +323,12 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
data: {
carId: body.carId,
status: 'finish',
area: area,
ramp: ramp,
path: path,
...dataCrown
area: carCrowns.area,
ramp: carCrowns.ramp,
path: carCrowns.path,
playedAt: carCrowns.playedAt,
tunePower: carCrowns.tunePower,
tuneHandling: carCrowns.tuneHandling
}
});

Expand All @@ -350,10 +352,12 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
data: {
carId: body.carId,
status: 'finish',
area: area,
ramp: ramp,
path: path,
...dataCrown
area: carCrowns.area,
ramp: carCrowns.ramp,
path: carCrowns.path,
playedAt: carCrowns.playedAt,
tunePower: carCrowns.tunePower,
tuneHandling: carCrowns.tuneHandling
}
});

Expand Down Expand Up @@ -726,7 +730,7 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
export async function deleteGhostTrail(body: wm.protobuf.SaveGameResultRequest, ghostTrailDays: number)
{
// if is not retired or time up
if (!(body.retired || body.timeup))
if (!(body.retired || body.timeup))
{
// if n days of ghost trail is set
if(ghostTrailDays != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as check_step from "./games_util/check_step";
export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, car: any)
{
// If the game was not retired / timed out
if (!(body.retired || body.timeup))
if (!(body.retired || body.timeup))
{
console.log('Game not retired / timed out, continuing ...')

Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/time_attack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function saveTimeAttackResult(body: wm.protobuf.SaveGameResultReque
let cheatedTime: boolean = false;

// If the game was not retired / timed out
if (!(body.retired || body.timeup))
if (!(body.retired || body.timeup))
{
console.log('Game not retired / timed out, continuing ...')

Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/versus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as common from "../util/common";
// Save versus battle result
export async function saveVersusBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
{
if (!(body.retired))
if (!body.retired)
{
// Get the car
let cars = body?.car;
Expand Down
25 changes: 8 additions & 17 deletions src/modules/ghost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,16 @@ export default class GhostModule {
}
});

if(getUserId)
if(getUserId?.userBanned)
{
if(getUserId.userBanned === false)
{
// Encode the response
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);
return res.status(500);
}

// Send the response to the client
common.sendResponse(message, res, req.rawHeaders);
}
}
else
{
// Encode the response
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);
// Encode the response
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);

// Send the response to the client
common.sendResponse(message, res, req.rawHeaders);
}
// Send the response to the client
common.sendResponse(message, res, req.rawHeaders);
})


Expand Down Expand Up @@ -326,7 +317,7 @@ export default class GhostModule {
else if(actualSessionId > 0 && actualSessionId < 101)
{
// Check if it is crown ghost battle or not (crown ghost battle don't have time, driveData, trendBinaryByArea, trendBinaryByCar, trendBinaryByUser value from request body)
if(!(body.trendBinaryByArea) && !(body.trendBinaryByCar) && !(body.trendBinaryByUser))
if(!body.trendBinaryByArea && !body.trendBinaryByCar && !body.trendBinaryByUser)
{
console.log('Crown Ghost Battle Game found');

Expand Down
2 changes: 1 addition & 1 deletion src/modules/ghost/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export async function getGhostCar(car: any, area: number, ramp: number, path: nu
}

// Push user's car data without ghost trail
if(!(ghost_trails))
if(!ghost_trails)
{
lists_ghostcar.push(wmproto.wm.protobuf.GhostCar.create({
car: car[random]
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ghost/ghost_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques
});

// Period ID not found
if(!(OCM_periodId))
if(!OCM_periodId)
{
OCM_periodId = await prisma.oCMPeriod.findFirst({
where:{
Expand Down
2 changes: 1 addition & 1 deletion src/modules/ghost/ghost_stamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)
})

// No record found
if(!(stampTarget))
if(!stampTarget)
{
console.log('Creating new stamp entry');

Expand Down
33 changes: 17 additions & 16 deletions src/modules/ghost_ocm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,26 +400,28 @@ export default class GhostModule {
let pathVal: number = OCMArea.pathVal;

// Get url query parameter (period_id)
let period_id = Number(req.query.period_id);
let period_id = Number(req.query.period_id);

// Get current date
let date = Math.floor(new Date().getTime() / 1000);

// Get currently active OCM event
let ocmEventDate = await prisma.oCMEvent.findFirst({
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
// competitionId
competitionId: competition_id
// qualifyingPeriodStartAt is less than current date
qualifyingPeriodStartAt: { lte: date },
// qualifyingPeriodStartAt: { lte: date },

// competitionEndAt is greater than current date
competitionEndAt: { gte: date },
// competitionEndAt: { gte: date },
},
orderBy:{
competitionId: 'desc'
}
});

if(!(ocmEventDate))
if(!ocmEventDate)
{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy:{
Expand All @@ -432,7 +434,7 @@ export default class GhostModule {
let ghostCars: wm.wm.protobuf.GhostCar;
let ghostTypes;
let cars: wm.wm.protobuf.ICar | null;
let playedPlace = wm.wm.protobuf.Place.create({
let playedPlace = wm.wm.protobuf.Place.create({
placeId: Config.getConfig().placeId,
regionId: Config.getConfig().regionId,
shopName: Config.getConfig().shopName,
Expand Down Expand Up @@ -460,7 +462,7 @@ export default class GhostModule {
});

// Get Top 1 qualifying ghost trail id
let checkGhostTrail = await prisma.oCMTop1GhostTrail.findFirst({
let checkGhostTrail = await prisma.oCMTop1GhostTrail.findFirst({
where:{
carId: ocmTallyRecord!.carId,
competitionId: ocmEventDate!.competitionId,
Expand All @@ -473,7 +475,7 @@ export default class GhostModule {

// Top 1 OCM Ghost trail data available
if(checkGhostTrail)
{
{
// Get the Top 1 OCM car data
cars = await prisma.car.findFirst({
where:{
Expand Down Expand Up @@ -502,10 +504,10 @@ export default class GhostModule {
}
// Current date is OCM qualifying day
else if(ocmEventDate!.qualifyingPeriodStartAt < date && ocmEventDate!.qualifyingPeriodCloseAt > date)
{
{
console.log('OCM Qualifying Day');

// Get the default ghost trail
// Get the default ghost trail
let checkGhostTrail = await prisma.oCMTop1GhostTrail.findFirst({
where:{
carId: 999999999,
Expand Down Expand Up @@ -561,7 +563,7 @@ export default class GhostModule {
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
}
else if(ocmEventDate!.competitionCloseAt < date && ocmEventDate!.competitionEndAt > date)
{
{
// TODO: Actual stuff here
// This is literally just bare-bones so the shit boots
}
Expand All @@ -577,7 +579,7 @@ export default class GhostModule {
},
orderBy:{
result: 'desc'
},
}
});

// Get Top 1 qualifying ghost trail id
Expand All @@ -588,12 +590,12 @@ export default class GhostModule {
},
orderBy:{
playedAt: 'desc'
},
}
});

// Top 1 OCM Ghost trail data available
if(checkGhostTrail)
{
{
// Get the Top 1 OCM car data
cars = await prisma.car.findFirst({
where:{
Expand All @@ -606,7 +608,7 @@ export default class GhostModule {
});

// Set the tunePower used when playing ghost crown
cars!.tunePower = ocmTallyRecord!.tunePower;
cars!.tunePower = ocmTallyRecord!.tunePower;

// Set the tuneHandling used when playing ghost crown
cars!.tuneHandling = ocmTallyRecord!.tuneHandling;
Expand All @@ -631,7 +633,6 @@ export default class GhostModule {
cars!.lastPlayedPlace!.shopName = checkShopName.playedShopName;
}


let ocmEventDate = await prisma.oCMEvent.findFirst({
where:{
competitionId: competition_id
Expand Down
8 changes: 6 additions & 2 deletions src/modules/startup/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function competitionSchedule(date: any, competitionId: any)

// Currently no Active Competition (OCM) Event.. Getting Previous Competition (OCM) Event
let pastEvent = 0;
if(!(ghostCompetitionSchedule))
if(!ghostCompetitionSchedule)
{
ghostCompetitionSchedule = await prisma.oCMEvent.findFirst({
orderBy:{
Expand Down Expand Up @@ -96,6 +96,11 @@ export async function competitionSchedule(date: any, competitionId: any)
// idk what this is
minigamePatternId: ghostCompetitionSchedule.minigamePatternId
});

// hof menu while OCM is ongoing
if(ghostCompetitionSchedule.competitionId > 1) {
lastCompetitionId = ghostCompetitionSchedule.competitionId -1;
}
}

// It's previous Competition (OCM) event
Expand All @@ -112,7 +117,6 @@ export async function competitionSchedule(date: any, competitionId: any)
competitionId: 'desc'
}
});


lastCompetitionId = lastScheduleCompetitionId?.competitionId || 0;
}
Expand Down
Loading