more random
This commit is contained in:
parent
1d3a8e6880
commit
43777cc690
@ -129,7 +129,19 @@ export default class CarModule extends Module {
|
||||
console.log('Challengers Available');
|
||||
|
||||
// Randomize pick
|
||||
let random: number = MersenneTwister.int(0, opponentTargetCount - 1);
|
||||
let random: number = 1;
|
||||
|
||||
// Randomize it 5 times
|
||||
for(let i=0; i<5; i++)
|
||||
{
|
||||
random = MersenneTwister.int(0, opponentTargetCount - 1); // array 0 until max - 1
|
||||
}
|
||||
|
||||
// Try randomize it again if it's 1
|
||||
if(random === 1)
|
||||
{
|
||||
random = MersenneTwister.int(0, opponentTargetCount - 1); // array 0 until max - 1
|
||||
}
|
||||
|
||||
// Check opponents target
|
||||
let opponentTarget = await prisma.carStampTarget.findMany({
|
||||
@ -399,7 +411,24 @@ export default class CarModule extends Module {
|
||||
|
||||
// Randomize regionId
|
||||
let regionId: number = 18;
|
||||
|
||||
// Randomize it 5 times
|
||||
for(let i=0; i<5; i++)
|
||||
{
|
||||
regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Try randomize it again if it's 1
|
||||
if(regionId === 1)
|
||||
{
|
||||
regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Error handling if regionId is above 47
|
||||
if(regionId > 47)
|
||||
{
|
||||
regionId = 47
|
||||
}
|
||||
|
||||
// Default car values
|
||||
let carInsert = {
|
||||
|
@ -136,12 +136,6 @@ export default class GameModule extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
// Check region id is 0
|
||||
if(body.car!.regionId! === 0)
|
||||
{
|
||||
body.car!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Check playet at timestamp
|
||||
let timestamps = 0;
|
||||
if(body.car?.lastPlayedAt !== undefined && body.car?.lastPlayedAt !== null)
|
||||
@ -436,11 +430,6 @@ export default class GameModule extends Module {
|
||||
ghostOpponentCar!.country = 'GLB';
|
||||
}
|
||||
|
||||
if(ghostOpponentCar!.regionId === 0)
|
||||
{
|
||||
ghostOpponentCar!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Get Opponent 1 tune
|
||||
ghostOpponentCar!.tunePower = ghostHistoryData![i].opponent1TunePower!;
|
||||
ghostOpponentCar!.tuneHandling = ghostHistoryData![i].opponent1TuneHandling!;
|
||||
@ -478,11 +467,6 @@ export default class GameModule extends Module {
|
||||
ghostOpponentCar2!.country = 'GLB';
|
||||
}
|
||||
|
||||
if(ghostOpponentCar!.regionId === 0)
|
||||
{
|
||||
ghostOpponentCar2!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Get Opponent 2 tune
|
||||
ghostOpponentCar2!.tunePower = ghostHistoryData![i].opponent2TunePower!;
|
||||
ghostOpponentCar2!.tuneHandling = ghostHistoryData![i].opponent2TuneHandling!;
|
||||
@ -517,11 +501,6 @@ export default class GameModule extends Module {
|
||||
ghostOpponentCar3!.country = 'GLB';
|
||||
}
|
||||
|
||||
if(ghostOpponentCar!.regionId === 0)
|
||||
{
|
||||
ghostOpponentCar3!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Get Opponent 3 tune
|
||||
ghostOpponentCar3!.tunePower = ghostHistoryData![i].opponent3TunePower!;
|
||||
ghostOpponentCar3!.tuneHandling = ghostHistoryData![i].opponent3TuneHandling!;
|
||||
|
@ -357,18 +357,31 @@ export default class GhostModule extends Module {
|
||||
// Choose the user's car data randomly to appear
|
||||
while(arr.length < maxNumber)
|
||||
{
|
||||
// Pick random car Id
|
||||
let randomNumber = MersenneTwister.int(0, car.length-1);
|
||||
// Randomize pick
|
||||
let random: number = 1;
|
||||
|
||||
if(arr.indexOf(randomNumber) === -1)
|
||||
// Randomize it 5 times
|
||||
for(let i=0; i<5; i++)
|
||||
{
|
||||
random = MersenneTwister.int(0, car.length - 1); // array 0 until max - 1
|
||||
}
|
||||
|
||||
// Try randomize it again if it's 1
|
||||
if(random === 1)
|
||||
{
|
||||
random = MersenneTwister.int(0, car.length - 1); // array 0 until max - 1
|
||||
}
|
||||
|
||||
|
||||
if(arr.indexOf(random) === -1)
|
||||
{
|
||||
// Push current number to array
|
||||
arr.push(randomNumber);
|
||||
arr.push(random);
|
||||
|
||||
// Check if ghost trail for certain car is available
|
||||
let ghost_trails = await prisma.ghostTrail.findFirst({
|
||||
where: {
|
||||
carId: car[randomNumber].carId,
|
||||
carId: car[random].carId,
|
||||
area: body.area,
|
||||
crownBattle: false
|
||||
},
|
||||
@ -377,31 +390,25 @@ export default class GhostModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
// If regionId is 0 or not set, game will crash after defeating the ghost
|
||||
if(car[randomNumber]!.regionId === 0)
|
||||
{
|
||||
car[randomNumber].regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Push user's car data without ghost trail
|
||||
if(!(ghost_trails))
|
||||
{
|
||||
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
|
||||
car: car[randomNumber]
|
||||
car: car[random]
|
||||
}));
|
||||
}
|
||||
// Push user's car data with ghost trail
|
||||
else
|
||||
{
|
||||
// Set the tunePower used when playing certain area
|
||||
car[randomNumber].tunePower = ghost_trails!.tunePower;
|
||||
car[random].tunePower = ghost_trails!.tunePower;
|
||||
|
||||
// Set the tuneHandling used when playing certain area
|
||||
car[randomNumber].tuneHandling = ghost_trails!.tuneHandling;
|
||||
car[random].tuneHandling = ghost_trails!.tuneHandling;
|
||||
|
||||
// Push data to Ghost car proto
|
||||
lists_ghostcar.push(wm.wm.protobuf.GhostCar.create({
|
||||
car: car[randomNumber],
|
||||
car: car[random],
|
||||
nonhuman: false,
|
||||
type: wm.wm.protobuf.GhostType.GHOST_NORMAL,
|
||||
trailId: ghost_trails!.dbId!
|
||||
|
@ -2,7 +2,6 @@ import { Application } from "express";
|
||||
import { Module } from "module";
|
||||
import { prisma } from "..";
|
||||
import { Config } from "../config";
|
||||
let MersenneTwister = require('chancer');
|
||||
|
||||
// Import Proto
|
||||
import * as wm from "../wmmt/wm.proto";
|
||||
@ -487,12 +486,6 @@ export default class GhostModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
// If regionId is 0 or not set, game will crash after defeating the ghost
|
||||
if(cars!.regionId === 0)
|
||||
{
|
||||
cars!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Set the tunePower used when playing ghost crown
|
||||
cars!.tunePower = ocmTallyRecord!.tunePower;
|
||||
|
||||
@ -609,12 +602,6 @@ export default class GhostModule extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
// If regionId is 0 or not set, game will crash after defeating the ghost
|
||||
if(cars!.regionId === 0)
|
||||
{
|
||||
cars!.regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
|
||||
// Set the tunePower used when playing ghost crown
|
||||
cars!.tunePower = ocmTallyRecord!.tunePower;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import e, { Application } from "express";
|
||||
import { Application } from "express";
|
||||
import { Module } from "module";
|
||||
import { Config } from "../config";
|
||||
import { prisma } from "..";
|
||||
|
@ -3,7 +3,6 @@ import { Config } from "../config";
|
||||
import { Module } from "module";
|
||||
import { prisma } from "..";
|
||||
import { Car } from "@prisma/client";
|
||||
let MersenneTwister = require('chancer');
|
||||
|
||||
// Import Proto
|
||||
import * as wm from "../wmmt/wm.proto";
|
||||
@ -249,14 +248,6 @@ export default class TerminalModule extends Module {
|
||||
});
|
||||
}
|
||||
|
||||
for(let i=0; i<cars.length; i++)
|
||||
{
|
||||
if(cars[i].regionId === 0)
|
||||
{
|
||||
cars[i].regionId = MersenneTwister.int(1, 47);
|
||||
}
|
||||
}
|
||||
|
||||
let msg = {
|
||||
hitCount: cars.length,
|
||||
cars: cars
|
||||
|
Loading…
x
Reference in New Issue
Block a user