1
0
mirror of synced 2025-01-22 11:23:40 +01:00
This commit is contained in:
Shiroi Kitsu 2023-01-25 22:54:42 +07:00
parent 8080b7d068
commit 7ca14639fb
16 changed files with 919 additions and 848 deletions

View File

@ -216,7 +216,7 @@ export async function getOpponentsTarget(carId: number, registeredargetAvailable
}
// Get Number of Challengers
numOfChallengers = opponentTarget.length + 1;
numOfChallengers = opponentTargetCount + 1;
}
}

View File

@ -6,8 +6,8 @@ import wmproto from "../../wmmt/wm.proto";
// Import Util
import * as common from "../util/common";
import * as ghost_history from "../../util/ghost/ghost_history";
import * as ghost_stamp from "../../util/ghost/ghost_stamp";
import * as ghost_history from "../ghost/ghost_history";
import * as ghost_stamp from "../ghost/ghost_stamp";
// Save ghost battle result
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)

View File

@ -3,7 +3,6 @@ import { Module } from "module";
import { prisma } from "..";
import { CarPathandTuning } from "@prisma/client";
import Long from "long";
import { Config } from "../config";
// Import Proto
import * as wm from "../wmmt/wm.proto";
@ -11,9 +10,10 @@ import * as wmsrv from "../wmmt/service.proto";
// Import Util
import * as common from "./util/common";
import * as ghost_save_trail from "../util/ghost/ghost_save_trail";
import * as ghost_trail from "../util/ghost/ghost_trail";
import * as ghost_area from "../util/ghost/ghost_area";
import * as ghostFunctions from "./ghost/functions";
import * as ghost_save_trail from "./ghost/ghost_save_trail";
import * as ghost_trail from "./ghost/ghost_util/ghost_trail";
import * as ghost_area from "./ghost/ghost_util/ghost_area";
export default class GhostModule extends Module {
@ -33,152 +33,35 @@ export default class GhostModule extends Module {
gtWing: true,
lastPlayedPlace: true
}
})
});
// Car History
let findChallenger = await prisma.carChallenger.findMany({
where: {
challengerCarId: body.carId
},
orderBy:{
lastPlayedAt: 'desc'
},
take: 10
})
// Get Challenged Opponent History
let getStampTargets = await ghostFunctions.getOpponentHistory(body.carId);
let opponentHistory = getStampTargets.opponentHistory;
let carsHistory: wm.wm.protobuf.Car[] = [];
if(findChallenger.length > 0)
{
for(let i=0; i<findChallenger.length; i++)
{
let car = await prisma.car.findFirst({
where: {
carId: findChallenger[i].carId
},
include:{
gtWing: true,
lastPlayedPlace: true
},
orderBy: {
carId: 'asc'
},
take: 10
});
carsHistory.push(wm.wm.protobuf.Car.create({
...car!
}))
}
}
let carsStamp: wm.wm.protobuf.StampTargetCar[] = [];
let carsChallenger: wm.wm.protobuf.ChallengerCar[] = [];
// Get all of the friend cars for the carId provided
let stampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: body.carId,
recommended: true
},
orderBy:{
locked: 'desc'
}
});
if(stampTargets)
{
for(let i=0; i<stampTargets.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: stampTargets[i].carId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
carsStamp.push(
wm.wm.protobuf.StampTargetCar.create({
car: carTarget!,
returnCount: stampTargets[i].returnCount,
locked: stampTargets[i].locked,
recommended: stampTargets[i].recommended
})
);
}
}
// Get all of the challenger car for the carId provided except beated car
let checkBeatedCar = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: body.carId,
recommended: false
},
orderBy:{
carId: 'asc'
}
});
let arrChallengerCarId = [];
for(let i=0; i<checkBeatedCar.length; i++)
{
arrChallengerCarId.push(checkBeatedCar[i].carId);
}
let challengers = await prisma.carChallenger.findMany({
where: {
carId: body.carId,
NOT: {
challengerCarId: { in: arrChallengerCarId }, // Except beated challenger id
},
}
});
if(challengers)
{
for(let i=0; i<challengers.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: challengers[i].challengerCarId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
let result = 0;
if(challengers[i].result > 0)
{
result = -Math.abs(challengers[i].result);
}
else{
result = Math.abs(challengers[i].result);
}
carsChallenger.push(
wm.wm.protobuf.ChallengerCar.create({
car: carTarget!,
stamp: challengers[i].stamp,
result: result,
area: challengers[i].area
})
);
}
}
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId);
let stampTarget = getStampTarget.stampTarget;
// Get Challengers
let getChallengers = await ghostFunctions.getChallengers(body.carId);
let challengers = getChallengers.challengers;
// Response data
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
stampTargetCars: carsStamp || null,
challengers: carsChallenger || null,
stampSheetCount: car!.stampSheetCount,
// Challengers
challengers: challengers || null,
stampTargetCars: stampTarget || null,
// History
history: opponentHistory || null,
// Stamp
stampSheetCount: car?.stampSheetCount || 0,
stampSheet: car?.stampSheet || null,
stampReturnStats: car?.stampSheet || null,
history: carsHistory || null,
};
// Encode the response
@ -193,93 +76,21 @@ export default class GhostModule extends Module {
app.post('/method/load_stamp_target', async (req, res) => {
// Get the request body for the load stamp target request
let body = wm.wm.protobuf.LoadStampTargetRequest.decode(req.body);
let body = wm.wm.protobuf.LoadStampTargetRequest.decode(req.body);
let carsStamp: wm.wm.protobuf.StampTargetCar[] = [];
let carsChallenger: wm.wm.protobuf.ChallengerCar[] = [];
// Get Stamp Target
let getStampTarget = await ghostFunctions.getStampTarget(body.carId);
let stampTarget = getStampTarget.stampTarget;
// Get all of the friend cars for the carId provided
let stampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: body.carId,
recommended: true
},
orderBy:{
locked: 'asc'
}
});
if(stampTargets)
{
for(let i=0; i<stampTargets.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: stampTargets[i].carId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
carsStamp.push(
wm.wm.protobuf.StampTargetCar.create({
car: carTarget!,
returnCount: stampTargets[i].returnCount,
locked: stampTargets[i].locked,
recommended: stampTargets[i].recommended
})
);
}
}
// Get all of the friend cars for the carId provided
let challengers = await prisma.carChallenger.findMany({
where: {
carId: body.carId
}
});
if(stampTargets)
{
for(let i=0; i<challengers.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: challengers[i].challengerCarId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
let result = 0;
if(challengers[i].result > 0)
{
result = -Math.abs(challengers[i].result);
}
else{
result = Math.abs(challengers[i].result);
}
carsChallenger.push(
wm.wm.protobuf.ChallengerCar.create({
car: carTarget!,
stamp: challengers[i].stamp,
result: result,
area: challengers[i].area
})
);
}
}
// Get Challengers
let getChallengers = await ghostFunctions.getChallengers(body.carId);
let challengers = getChallengers.challengers;
// Response data
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
cars: carsStamp,
challengers: carsChallenger
cars: stampTarget,
challengers: challengers
};
// Encode the response
@ -290,7 +101,7 @@ export default class GhostModule extends Module {
})
// Ghost Mode
// Search Cars by Level
app.post('/method/search_cars_by_level', async (req, res) => {
// Get the request body for the search cars by level request
@ -326,221 +137,36 @@ export default class GhostModule extends Module {
});
}
// Randomizing the starting ramp and path based on selected area
let rampVal = 0;
let pathVal = 0;
// Get the ramp and path id
let ghost_areas = await ghost_area.GhostArea(body.area);
// Set the value
rampVal = ghost_areas.rampVal;
pathVal = ghost_areas.pathVal;
let rampVal = ghost_areas.rampVal;
let pathVal = ghost_areas.pathVal;
// Empty list of ghost car records
let lists_ghostcar: wm.wm.protobuf.GhostCar[] = [];
let arr = [];
let maxNumber = 0;
// If all user car data available is more than 10 for certain level
if(car.length > 10)
{
maxNumber = 10 // Limit to 10 (game default)
}
// If no more than 10
else
{
maxNumber = car.length;
}
// Choose the user's car data randomly to appear
while(arr.length < maxNumber)
{
// Randomize pick
let random: number = 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
arr.push(random);
// Check if ghost trail for certain car is available
let ghost_trails = await prisma.ghostTrail.findFirst({
where: {
carId: car[random].carId,
area: body.area,
crownBattle: false
},
orderBy: {
playedAt: 'desc'
}
});
// Push user's car data without ghost trail
if(!(ghost_trails))
{
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
car: car[random]
}));
}
// Push user's car data with ghost trail
else
{
// Set the tunePower used when playing certain area
car[random].tunePower = ghost_trails!.tunePower;
// Set the tuneHandling used when playing certain area
car[random].tuneHandling = ghost_trails!.tuneHandling;
// Push data to Ghost car proto
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
car: car[random],
nonhuman: false,
type: wm.wm.protobuf.GhostType.GHOST_NORMAL,
trailId: ghost_trails!.dbId!
}));
}
}
}
// Get Ghost Car
let getGhostCar = await ghostFunctions.getGhostCar(car, body.area, rampVal, pathVal);
let lists_ghostcar = getGhostCar.lists_ghostcar;
// Check again if car list for that selected region is available of not
if(body.regionId !== null && body.regionId !== undefined && body.regionId !== 0)
{
if(car.length < 1)
{
// Get current date
let date = Math.floor(new Date().getTime() / 1000);
let playedPlace = wm.wm.protobuf.Place.create({
placeId: Config.getConfig().placeId,
regionId: Config.getConfig().regionId,
shopName: Config.getConfig().shopName,
country: Config.getConfig().country
});
let tunePowerDefault = 0
let tuneHandlingDefault = 0;
if(body.ghostLevel === 1)
{
tunePowerDefault = 1;
tuneHandlingDefault = 4;
}
else if(body.ghostLevel === 2)
{
tunePowerDefault = 5;
tuneHandlingDefault = 5;
}
else if(body.ghostLevel === 3)
{
tunePowerDefault = 8;
tuneHandlingDefault = 7;
}
else if(body.ghostLevel === 4)
{
tunePowerDefault = 10;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 5)
{
tunePowerDefault = 15;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 6)
{
tunePowerDefault = 18;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 7)
{
tunePowerDefault = 20;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 8)
{
tunePowerDefault = 21;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 9)
{
tunePowerDefault = 22;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 10)
{
tunePowerDefault = 24;
tuneHandlingDefault = 10;
}
else if(body.ghostLevel === 11)
{
tunePowerDefault = 24;
tuneHandlingDefault = 24;
}
// Generate default S660 car data
car = wm.wm.protobuf.Car.create({
carId: 999999999, // Don't change this
name: '',
regionId: body.regionId, // IDN (福井)
manufacturer: 12, // HONDA
model: 105, // S660 [JW5]
visualModel: 130, // S660 [JW5]
defaultColor: 0,
customColor: 0,
wheel: 20,
wheelColor: 0,
aero: 0,
bonnet: 0,
wing: 0,
mirror: 0,
neon: 0,
trunk: 0,
plate: 0,
plateColor: 0,
plateNumber: 0,
tunePower: tunePowerDefault,
tuneHandling: tuneHandlingDefault,
rivalMarker: 32,
aura: 551,
windowSticker: true,
windowStickerString: '',
windowStickerFont: 0,
title: 'No Ghost for this Region',
level: 65, // SSSSS
lastPlayedAt: date,
country: 'JPN',
lastPlayedPlace: playedPlace
});
// Push data to Ghost car proto
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
car: car,
nonhuman: true,
type: wm.wm.protobuf.GhostType.GHOST_DEFAULT,
}));
}
// else{} have car list
let checkGhostSearchByRegion = await ghostFunctions.checkGhostSearchByRegion(car, body.ghostLevel, body.regionId);
lists_ghostcar = checkGhostSearchByRegion.lists_ghostcar;
}
// Response data
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
// Area Value
ramp: rampVal,
path: pathVal,
// Ghost Car List
ghosts: lists_ghostcar,
// Ghost Selection Method
selectionMethod: Number(wm.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL)
};
@ -581,7 +207,8 @@ export default class GhostModule extends Module {
// ---Get the user and opponent ghost trail data---
let ghostType: number = wm.wm.protobuf.GhostType.GHOST_NORMAL;
let lists_binarydriveData;
if(ghost_trails?.driveData !== null && ghost_trails?.driveData !== undefined){
if(ghost_trails?.driveData !== null && ghost_trails?.driveData !== undefined)
{
lists_binarydriveData = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.driveData!,
mergeSerial: ghost_trails!.driveDMergeSerial!
@ -589,7 +216,8 @@ export default class GhostModule extends Module {
}
let lists_binaryByArea
if(ghost_trails?.trendBinaryByArea !== null && ghost_trails?.trendBinaryByArea !== undefined){
if(ghost_trails?.trendBinaryByArea !== null && ghost_trails?.trendBinaryByArea !== undefined)
{
lists_binaryByArea = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.trendBinaryByArea!,
mergeSerial: ghost_trails!.byAreaMergeSerial!
@ -597,7 +225,8 @@ export default class GhostModule extends Module {
}
let lists_binaryByCar
if(ghost_trails?.trendBinaryByCar !== null && ghost_trails?.trendBinaryByCar !== undefined){
if(ghost_trails?.trendBinaryByCar !== null && ghost_trails?.trendBinaryByCar !== undefined)
{
lists_binaryByCar = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.trendBinaryByCar!,
mergeSerial: ghost_trails!.byCarMergeSerial!
@ -605,7 +234,8 @@ export default class GhostModule extends Module {
}
let lists_binaryByUser
if(ghost_trails?.trendBinaryByUser !== null && ghost_trails?.trendBinaryByUser !== undefined){
if(ghost_trails?.trendBinaryByUser !== null && ghost_trails?.trendBinaryByUser !== undefined)
{
lists_binaryByUser = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.trendBinaryByUser!,
mergeSerial: ghost_trails!.byUserMergeSerial!
@ -656,6 +286,7 @@ export default class GhostModule extends Module {
actualSessionId = common.getBigIntFromLong(body.ghostSessionId);
}
// -----------------------------------------------------------------------------------------
// OCM game mode session id
if(actualSessionId > 100 && actualSessionId < 201)
{
@ -686,6 +317,7 @@ export default class GhostModule extends Module {
await ghost_save_trail.savePathAndTuning(body);
}
}
// -----------------------------------------------------------------------------------------
// Response data
let msg = {

View File

@ -0,0 +1,367 @@
import { Config } from "../../config";
import { prisma } from "../..";
// Import Proto
import * as wmproto from "../../wmmt/wm.proto";
// Get Challenged Opponent History
export async function getOpponentHistory(carId: number)
{
// Car History
let findChallenger = await prisma.carChallenger.findMany({
where: {
challengerCarId: carId
},
orderBy:{
lastPlayedAt: 'desc'
},
take: 10
})
let opponentHistory: wmproto.wm.protobuf.Car[] = [];
if(findChallenger.length > 0)
{
for(let i=0; i<findChallenger.length; i++)
{
let car = await prisma.car.findFirst({
where: {
carId: findChallenger[i].carId
},
include:{
gtWing: true,
lastPlayedPlace: true
},
orderBy: {
carId: 'asc'
},
take: 10
});
opponentHistory.push(wmproto.wm.protobuf.Car.create({
...car!
}))
}
}
return { opponentHistory }
}
// Get Stamp Target
export async function getStampTarget(carId: number)
{
// Get all of the friend cars for the carId provided
let getStampTargets = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: carId,
recommended: true
},
orderBy:{
locked: 'desc'
}
});
let stampTarget: wmproto.wm.protobuf.StampTargetCar[] = [];
if(getStampTargets)
{
for(let i=0; i<getStampTargets.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: getStampTargets[i].carId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
stampTarget.push(
wmproto.wm.protobuf.StampTargetCar.create({
car: carTarget!,
returnCount: getStampTargets[i].returnCount,
locked: getStampTargets[i].locked,
recommended: getStampTargets[i].recommended
})
);
}
}
return { stampTarget }
}
// Get Challengers
export async function getChallengers(carId: number)
{
// Get all of the challenger car for the carId provided except beated car
let checkBeatedCar = await prisma.carStampTarget.findMany({
where: {
stampTargetCarId: carId,
recommended: false
},
orderBy:{
carId: 'asc'
}
});
let challengers: wmproto.wm.protobuf.ChallengerCar[] = [];
let arrChallengerCarId = [];
for(let i=0; i<checkBeatedCar.length; i++)
{
arrChallengerCarId.push(checkBeatedCar[i].carId);
}
let getChallengers = await prisma.carChallenger.findMany({
where: {
carId: carId,
NOT: {
challengerCarId: { in: arrChallengerCarId }, // Except beated challenger id
},
}
});
if(getChallengers)
{
for(let i=0; i<getChallengers.length; i++)
{
let carTarget = await prisma.car.findFirst({
where:{
carId: getChallengers[i].challengerCarId
},
include:{
gtWing: true,
lastPlayedPlace: true
}
})
let result = 0;
if(getChallengers[i].result > 0)
{
result = -Math.abs(getChallengers[i].result);
}
else{
result = Math.abs(getChallengers[i].result);
}
challengers.push(
wmproto.wm.protobuf.ChallengerCar.create({
car: carTarget!,
stamp: getChallengers[i].stamp,
result: result,
area: getChallengers[i].area
})
);
}
}
return { challengers }
}
// Get Ghost Car
export async function getGhostCar(car: any, area: number, ramp: number, path: number)
{
// Empty list of ghost car records
let lists_ghostcar: wmproto.wm.protobuf.GhostCar[] = [];
let arr = [];
let maxNumber = 0;
// If all user car data available is more than 10 for certain level
if(car.length > 10)
{
maxNumber = 10 // Limit to 10 (game default)
}
// If no more than 10
else
{
maxNumber = car.length;
}
// Choose the user's car data randomly to appear
while(arr.length < maxNumber)
{
// Randomize pick
let random: number = 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
arr.push(random);
// Check if ghost trail for certain car is available
let ghost_trails = await prisma.ghostTrail.findFirst({
where: {
carId: car[random].carId,
area: area,
crownBattle: false
},
orderBy: {
playedAt: 'desc'
}
});
// Push user's car data without ghost trail
if(!(ghost_trails))
{
lists_ghostcar.push(wmproto.wm.protobuf.GhostCar.create({
car: car[random]
}));
}
// Push user's car data with ghost trail
else
{
// Set the tunePower used when playing certain area
car[random].tunePower = ghost_trails!.tunePower;
// Set the tuneHandling used when playing certain area
car[random].tuneHandling = ghost_trails!.tuneHandling;
// Push data to Ghost car proto
lists_ghostcar.push(wmproto.wm.protobuf.GhostCar.create({
car: car[random],
nonhuman: false,
type: wmproto.wm.protobuf.GhostType.GHOST_NORMAL,
trailId: ghost_trails!.dbId!
}));
}
}
}
return { lists_ghostcar }
}
// Check Ghost Car when using Search by Region
export async function checkGhostSearchByRegion(car: any, ghostLevel: number, regionId: number)
{
let lists_ghostcar: any;
if(car.length < 1)
{
// Get current date
let date = Math.floor(new Date().getTime() / 1000);
let playedPlace = wmproto.wm.protobuf.Place.create({
placeId: Config.getConfig().placeId,
regionId: Config.getConfig().regionId,
shopName: Config.getConfig().shopName,
country: Config.getConfig().country
});
let tunePowerDefault = 0
let tuneHandlingDefault = 0;
if(ghostLevel === 1)
{
tunePowerDefault = 1;
tuneHandlingDefault = 4;
}
else if(ghostLevel === 2)
{
tunePowerDefault = 5;
tuneHandlingDefault = 5;
}
else if(ghostLevel === 3)
{
tunePowerDefault = 8;
tuneHandlingDefault = 7;
}
else if(ghostLevel === 4)
{
tunePowerDefault = 10;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 5)
{
tunePowerDefault = 15;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 6)
{
tunePowerDefault = 18;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 7)
{
tunePowerDefault = 20;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 8)
{
tunePowerDefault = 21;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 9)
{
tunePowerDefault = 22;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 10)
{
tunePowerDefault = 24;
tuneHandlingDefault = 10;
}
else if(ghostLevel === 11)
{
tunePowerDefault = 24;
tuneHandlingDefault = 24;
}
// Generate default S660 car data
car = wmproto.wm.protobuf.Car.create({
carId: 999999999, // Don't change this
name: '',
regionId: regionId, // IDN (福井)
manufacturer: 12, // HONDA
model: 105, // S660 [JW5]
visualModel: 130, // S660 [JW5]
defaultColor: 0,
customColor: 0,
wheel: 20,
wheelColor: 0,
aero: 0,
bonnet: 0,
wing: 0,
mirror: 0,
neon: 0,
trunk: 0,
plate: 0,
plateColor: 0,
plateNumber: 0,
tunePower: tunePowerDefault,
tuneHandling: tuneHandlingDefault,
rivalMarker: 32,
aura: 551,
windowSticker: true,
windowStickerString: '',
windowStickerFont: 0,
title: 'No Ghost for this Region',
level: 65, // SSSSS
lastPlayedAt: date,
country: 'JPN',
lastPlayedPlace: playedPlace
});
// Push data to Ghost car proto
lists_ghostcar.push(wmproto.wm.protobuf.GhostCar.create({
car: car,
nonhuman: true,
type: wmproto.wm.protobuf.GhostType.GHOST_DEFAULT,
}));
}
return { lists_ghostcar }
}

View File

@ -4,9 +4,9 @@ import { Config } from "../../config";
import { wm } from "../../wmmt/wm.proto";
// Import Util
import * as common from "../../modules/util/common";
import * as ghost_stamp from "../ghost/ghost_stamp";
import * as ghost_get_area_from_path from "../ghost/ghost_util/ghost_get_area_from_path";
import * as common from "../util/common";
import * as ghost_stamp from "./ghost_stamp";
import * as ghost_get_area_from_path from "./ghost_util/ghost_get_area_from_path";
// Save ghost history battle

View File

@ -4,7 +4,7 @@ import { prisma } from "../..";
import { wm } from "../../wmmt/wm.proto";
// Import Util
import * as ghost_get_area_from_path from "../ghost/ghost_util/ghost_get_area_from_path";
import * as ghost_get_area_from_path from "./ghost_util/ghost_get_area_from_path";
export async function sendStamp(body: wm.protobuf.SaveGameResultRequest)

View File

@ -96,16 +96,10 @@ export async function OCMArea(competition_id: number)
areaVal = 18;
// GID_RAMP_HIROSHIMA_SHINONOME
//rampVal = 37;
// GID_RAMP_HIROSHIMA_UJINA
rampVal = 38;
rampVal = 37;
// GID_PATH_HS_SHINONOME
//pathVal = 56;
// GID_PATH_HS_UJINA
pathVal = 57;
pathVal = 56;
}
// 8th - Hakone
else if(competition_id === 9)

View File

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

View File

@ -8,8 +8,8 @@ import * as wm from "../wmmt/wm.proto";
// Import Util
import * as common from "./util/common";
import * as ghost_ocm from "../util/ghost/ghost_ocm";
import * as ghost_ocm_area from "../util/ghost/ghost_ocm_area";
import * as ghost_ocm from "./ghost/ghost_ocm";
import * as ghost_ocm_area from "./ghost/ghost_util/ghost_ocm_area";
export default class GhostModule extends Module {

View File

@ -10,6 +10,8 @@ import * as wmsrv from "../wmmt/service.proto";
// Import Util
import * as common from "./util/common";
import * as crown_list from "./resource/crown_list";
import * as ranking from "./resource/ranking";
export default class ResourceModule extends Module {
@ -50,6 +52,22 @@ export default class ResourceModule extends Module {
}
})
}
else
{
if(checkPlaceList.shopName !== Config.getConfig().shopName)
{
await prisma.placeList.update({
where:{
id: checkPlaceList.id
},
data:{
regionId: Number(Config.getConfig().regionId),
shopName: Config.getConfig().shopName,
country: Config.getConfig().country
}
})
}
}
// Encode the response
let message = wm.wm.protobuf.PlaceList.encode({places});
@ -67,252 +85,16 @@ export default class ResourceModule extends Module {
let lists: wmsrv.wm.protobuf.Ranking.List[] = [];
// Get TA Ranking
for(let i=0; i<25; i++){ // GID_TACOURSE ID
let rankingTA = await ranking.getTimeAttackRanking();
lists.push( ...rankingTA.lists );
// Get the TA time per course
let ta_time = await prisma.timeAttackRecord.findMany({
where: {
course: i
},
orderBy: {
time: 'asc'
},
take: 10, // Take top 10
});
// Get VS Outrun Ranking
let rankingVSOutrun = await ranking.getVSOutrunRanking();
lists.push( ...rankingVSOutrun.lists );
// TA time record by user is available for certain course
if(ta_time.length > 0){
// Empty list of ranking records for user time attack
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the TA time data
for(let j=0; j<ta_time.length; j++){
// Get the car data
let car_ta = await prisma.car.findFirst({
where: {
carId: ta_time[j].carId
}
});
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: ta_time[j].carId,
rank: car_ta!.level,
result: ta_time[j].time,
name: car_ta!.name,
regionId: car_ta!.regionId,
model: car_ta!.model,
visualModel: car_ta!.visualModel,
defaultColor: car_ta!.defaultColor,
tunePower: ta_time[j].tunePower, // Set the tunePower used when playing TA
tuneHandling: ta_time[j].tuneHandling, // Set the tuneHandling used when playing TA
title: car_ta!.title,
level: car_ta!.level
}));
}
// If the TA time record by user is less than 10 user
if(ta_time.length < 11){
// Take the remaining unfilled
for(let j=ta_time.length; j<11; j++){
let resultTime = 599999; // 9:59:999 time
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
if(i === 22 || i === 23){
resultTime = 1199999; // 19:59:999 time
}
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: resultTime,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: i, // RANKING_TA_*AREA*
topRecords: list_ta
}));
}
// There is no user's TA record for certain area
else{
// Empty list of ranking records for time attack
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Generate the top 10 TA time data
for(let j=0; j<11; j++){
let resulttime = 599999; // 9:59:999 time
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
if(i === 22 || i === 23){
resulttime = 1199999 // 19:59:999 time
}
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: resulttime,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
// Push the certain area ranking data to the list
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: i, // RANKING_TA_*AREA*
topRecords: list_ta // Top 10 TA time record data
}));
}
}
// Get VS Star Ranking
// Get the user's VS Stars data
let car_vs = await prisma.car.findMany({
orderBy: {
vsStarCount: 'desc'
},
take: 20, // Take top 20
});
// Empty list of ranking records for VS Stars
let list_vs: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the VS stars data
for(let i=0; i<car_vs.length; i++){
// Push the car data to the ranking data
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: car_vs[i].carId,
rank: car_vs[i].level,
result: car_vs[i].vsStarCount,
name: car_vs[i].name,
regionId: car_vs[i].regionId,
model: car_vs[i].model,
visualModel: car_vs[i].visualModel,
defaultColor: car_vs[i].defaultColor,
tunePower: car_vs[i].tunePower,
tuneHandling: car_vs[i].tuneHandling,
title: car_vs[i].title,
level: car_vs[i].level
}));
}
// If the VS stars record by user is less than 20 user
if(car_vs.length < 20){
// Take the remaining unfilled
for(let j=car_vs.length; j<21; j++){
// Push the data to the ranking data
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: 0,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
// Push the data
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: 100, // RANKING_VS_STAR
topRecords: list_vs // Top 20 VS stars record data
}));
// Get Ghost Defeated Ranking
// Get the user's Ghost Win data
let car_ghost = await prisma.car.findMany({
orderBy: {
rgWinCount: 'desc'
},
take: 20, // Take top 20
});
// Empty list of ranking records for Ghost Battle Win
let list_ghost: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the Ghost Battle Win data
for(let i=0; i<car_ghost.length; i++){
// Push the car data to the ranking data
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: car_ghost[i].carId,
rank: car_ghost[i].level,
result: car_ghost[i].rgWinCount,
name: car_ghost[i].name,
regionId: car_ghost[i].regionId,
model: car_ghost[i].model,
visualModel: car_ghost[i].visualModel,
defaultColor: car_ghost[i].defaultColor,
tunePower: car_ghost[i].tunePower,
tuneHandling: car_ghost[i].tuneHandling,
title: car_ghost[i].title,
level: car_ghost[i].level
}));
}
// If the Ghost Win record by user is less than 20 user
if(car_ghost.length < 20){
// Take the remaining unfilled
for(let j=car_ghost.length; j<21; j++){
// Push the data to the ranking data
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: 0,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
// Push the data
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: 101, // RANKING_GHOST_DEFEATED_COUNT
topRecords: list_ghost // Top 20 Ghost Win record data
}));
// Get Ghost Trophies Ranking
let rankingGhostTrophies = await ranking.getTGhostTrophiesRanking();
lists.push( ...rankingGhostTrophies.lists );
// Encode the response
let message = wmsrv.wm.protobuf.Ranking.encode({lists});
@ -328,168 +110,14 @@ export default class ResourceModule extends Module {
console.log('crown_list');
// Empty list of crown records
let list_crown: wmsrv.wm.protobuf.Crown[] = [];
let crowns: wmsrv.wm.protobuf.Crown[] = [];
// Get the crown holder data
let car_crown = await prisma.carCrown.findMany({
orderBy: {
area: 'asc'
},
distinct: ['area']
});
// Crown holder data available
if(car_crown.length !== 0)
{
let counter = 0;
// Loop GID_RUNAREA
for(let i=0; i<19; i++)
{
// After Kobe is Hiroshima then Fukuoka and the rest
if(i > 14)
{
i = 18; // GID_RUNAREA_HIROSHIMA
}
// Crown holder for certain area available
if(car_crown[counter].area === i)
{
// Get user's data
let car = await prisma.car.findFirst({
where: {
carId: car_crown[counter].carId
},
include: {
gtWing: true,
lastPlayedPlace: true
}
});
// Set the tunePower and tuneHandling used when capturing ghost crown
car!.tunePower = car_crown[counter].tunePower;
car!.tuneHandling = car_crown[counter].tuneHandling;
// Error handling if played At timestamp value is current date and timestamp is bigger than 9 July 2022 (using GMT+7 timestamp)
if(car_crown[counter].playedAt !== 0 && car_crown[counter].playedAt >= 1657299600)
{
// Acquired crown timestamp - 1 day
car!.lastPlayedAt = car_crown[counter].playedAt - 172800;
// Acquired crown timestamp - 1 day
car_crown[counter].playedAt = car_crown[counter].playedAt - 172800;
}
// Error handling if played At timestamp value is 0 or timestamp is less than 9 July 2022 (using GMT+7 timestamp)
else if(car_crown[counter].playedAt === 0 || car_crown[counter].playedAt < 1657299600)
{
// Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp)
car!.lastPlayedAt = 1657299600;
// Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp)
car_crown[counter].playedAt = 1657299600;
}
// Push the car data to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(car_crown[counter].area === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
});
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
}));
}
if(counter < car_crown.length-1)
{
counter++;
}
}
// Crown holder for certain area not available
else
{
// Push the default data by the game to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
});
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
}));
}
}
}
}
// There is no user's crown holder data available
else
{
// Loop GID_RUNAREA
for(let i=0; i<19; i++)
{
// After Kobe is Hiroshima then Fukuoka and the rest
if(i > 14)
{
i = 18; // GID_RUNAREA_HIROSHIMA
}
// Push the default data by the game to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: 0,
}));
}
}
}
// Response data
let msg = {
crowns: list_crown
};
// Get Crown List
let crown_lists = await crown_list.getCrownList();
crowns.push( ...crown_lists.list_crown );
// Encode the response
let message = wmsrv.wm.protobuf.CrownList.encode(msg);
let message = wmsrv.wm.protobuf.CrownList.encode( {crowns} );
// Send the response to the client
common.sendResponse(message, res);
@ -509,7 +137,6 @@ export default class ResourceModule extends Module {
}
});
res.sendFile(path.resolve(paths!.filePath, req.params.filename), { cacheControl: false });
});

