commit
d978a7a4e4
@ -117,6 +117,8 @@ export default class CarModule extends Module {
|
||||
|
||||
if(getNo1OCM)
|
||||
{
|
||||
console.log('Getting registered car data');
|
||||
|
||||
// Get Car Data
|
||||
let cars = await prisma.car.findFirst({
|
||||
where:{
|
||||
@ -167,8 +169,10 @@ export default class CarModule extends Module {
|
||||
let opponentTarget = await prisma.carStampTarget.findMany({
|
||||
where:{
|
||||
stampTargetCarId: body.carId,
|
||||
locked: false,
|
||||
recommended: true,
|
||||
},
|
||||
orderBy:{
|
||||
locked: 'desc'
|
||||
}
|
||||
})
|
||||
|
||||
@ -250,7 +254,7 @@ export default class CarModule extends Module {
|
||||
// Stamp or Challenger
|
||||
challenger: carsChallengers[0] || null,
|
||||
challengerReturnCount: returnCount || null,
|
||||
numOfChallengers: carsChallengers.length || null,
|
||||
numOfChallengers: carsChallengers.length + 1 || null,
|
||||
|
||||
// OCM Challenge Top 1
|
||||
opponentGhost: ghostCarsNo1 || null,
|
||||
@ -573,6 +577,7 @@ export default class CarModule extends Module {
|
||||
|
||||
// Get the request body for the update car request
|
||||
let body = wm.wm.protobuf.UpdateCarRequest.decode(req.body);
|
||||
console.log(body);
|
||||
|
||||
// Get the ghost result for the car
|
||||
let cars = body?.car;
|
||||
@ -702,26 +707,38 @@ export default class CarModule extends Module {
|
||||
wingTip: common.sanitizeInput(gtWing.wingTip),
|
||||
material: common.sanitizeInput(gtWing.material),
|
||||
}
|
||||
|
||||
await prisma.carGTWing.update({
|
||||
where: {
|
||||
dbId: body.carId
|
||||
},
|
||||
data: dataGTWing
|
||||
})
|
||||
}
|
||||
else
|
||||
// Check if this is in getting new custom color screen or not
|
||||
else if(body.car?.carId !== null && body.car?.carId !== undefined)
|
||||
{
|
||||
dataGTWing = {
|
||||
pillar: 0,
|
||||
pillarMaterial: 0,
|
||||
mainWing: 0,
|
||||
mainWingColor: 0,
|
||||
wingTip: 0,
|
||||
material: 0,
|
||||
// GT Wing not set
|
||||
if(gtWing === undefined || gtWing === null)
|
||||
{
|
||||
dataGTWing = {
|
||||
pillar: 0,
|
||||
pillarMaterial: 0,
|
||||
mainWing: 0,
|
||||
mainWingColor: 0,
|
||||
wingTip: 0,
|
||||
material: 0,
|
||||
}
|
||||
|
||||
await prisma.carGTWing.update({
|
||||
where: {
|
||||
dbId: body.carId
|
||||
},
|
||||
data: dataGTWing
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.carGTWing.update({
|
||||
where: {
|
||||
dbId: body.carId
|
||||
},
|
||||
data: dataGTWing
|
||||
})
|
||||
|
||||
// Response data
|
||||
let msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
|
@ -13,6 +13,7 @@ import * as wmsrv from "../wmmt/service.proto";
|
||||
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";
|
||||
|
||||
|
||||
export default class GhostModule extends Module {
|
||||
@ -77,8 +78,11 @@ export default class GhostModule extends Module {
|
||||
let stampTargets = await prisma.carStampTarget.findMany({
|
||||
where: {
|
||||
stampTargetCarId: body.carId,
|
||||
locked: false
|
||||
}
|
||||
recommended: true
|
||||
},
|
||||
orderBy:{
|
||||
locked: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
if(stampTargets)
|
||||
@ -179,8 +183,11 @@ export default class GhostModule extends Module {
|
||||
let stampTargets = await prisma.carStampTarget.findMany({
|
||||
where: {
|
||||
stampTargetCarId: body.carId,
|
||||
locked: false
|
||||
}
|
||||
recommended: true
|
||||
},
|
||||
orderBy:{
|
||||
locked: 'asc'
|
||||
}
|
||||
});
|
||||
|
||||
if(stampTargets)
|
||||
@ -303,67 +310,13 @@ export default class GhostModule extends Module {
|
||||
// Randomizing the starting ramp and path based on selected area
|
||||
let rampVal = 0;
|
||||
let pathVal = 0;
|
||||
if(body.area === 0){ // GID_RUNAREA_C1
|
||||
rampVal = Math.floor(Math.random() * 4);
|
||||
pathVal = Math.floor(Math.random() * 10);
|
||||
}
|
||||
else if(body.area === 1){ // GID_RUNAREA_RING
|
||||
rampVal = Math.floor(Math.random() * 2) + 4;
|
||||
pathVal = Math.floor(Math.random() * 6) + 10;
|
||||
}
|
||||
else if(body.area === 2){ // GID_RUNAREA_SUBTOKYO_3_4
|
||||
rampVal = Math.floor(Math.random() * 2) + 6;
|
||||
pathVal = Math.floor(Math.random() * 2) + 16;
|
||||
}
|
||||
else if(body.area === 3){ // GID_RUNAREA_SUBTOKYO_5
|
||||
rampVal = Math.floor(Math.random() * 2) + 8;
|
||||
pathVal = Math.floor(Math.random() * 2) + 18;
|
||||
}
|
||||
else if(body.area === 4){ // GID_RUNAREA_WANGAN
|
||||
rampVal = Math.floor(Math.random() * 4) + 10;
|
||||
pathVal = Math.floor(Math.random() * 7) + 20;
|
||||
}
|
||||
else if(body.area === 5){ // GID_RUNAREA_K1
|
||||
rampVal = Math.floor(Math.random() * 4) + 14;
|
||||
pathVal = Math.floor(Math.random() * 7) + 27;
|
||||
}
|
||||
else if(body.area === 6){ // GID_RUNAREA_YAESU
|
||||
rampVal = Math.floor(Math.random() * 3) + 18;
|
||||
pathVal = Math.floor(Math.random() * 4) + 34;
|
||||
}
|
||||
else if(body.area === 7){ // GID_RUNAREA_YOKOHAMA
|
||||
rampVal = Math.floor(Math.random() * 4) + 21;
|
||||
pathVal = Math.floor(Math.random() * 11) + 38;
|
||||
}
|
||||
else if(body.area === 8){ // GID_RUNAREA_NAGOYA
|
||||
rampVal = 25;
|
||||
pathVal = 49;
|
||||
}
|
||||
else if(body.area === 9){ // GID_RUNAREA_OSAKA
|
||||
rampVal = 26;
|
||||
pathVal = Math.floor(Math.random() * 4) + 50;
|
||||
}
|
||||
else if(body.area === 10){ // GID_RUNAREA_KOBE
|
||||
rampVal = Math.floor(Math.random() * 2) + 27;
|
||||
pathVal = Math.floor(Math.random() * 2) + 54;
|
||||
}
|
||||
else if(body.area === 11){ // GID_RUNAREA_FUKUOKA
|
||||
rampVal = Math.floor(Math.random() * 4) + 29;
|
||||
pathVal = Math.floor(Math.random() * 4) + 58;
|
||||
}
|
||||
else if(body.area === 12){ // GID_RUNAREA_HAKONE
|
||||
rampVal = Math.floor(Math.random() * 2) + 33;
|
||||
pathVal = Math.floor(Math.random() * 2) + 62;
|
||||
}
|
||||
else if(body.area === 13){ // GID_RUNAREA_TURNPIKE
|
||||
rampVal = Math.floor(Math.random() * 2) + 35;
|
||||
pathVal = Math.floor(Math.random() * 2) + 64;
|
||||
}
|
||||
//14 - 16 are dummy area, 17 is GID_RUNAREA_C1_CLOSED
|
||||
else if(body.area === 18){ // GID_RUNAREA_HIROSHIMA
|
||||
rampVal = Math.floor(Math.random() * 2) + 37;
|
||||
pathVal = Math.floor(Math.random() * 2) + 56;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// Empty list of ghost car records
|
||||
let lists_ghostcar: wm.wm.protobuf.GhostCar[] = [];
|
||||
@ -796,67 +749,13 @@ export default class GhostModule extends Module {
|
||||
}
|
||||
let rampVal = 0;
|
||||
let pathVal = 0;
|
||||
if(j === 0){ // GID_RUNAREA_C1
|
||||
rampVal = Math.floor(Math.random() * 4);
|
||||
pathVal = Math.floor(Math.random() * 10);
|
||||
}
|
||||
else if(j === 1){ // GID_RUNAREA_RING
|
||||
rampVal = Math.floor(Math.random() * 2) + 4;
|
||||
pathVal = Math.floor(Math.random() * 6) + 10;
|
||||
}
|
||||
else if(j === 2){ // GID_RUNAREA_SUBTOKYO_3_4
|
||||
rampVal = Math.floor(Math.random() * 2) + 6;
|
||||
pathVal = Math.floor(Math.random() * 2) + 16;
|
||||
}
|
||||
else if(j === 3){ // GID_RUNAREA_SUBTOKYO_5
|
||||
rampVal = Math.floor(Math.random() * 2) + 8;
|
||||
pathVal = Math.floor(Math.random() * 2) + 18;
|
||||
}
|
||||
else if(j === 4){ // GID_RUNAREA_WANGAN
|
||||
rampVal = Math.floor(Math.random() * 4) + 10;
|
||||
pathVal = Math.floor(Math.random() * 7) + 20;
|
||||
}
|
||||
else if(j === 5){ // GID_RUNAREA_K1
|
||||
rampVal = Math.floor(Math.random() * 4) + 14;
|
||||
pathVal = Math.floor(Math.random() * 7) + 27;
|
||||
}
|
||||
else if(j === 6){ // GID_RUNAREA_YAESU
|
||||
rampVal = Math.floor(Math.random() * 3) + 18;
|
||||
pathVal = Math.floor(Math.random() * 4) + 34;
|
||||
}
|
||||
else if(j === 7){ // GID_RUNAREA_YOKOHAMA
|
||||
rampVal = Math.floor(Math.random() * 4) + 21;
|
||||
pathVal = Math.floor(Math.random() * 11) + 38;
|
||||
}
|
||||
else if(j === 8){ // GID_RUNAREA_NAGOYA
|
||||
rampVal = 25;
|
||||
pathVal = 49;
|
||||
}
|
||||
else if(j === 9){ // GID_RUNAREA_OSAKA
|
||||
rampVal = 26;
|
||||
pathVal = Math.floor(Math.random() * 4) + 50;
|
||||
}
|
||||
else if(j === 10){ // GID_RUNAREA_KOBE
|
||||
rampVal = Math.floor(Math.random() * 2) + 27;
|
||||
pathVal = Math.floor(Math.random() * 2) + 54;
|
||||
}
|
||||
else if(j === 11){ // GID_RUNAREA_FUKUOKA
|
||||
rampVal = Math.floor(Math.random() * 4) + 29;
|
||||
pathVal = Math.floor(Math.random() * 4) + 58;
|
||||
}
|
||||
else if(j === 12){ // GID_RUNAREA_HAKONE
|
||||
rampVal = Math.floor(Math.random() * 2) + 33;
|
||||
pathVal = Math.floor(Math.random() * 2) + 62;
|
||||
}
|
||||
else if(j === 13){ // GID_RUNAREA_TURNPIKE
|
||||
rampVal = Math.floor(Math.random() * 2) + 35;
|
||||
pathVal = Math.floor(Math.random() * 2) + 64;
|
||||
}
|
||||
//14 - 16 are dummy area, 17 is GID_RUNAREA_C1_CLOSED
|
||||
else if(j === 18){ // GID_RUNAREA_HIROSHIMA
|
||||
rampVal = Math.floor(Math.random() * 2) + 37;
|
||||
pathVal = Math.floor(Math.random() * 2) + 56;
|
||||
}
|
||||
|
||||
// Get the ramp and path id
|
||||
let ghost_areas = await ghost_area.GhostArea(j);
|
||||
|
||||
// Set the value
|
||||
rampVal = ghost_areas.rampVal;
|
||||
pathVal = ghost_areas.pathVal;
|
||||
|
||||
// Empty list of car tuning records
|
||||
let carTuning: wm.wm.protobuf.CarTuning[] = [];
|
||||
|
@ -359,6 +359,14 @@ export default class GhostModule extends Module {
|
||||
closed: true
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Response data
|
||||
msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
closed: true
|
||||
};
|
||||
}
|
||||
}
|
||||
// No OCM Event
|
||||
else{
|
||||
@ -399,8 +407,6 @@ export default class GhostModule extends Module {
|
||||
// Get currently active OCM event
|
||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
where: {
|
||||
competitionId: competition_id,
|
||||
|
||||
// qualifyingPeriodStartAt is less than current date
|
||||
qualifyingPeriodStartAt: { lte: date },
|
||||
|
||||
@ -419,9 +425,6 @@ export default class GhostModule extends Module {
|
||||
{
|
||||
dbId: 'desc'
|
||||
},
|
||||
{
|
||||
competitionEndAt: 'desc',
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
@ -436,6 +439,7 @@ export default class GhostModule extends Module {
|
||||
shopName: Config.getConfig().shopName,
|
||||
country: Config.getConfig().country
|
||||
});
|
||||
let competitionSchedule;
|
||||
|
||||
// Get default trail id
|
||||
let ghostTrailId = 0;
|
||||
@ -586,12 +590,8 @@ export default class GhostModule extends Module {
|
||||
// Get Top 1 qualifying ghost trail id
|
||||
let checkGhostTrail = await prisma.oCMTop1GhostTrail.findFirst({
|
||||
where:{
|
||||
carId: ocmTallyRecord!.carId,
|
||||
competitionId: ocmEventDate!.competitionId,
|
||||
competitionId: competition_id,
|
||||
periodId: 999999999,
|
||||
area: areaVal,
|
||||
ramp: rampVal,
|
||||
path: pathVal,
|
||||
},
|
||||
orderBy:{
|
||||
playedAt: 'desc'
|
||||
@ -629,6 +629,49 @@ export default class GhostModule extends Module {
|
||||
cars!.lastPlayedAt = checkGhostTrail.playedAt
|
||||
ghostTrailId = checkGhostTrail.dbId!;
|
||||
ghostTypes = wm.wm.protobuf.GhostType.GHOST_NORMAL;
|
||||
|
||||
let ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
where: {
|
||||
competitionId: competition_id
|
||||
}
|
||||
});
|
||||
|
||||
if(ocmEventDate)
|
||||
{
|
||||
// Creating GhostCompetitionSchedule
|
||||
competitionSchedule = wm.wm.protobuf.GhostCompetitionSchedule.create({
|
||||
|
||||
// OCM Competition ID (1 = C1 (Round 16), 4 = Nagoya (Round 19), 8 = Hiroshima (Round 21))
|
||||
competitionId: ocmEventDate.competitionId,
|
||||
|
||||
// OCM Qualifying Start Timestamp
|
||||
qualifyingPeriodStartAt: ocmEventDate.qualifyingPeriodStartAt,
|
||||
|
||||
// OCM Qualifying Close Timestamp
|
||||
qualifyingPeriodCloseAt: ocmEventDate.qualifyingPeriodCloseAt,
|
||||
|
||||
// OCM Competition (Main Draw) Start Timestamp
|
||||
competitionStartAt: ocmEventDate.competitionStartAt,
|
||||
|
||||
// OCM Competition (Main Draw) Close Timestamp
|
||||
competitionCloseAt: ocmEventDate.competitionCloseAt,
|
||||
|
||||
// OCM Competition (Main Draw) End Timestamp
|
||||
competitionEndAt: ocmEventDate.competitionEndAt,
|
||||
|
||||
// idk what this is
|
||||
lengthOfPeriod: ocmEventDate.lengthOfPeriod,
|
||||
|
||||
// idk what this is
|
||||
lengthOfInterval: ocmEventDate.lengthOfInterval,
|
||||
|
||||
// Area for the event (GID_RUNAREA_*, 8 is GID_RUNAREA_NAGOYA)
|
||||
area: ocmEventDate.area,
|
||||
|
||||
// idk what this is
|
||||
minigamePatternId: ocmEventDate.minigamePatternId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,7 +683,7 @@ export default class GhostModule extends Module {
|
||||
path: pathVal,
|
||||
nonhuman: false,
|
||||
type: ghostTypes,
|
||||
trailId: ghostTrailId
|
||||
trailId: ghostTrailId,
|
||||
});
|
||||
|
||||
// Response data
|
||||
@ -649,7 +692,8 @@ export default class GhostModule extends Module {
|
||||
competitionId: competition_id,
|
||||
ghostCar: ghostCars!,
|
||||
trailId: ghostTrailId,
|
||||
updatedAt: date
|
||||
updatedAt: date,
|
||||
competitionSchedule: competitionSchedule || null
|
||||
};
|
||||
|
||||
// Encode the response
|
||||
|
@ -44,14 +44,9 @@ export default class StartupModule extends Module {
|
||||
if(!(ocmEventDate))
|
||||
{
|
||||
ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
orderBy: [
|
||||
{
|
||||
dbId: 'desc'
|
||||
},
|
||||
{
|
||||
competitionEndAt: 'desc',
|
||||
},
|
||||
],
|
||||
orderBy:{
|
||||
dbId: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
pastEvent = 1;
|
||||
|
@ -188,6 +188,7 @@ export default class TerminalModule extends Module {
|
||||
|
||||
// Get the query from the request
|
||||
let query = req.query;
|
||||
let cars;
|
||||
|
||||
// Check the query limit
|
||||
let queryLimit = 10
|
||||
@ -197,9 +198,9 @@ export default class TerminalModule extends Module {
|
||||
}
|
||||
|
||||
// Check the last played place id
|
||||
let queryLastPlayedPlaceId = 1;
|
||||
if(query.limit)
|
||||
if(query.last_played_place_id)
|
||||
{
|
||||
let queryLastPlayedPlaceId = 1;
|
||||
let getLastPlayedPlaceId = await prisma.placeList.findFirst({
|
||||
where:{
|
||||
placeId: String(query.last_played_place_id)
|
||||
@ -208,30 +209,46 @@ export default class TerminalModule extends Module {
|
||||
|
||||
if(getLastPlayedPlaceId)
|
||||
{
|
||||
queryLastPlayedPlaceId = getLastPlayedPlaceId.id
|
||||
queryLastPlayedPlaceId = getLastPlayedPlaceId.id;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all of the cars matching the query
|
||||
let cars = await prisma.car.findMany({
|
||||
take: queryLimit,
|
||||
where: {
|
||||
OR:[
|
||||
{
|
||||
name: {
|
||||
startsWith: String(query.name)
|
||||
cars = await prisma.car.findMany({
|
||||
take: queryLimit,
|
||||
where: {
|
||||
lastPlayedPlaceId: queryLastPlayedPlaceId
|
||||
},
|
||||
include:{
|
||||
gtWing: true,
|
||||
lastPlayedPlace: true
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get all of the cars matching the query
|
||||
cars = await prisma.car.findMany({
|
||||
take: queryLimit,
|
||||
where: {
|
||||
OR:[
|
||||
{
|
||||
name: {
|
||||
startsWith: String(query.name)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: {
|
||||
endsWith: String(query.name)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
lastPlayedPlaceId: queryLastPlayedPlaceId
|
||||
}
|
||||
]
|
||||
},
|
||||
include:{
|
||||
gtWing: true,
|
||||
lastPlayedPlace: true
|
||||
}
|
||||
});
|
||||
]
|
||||
|
||||
},
|
||||
include:{
|
||||
gtWing: true,
|
||||
lastPlayedPlace: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(let i=0; i<cars.length; i++)
|
||||
{
|
||||
@ -581,8 +598,8 @@ export default class TerminalModule extends Module {
|
||||
if(!(ocmEventDate))
|
||||
{
|
||||
ocmEventDate = await prisma.oCMEvent.findFirst({
|
||||
orderBy:{
|
||||
dbId: 'desc'
|
||||
where:{
|
||||
competitionId: body.competitionId
|
||||
}
|
||||
});
|
||||
|
||||
@ -995,6 +1012,50 @@ export default class TerminalModule extends Module {
|
||||
})
|
||||
|
||||
|
||||
// Lock Stamp Target
|
||||
app.post('/method/lock_stamp_target', async (req, res) => {
|
||||
|
||||
// car_id, target_cars[]
|
||||
let body = wm.wm.protobuf.LockStampTargetRequest.decode(req.body);
|
||||
|
||||
// Unlock all of the stamp targets for the car
|
||||
await prisma.carStampTarget.updateMany({
|
||||
where: {
|
||||
stampTargetCarId: body.carId
|
||||
},
|
||||
data: {
|
||||
locked: false
|
||||
}
|
||||
});
|
||||
|
||||
// Loop over all of the locked stamp targets
|
||||
for(let targetCar of body.targetCars)
|
||||
{
|
||||
// Lock the stamp target for the given car
|
||||
|
||||
// This should only occur once, however
|
||||
// the relationship is not strictly 1:1
|
||||
await prisma.carStampTarget.updateMany({
|
||||
where: {
|
||||
carId: targetCar,
|
||||
stampTargetCarId: body.carId
|
||||
},
|
||||
data: {
|
||||
locked: true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Encode the response
|
||||
let message = wm.wm.protobuf.LoadStampTargetResponse.encode({
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
||||
});
|
||||
|
||||
// Send the response to the client
|
||||
common.sendResponse(message, res);
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
app.post('/method/load_unreceived_user_items', async (req, res) => {
|
||||
|
||||
|
@ -71,13 +71,19 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
|
||||
// ghostResult is set
|
||||
if (ghostResult)
|
||||
{
|
||||
let stampSheet: any = undefined;
|
||||
if(ghostResult.stampSheet!.length > 0)
|
||||
{
|
||||
stampSheet = ghostResult.stampSheet;
|
||||
}
|
||||
|
||||
// Ghost update data
|
||||
dataGhost = {
|
||||
rgRegionMapScore: common.sanitizeInput(ghostResult.rgRegionMapScore),
|
||||
rgPlayCount: common.sanitizeInput(ghostResult.rgPlayCount),
|
||||
dressupLevel: common.sanitizeInput(ghostResult.dressupLevel),
|
||||
dressupPoint: common.sanitizeInput(ghostResult.dressupPoint),
|
||||
stampSheet: common.sanitizeInput(ghostResult.stampSheet),
|
||||
stampSheet: stampSheet,
|
||||
stampSheetCount: common.sanitizeInputNotZero(ghostResult.stampSheetCount),
|
||||
}
|
||||
|
||||
|
289
src/util/ghost/ghost_area.ts
Normal file
289
src/util/ghost/ghost_area.ts
Normal file
@ -0,0 +1,289 @@
|
||||
import { wm } from "../../wmmt/wm.proto";
|
||||
|
||||
// OCM Area
|
||||
export async function GhostArea(area: number)
|
||||
{
|
||||
let rampVal = 0;
|
||||
let pathVal = 0;
|
||||
|
||||
// GID_RUNAREA_C1
|
||||
if(Number(area) === 0)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 4);
|
||||
|
||||
// GID_RAMP_C1_IN_KANDABASHI
|
||||
if(rampVal === 0)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3); // path id 0-2
|
||||
}
|
||||
// GID_RAMP_C1_IN_SHIODOME
|
||||
else if(rampVal === 1)
|
||||
{
|
||||
pathVal = 3
|
||||
}
|
||||
// GID_RAMP_C1_OUT_KANDABASHI
|
||||
else if(rampVal === 2)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 4; // path id 4-6
|
||||
}
|
||||
// GID_RAMP_C1_OUT_SHIBA
|
||||
else if(rampVal === 3)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 7; // path id 7-9
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_RING
|
||||
else if(Number(area) === 1)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 4;
|
||||
|
||||
// GID_RAMP_RING_LEFT_ARIAKE
|
||||
if(rampVal === 4)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 10; // path id 10-12
|
||||
}
|
||||
// GID_RAMP_RING_RIGHT_KIBA
|
||||
else if(rampVal === 5)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 13; // path id 13-15
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_SUBTOKYO_3_4
|
||||
else if(Number(area) === 2)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 6;
|
||||
|
||||
// GID_RAMP_SUBTOKYO_SHIBUYA
|
||||
if(rampVal === 6)
|
||||
{
|
||||
pathVal = 16
|
||||
}
|
||||
// GID_RAMP_SUBTOKYO_GAIEN
|
||||
else if(rampVal === 7)
|
||||
{
|
||||
pathVal = 17
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_SUBTOKYO_5
|
||||
else if(Number(area) === 3)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 8;
|
||||
|
||||
// GID_RAMP_SUBTOKYO_DAIKANCHOU
|
||||
if(rampVal === 8)
|
||||
{
|
||||
pathVal = 18;
|
||||
}
|
||||
// GID_RAMP_SUBTOKYO_SHINJUKU
|
||||
else if(rampVal === 9)
|
||||
{
|
||||
pathVal = 19;
|
||||
}
|
||||
|
||||
}
|
||||
// GID_RUNAREA_WANGAN
|
||||
else if(Number(area) === 4)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 4) + 10;
|
||||
|
||||
// GID_RAMP_WANGAN_EAST_AIRPORT
|
||||
if(rampVal === 10)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 20; // path id 20-22
|
||||
}
|
||||
// GID_RAMP_WANGAN_EAST_DAIKOKU
|
||||
else if(rampVal === 11)
|
||||
{
|
||||
pathVal = 23
|
||||
}
|
||||
// GID_RAMP_WANGAN_WEST_RINKAI
|
||||
else if(rampVal === 12)
|
||||
{
|
||||
pathVal = 24;
|
||||
}
|
||||
// GID_RAMP_WANGAN_WEST_AIRPORT
|
||||
else if(rampVal === 13)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 25; // path id 25-26
|
||||
}
|
||||
|
||||
}
|
||||
// GID_RUNAREA_K1
|
||||
else if(Number(area) === 5)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 4) + 14;
|
||||
|
||||
// GID_RAMP_K1_DOWN_SHIBAURA
|
||||
if(rampVal === 14)
|
||||
{
|
||||
pathVal = 27
|
||||
}
|
||||
// GID_RAMP_K1_DOWN_HANEDA
|
||||
else if(rampVal === 15)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 28; // path id 28-29
|
||||
}
|
||||
// GID_RAMP_K1_UP_HANEDA
|
||||
else if(rampVal === 16)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 30; // path id 30-31
|
||||
}
|
||||
// GID_RAMP_K1_UP_SHIOIRI
|
||||
else if(rampVal === 17)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 32; // path id 32-33
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_YAESU
|
||||
else if(Number(area) === 6)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 3) + 18;
|
||||
|
||||
// GID_RAMP_YAESU_SHIODOME
|
||||
if(rampVal === 18)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 34; // path id 34-35
|
||||
}
|
||||
// GID_RAMP_YAESU_KYOBASHI
|
||||
else if(rampVal === 19)
|
||||
{
|
||||
pathVal = 36
|
||||
}
|
||||
// GID_RAMP_YAESU_KANDABASHI
|
||||
else if(rampVal === 20)
|
||||
{
|
||||
pathVal = 37
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_YOKOHAMA
|
||||
else if(Number(area) === 7)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 4) + 21;
|
||||
|
||||
// GID_RAMP_MINATOMIRAI_IN_HIGASHIKANAGAWA
|
||||
if(rampVal === 21)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 2) + 38; // path id 38-39
|
||||
}
|
||||
// GID_RAMP_MINATOMIRAI_IN_MINATOMIRAI
|
||||
else if(rampVal === 22)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 40; // path id 40-42
|
||||
}
|
||||
// GID_RAMP_MINATOMIRAI_OUT_SHINYAMASHITA
|
||||
else if(rampVal === 23)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 43; // path id 43-45
|
||||
}
|
||||
// GID_RAMP_MINATOMIRAI_OUT_MINATOMIRAI
|
||||
else if(rampVal === 24)
|
||||
{
|
||||
pathVal = Math.floor(Math.random() * 3) + 46; // path id 46-48
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_NAGOYA
|
||||
else if(Number(area) === 8)
|
||||
{
|
||||
rampVal = 25;
|
||||
pathVal = 49;
|
||||
}
|
||||
// GID_RUNAREA_OSAKA
|
||||
else if(Number(area) === 9)
|
||||
{
|
||||
rampVal = 26;
|
||||
pathVal = Math.floor(Math.random() * 4) + 50;
|
||||
}
|
||||
// GID_RUNAREA_KOBE
|
||||
else if(Number(area) === 10)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 27;
|
||||
|
||||
// GID_RAMP_KOBE_SHINKOUCHOU
|
||||
if(rampVal === 27)
|
||||
{
|
||||
pathVal = 54;
|
||||
}
|
||||
// GID_RAMP_KOBE_NADAOOHASHI
|
||||
else if(rampVal === 28)
|
||||
{
|
||||
pathVal = 55;
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_FUKUOKA
|
||||
else if(Number(area) === 11)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 4) + 29;
|
||||
|
||||
// GID_RAMP_FUKUOKA_WEST_MEIHAMA
|
||||
if(rampVal === 29)
|
||||
{
|
||||
pathVal = 58;
|
||||
}
|
||||
// GID_RAMP_FUKUOKA_WEST_HAKATA
|
||||
else if(rampVal === 30)
|
||||
{
|
||||
pathVal = 59;
|
||||
}
|
||||
// GID_RAMP_FUKUOKA_EAST_NISHI
|
||||
else if(rampVal === 31)
|
||||
{
|
||||
pathVal = 60;
|
||||
}
|
||||
// GID_RAMP_FUKUOKA_EAST_HANDOUBASHI
|
||||
else if(rampVal === 32)
|
||||
{
|
||||
pathVal = 61;
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_HAKONE
|
||||
else if(Number(area) === 12)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 33;
|
||||
|
||||
// GID_RAMP_HAKONE_FOR
|
||||
if(rampVal === 33)
|
||||
{
|
||||
pathVal = 62;
|
||||
}
|
||||
// GID_RAMP_HAKONE_BACK
|
||||
else if(rampVal === 34)
|
||||
{
|
||||
pathVal = 63;
|
||||
}
|
||||
}
|
||||
// GID_RUNAREA_TURNPIKE
|
||||
else if(Number(area) === 13)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 35;
|
||||
|
||||
// GID_RAMP_TURNPIKE_UP
|
||||
if(rampVal === 35)
|
||||
{
|
||||
pathVal = 64;
|
||||
}
|
||||
// GID_RAMP_TURNPIKE_DOWN
|
||||
else if(rampVal === 36)
|
||||
{
|
||||
pathVal = 65;
|
||||
}
|
||||
}
|
||||
// 14 - 16 are dummy area, 17 is GID_RUNAREA_C1_CLOSED
|
||||
// GID_RUNAREA_HIROSHIMA
|
||||
else if(Number(area) === 18)
|
||||
{
|
||||
rampVal = Math.floor(Math.random() * 2) + 37;
|
||||
|
||||
// GID_RAMP_HIROSHIMA_SHINONOME
|
||||
if(rampVal === 37)
|
||||
{
|
||||
pathVal = 56;
|
||||
}
|
||||
// GID_RAMP_HIROSHIMA_UJINA
|
||||
else if(rampVal === 38)
|
||||
{
|
||||
pathVal = 57;
|
||||
}
|
||||
}
|
||||
|
||||
return { rampVal, pathVal }
|
||||
}
|
@ -141,18 +141,21 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
|
||||
// Get the Top 1 Advantage
|
||||
if(top1advantage === null)
|
||||
{
|
||||
top1advantage = OCMTally[i].result;
|
||||
top1advantage = OCMTally[0].result;
|
||||
|
||||
let getTrail = await prisma.oCMGhostTrail.findFirst({
|
||||
where:{
|
||||
carId: OCMTally[i].carId,
|
||||
carId: OCMTally[0].carId,
|
||||
competitionId: body.competitionId,
|
||||
ocmMainDraw: true
|
||||
},
|
||||
orderBy:{
|
||||
playedAt: 'desc'
|
||||
}
|
||||
})
|
||||
|
||||
if(getTrail)
|
||||
{
|
||||
console.log('Creating Trail');
|
||||
await prisma.oCMTop1GhostTrail.create({
|
||||
data: {
|
||||
carId: getTrail.carId,
|
||||
@ -221,7 +224,8 @@ export async function ocmTallying(body: wm.protobuf.LoadGhostCompetitionInfoRequ
|
||||
}
|
||||
|
||||
|
||||
if(i === 0){
|
||||
if(i === 0)
|
||||
{
|
||||
console.log('Making OCM Top 1 Ghost Data');
|
||||
|
||||
// Create Top 1 ghost data
|
||||
|
@ -165,11 +165,11 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
|
||||
carId: rgResult.opponents![i].carId,
|
||||
stampTargetCarId: body.carId,
|
||||
returnCount: returnCount,
|
||||
locked: true,
|
||||
locked: false,
|
||||
recommended: false
|
||||
}
|
||||
|
||||
console.log(`Updating car ${rgResult.opponents![i].carId} vs ${body.carId} stamp entry and locking it`);
|
||||
console.log(`Updating car ${rgResult.opponents![i].carId} vs ${body.carId} stamp entry and remove it from your recommendation`);
|
||||
|
||||
await prisma.carStampTarget.update({
|
||||
where:{
|
||||
@ -217,7 +217,7 @@ export async function shuttleReturnStamp(body: wm.protobuf.SaveGameResultRequest
|
||||
|
||||
if(stampReturned)
|
||||
{
|
||||
console.log(`Stamp returned to ${rgResult.opponents![i].carId}, unlocking it so opponents can fight your ghost`);
|
||||
console.log(`Stamp returned to ${rgResult.opponents![i].carId}, recommend it so opponents can fight your ghost`);
|
||||
|
||||
await prisma.carStampTarget.update({
|
||||
where:{
|
||||
|
@ -3,6 +3,7 @@ import { OCMTop1GhostTrail } from "@prisma/client";
|
||||
|
||||
// Import Proto
|
||||
import * as ghost_ocm_area from "./ghost_ocm_area";
|
||||
import * as ghost_area from "./ghost_area";
|
||||
|
||||
|
||||
// Save ghost battle result
|
||||
@ -220,67 +221,12 @@ export async function getCrownGhostTrail(carId: number, areaId: number)
|
||||
{
|
||||
console.log('Crown Ghost Trail not found');
|
||||
|
||||
if(areaId === 0){ // GID_RUNAREA_C1
|
||||
rampVal = Math.floor(Math.random() * 4);
|
||||
pathVal = Math.floor(Math.random() * 10);
|
||||
}
|
||||
else if(areaId === 1){ // GID_RUNAREA_RING
|
||||
rampVal = Math.floor(Math.random() * 2) + 4;
|
||||
pathVal = Math.floor(Math.random() * 6) + 10;
|
||||
}
|
||||
else if(areaId === 2){ // GID_RUNAREA_SUBTOKYO_3_4
|
||||
rampVal = Math.floor(Math.random() * 2) + 6;
|
||||
pathVal = Math.floor(Math.random() * 2) + 16;
|
||||
}
|
||||
else if(areaId === 3){ // GID_RUNAREA_SUBTOKYO_5
|
||||
rampVal = Math.floor(Math.random() * 2) + 8;
|
||||
pathVal = Math.floor(Math.random() * 2) + 18;
|
||||
}
|
||||
else if(areaId === 4){ // GID_RUNAREA_WANGAN
|
||||
rampVal = Math.floor(Math.random() * 4) + 10;
|
||||
pathVal = Math.floor(Math.random() * 7) + 20;
|
||||
}
|
||||
else if(areaId === 5){ // GID_RUNAREA_K1
|
||||
rampVal = Math.floor(Math.random() * 4) + 14;
|
||||
pathVal = Math.floor(Math.random() * 7) + 27;
|
||||
}
|
||||
else if(areaId === 6){ // GID_RUNAREA_YAESU
|
||||
rampVal = Math.floor(Math.random() * 3) + 18;
|
||||
pathVal = Math.floor(Math.random() * 4) + 34;
|
||||
}
|
||||
else if(areaId === 7){ // GID_RUNAREA_YOKOHAMA
|
||||
rampVal = Math.floor(Math.random() * 4) + 21;
|
||||
pathVal = Math.floor(Math.random() * 11) + 38;
|
||||
}
|
||||
else if(areaId === 8){ // GID_RUNAREA_NAGOYA
|
||||
rampVal = 25;
|
||||
pathVal = 49;
|
||||
}
|
||||
else if(areaId === 9){ // GID_RUNAREA_OSAKA
|
||||
rampVal = 26;
|
||||
pathVal = Math.floor(Math.random() * 4) + 50;
|
||||
}
|
||||
else if(areaId === 10){ // GID_RUNAREA_KOBE
|
||||
rampVal = 28;
|
||||
pathVal = 55;
|
||||
}
|
||||
else if(areaId === 11){ // GID_RUNAREA_FUKUOKA
|
||||
rampVal = Math.floor(Math.random() * 4) + 29;
|
||||
pathVal = Math.floor(Math.random() * 4) + 58;
|
||||
}
|
||||
else if(areaId === 12){ // GID_RUNAREA_HAKONE
|
||||
rampVal = Math.floor(Math.random() * 2) + 33;
|
||||
pathVal = Math.floor(Math.random() * 2) + 62;
|
||||
}
|
||||
else if(areaId === 13){ // GID_RUNAREA_TURNPIKE
|
||||
rampVal = Math.floor(Math.random() * 2) + 35;
|
||||
pathVal = Math.floor(Math.random() * 2) + 64;
|
||||
}
|
||||
//14 - 16 are dummy area, 17 is GID_RUNAREA_C1_CLOSED
|
||||
else if(areaId === 18){ // GID_RUNAREA_HIROSHIMA
|
||||
rampVal = Math.floor(Math.random() * 2) + 37;
|
||||
pathVal = Math.floor(Math.random() * 2) + 56;
|
||||
}
|
||||
// Get the ramp and path id
|
||||
let ghost_areas = await ghost_area.GhostArea(areaId);
|
||||
|
||||
// Set the value
|
||||
rampVal = ghost_areas.rampVal;
|
||||
pathVal = ghost_areas.pathVal;
|
||||
|
||||
// Random value lmao, for default ghost trail stuff (any value maybe works)
|
||||
playedAt = date
|
||||
|
Loading…
Reference in New Issue
Block a user