View File

@ -0,0 +1,172 @@
import { prisma } from "../..";
//Import Proto
import wmsrv from "../../wmmt/service.proto";
// Get Crown List
export async function getCrownList()
{
// Empty list of crown records
let list_crown: wmsrv.wm.protobuf.Crown[] = [];
// Get the current date/time (unix epoch)
let date = Math.floor(new Date().getTime() / 1000);
// Get the crown holder data
let car_crown = await prisma.carCrown.findMany({
orderBy: {
area: 'asc'
},
distinct: ['area']
});
// Crown holder data available
if(car_crown.length !== 0)
{
let counter = 0;
// Loop GID_RUNAREA
for(let i=0; i<19; i++)
{
// After Kobe is Hiroshima then Fukuoka and the rest
if(i > 14)
{
i = 18; // GID_RUNAREA_HIROSHIMA
}
// Crown holder for certain area available
if(car_crown[counter].area === i)
{
// Get user's data
let car = await prisma.car.findFirst({
where: {
carId: car_crown[counter].carId
},
include: {
gtWing: true,
lastPlayedPlace: true
}
});
// Set the tunePower and tuneHandling used when capturing ghost crown
car!.tunePower = car_crown[counter].tunePower;
car!.tuneHandling = car_crown[counter].tuneHandling;
// Error handling if played At timestamp value is current date and timestamp is bigger than 9 July 2022 (using GMT+7 timestamp)
if(car_crown[counter].playedAt !== 0 && car_crown[counter].playedAt >= 1657299600)
{
// Acquired crown timestamp - 1 day
car!.lastPlayedAt = car_crown[counter].playedAt - 172800;
// Acquired crown timestamp - 1 day
car_crown[counter].playedAt = car_crown[counter].playedAt - 172800;
}
// Error handling if played At timestamp value is 0 or timestamp is less than 9 July 2022 (using GMT+7 timestamp)
else if(car_crown[counter].playedAt === 0 || car_crown[counter].playedAt < 1657299600)
{
// Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp)
car!.lastPlayedAt = 1657299600;
// Acquired crown timestamp become 9 July 2022 (using GMT+7 timestamp)
car_crown[counter].playedAt = 1657299600;
}
// Push the car data to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(car_crown[counter].area === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: car_crown[counter].carId,
area: car_crown[counter].area,
unlockAt: car_crown[counter].playedAt,
car: car!
}));
}
if(counter < car_crown.length-1)
{
counter++;
}
}
// Crown holder for certain area not available
else
{
// Push the default data by the game to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: date - 1000,
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: date - 1000,
}));
}
}
}
}
// There is no user's crown holder data available
else
{
// Loop GID_RUNAREA
for(let i=0; i<19; i++)
{
// After Kobe is Hiroshima then Fukuoka and the rest
if(i > 14)
{
i = 18; // GID_RUNAREA_HIROSHIMA
}
// Push the default data by the game to the crown holder data
// GID_RUNAREA_HIROSHIMA
if(i === 18)
{
let listCrown = wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: date - 1000,
});
// Push it after Kobe
list_crown.splice(11, 0, listCrown);
}
// GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE
else
{
list_crown.push(wmsrv.wm.protobuf.Crown.create({
carId: 999999999-i,
area: i,
unlockAt: date - 1000,
}));
}
}
}
return { list_crown }
}

View File

@ -0,0 +1,279 @@
import { prisma } from "../..";
//Import Proto
import * as wmsrv from "../../wmmt/service.proto";
// Get TA Ranking
export async function getTimeAttackRanking()
{
// Empty list ranking records
let lists: wmsrv.wm.protobuf.Ranking.List[] = [];
// Get TA Ranking
for(let i=0; i<25; i++) // GID_TACOURSE ID
{
// Get the TA time per course
let ta_time = await prisma.timeAttackRecord.findMany({
where: {
course: i
},
orderBy: {
time: 'asc'
},
take: 10, // Take top 10
});
// TA time record by user is available for certain course
if(ta_time.length > 0)
{
// Empty list of ranking records for user time attack
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the TA time data
for(let j=0; j<ta_time.length; j++){
// Get the car data
let car_ta = await prisma.car.findFirst({
where: {
carId: ta_time[j].carId
}
});
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: ta_time[j].carId,
rank: car_ta!.level,
result: ta_time[j].time,
name: car_ta!.name,
regionId: car_ta!.regionId,
model: car_ta!.model,
visualModel: car_ta!.visualModel,
defaultColor: car_ta!.defaultColor,
tunePower: ta_time[j].tunePower, // Set the tunePower used when playing TA
tuneHandling: ta_time[j].tuneHandling, // Set the tuneHandling used when playing TA
title: car_ta!.title,
level: car_ta!.level
}));
}
// If the TA time record by user is less than 10 user
if(ta_time.length < 11)
{
// Take the remaining unfilled
for(let j=ta_time.length; j<11; j++){
let resultTime = 599999; // 9:59:999 time
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
if(i === 22 || i === 23){
resultTime = 1199999; // 19:59:999 time
}
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: resultTime,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: i, // RANKING_TA_*AREA*
topRecords: list_ta
}));
}
// There is no user's TA record for certain area
else
{
// Empty list of ranking records for time attack
let list_ta: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Generate the top 10 TA time data
for(let j=0; j<11; j++){
let resulttime = 599999; // 9:59:999 time
// GID_TACOURSE_TOKYOALL & GID_TACOURSE_KANAGAWAALL area
if(i === 22 || i === 23){
resulttime = 1199999 // 19:59:999 time
}
// Push the data to the ranking data
list_ta.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: resulttime,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
// Push the certain area ranking data to the list
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: i, // RANKING_TA_*AREA*
topRecords: list_ta // Top 10 TA time record data
}));
}
}
return { lists }
}
// Get VS Outrun Ranking
export async function getVSOutrunRanking()
{
// Empty list ranking records
let lists: wmsrv.wm.protobuf.Ranking.List[] = [];
// Get VS Star Ranking
// Get the user's VS Stars data
let car_vs = await prisma.car.findMany({
orderBy: {
vsStarCount: 'desc'
},
take: 20, // Take top 20
});
// Empty list of ranking records for VS Stars
let list_vs: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the VS stars data
for(let i=0; i<car_vs.length; i++)
{
// Push the car data to the ranking data
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: car_vs[i].carId,
rank: car_vs[i].level,
result: car_vs[i].vsStarCount,
name: car_vs[i].name,
regionId: car_vs[i].regionId,
model: car_vs[i].model,
visualModel: car_vs[i].visualModel,
defaultColor: car_vs[i].defaultColor,
tunePower: car_vs[i].tunePower,
tuneHandling: car_vs[i].tuneHandling,
title: car_vs[i].title,
level: car_vs[i].level
}));
}
// If the VS stars record by user is less than 20 user
if(car_vs.length < 20)
{
// Take the remaining unfilled
for(let j=car_vs.length; j<21; j++)
{
// Push the data to the ranking data
list_vs.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: 0,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
// Push the data
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: 100, // RANKING_VS_STAR
topRecords: list_vs // Top 20 VS stars record data
}));
return { lists }
}
// Get Ghost Trophies Ranking
export async function getTGhostTrophiesRanking()
{
// Empty list ranking records
let lists: wmsrv.wm.protobuf.Ranking.List[] = [];
// Get Ghost Defeated Ranking
// Get the user's Ghost Win data
let car_ghost = await prisma.car.findMany({
orderBy: {
rgWinCount: 'desc'
},
take: 20, // Take top 20
});
// Empty list of ranking records for Ghost Battle Win
let list_ghost: wmsrv.wm.protobuf.Ranking.Entry[] = [];
// Get the Ghost Battle Win data
for(let i=0; i<car_ghost.length; i++){
// Push the car data to the ranking data
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: car_ghost[i].carId,
rank: car_ghost[i].level,
result: car_ghost[i].rgWinCount,
name: car_ghost[i].name,
regionId: car_ghost[i].regionId,
model: car_ghost[i].model,
visualModel: car_ghost[i].visualModel,
defaultColor: car_ghost[i].defaultColor,
tunePower: car_ghost[i].tunePower,
tuneHandling: car_ghost[i].tuneHandling,
title: car_ghost[i].title,
level: car_ghost[i].level
}));
}
// If the Ghost Win record by user is less than 20 user
if(car_ghost.length < 20){
// Take the remaining unfilled
for(let j=car_ghost.length; j<21; j++){
// Push the data to the ranking data
list_ghost.push(wmsrv.wm.protobuf.Ranking.Entry.create({
carId: 0,
rank: 0,
result: 0,
name: '',
regionId: 1, // Hokkaido
model: Math.floor(Math.random() * 50), // Randomizing Car data
visualModel: Math.floor(Math.random() * 100), // Randomizing Car data
defaultColor: 0,
tunePower: 0,
tuneHandling: 0,
title: 'Wangan Beginner', // 湾岸の新人
level: 0 // N
}));
}
}
// Push the data
lists.push(new wmsrv.wm.protobuf.Ranking.List({
rankingType: 101, // RANKING_GHOST_DEFEATED_COUNT
topRecords: list_ghost // Top 20 Ghost Win record data
}));
return { lists }
}