From 24382998c3fc6ca49d2a773bc649ee73a15bedbf Mon Sep 17 00:00:00 2001 From: Shiroi Kitsu <108461408+shiroikitsu8@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:02:06 +0700 Subject: [PATCH] removing mersenne coz no difference :c --- package.json | 1 - src/modules/cars.ts | 21 ++++----------------- src/modules/game.ts | 5 ++--- src/modules/ghost.ts | 5 ++--- src/modules/resource.ts | 17 ++++++++--------- yarn.lock | 12 ------------ 6 files changed, 16 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 7147b4c..565f206 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@sentry/tracing": "^7.7.0", "@types/pem": "^1.9.6", "body-parser": "^1.20.1", - "chancer": "^2.0.2", "dotenv": "^16.0.1", "express": "^4.18.1", "form-urlencoded": "^6.0.6", diff --git a/src/modules/cars.ts b/src/modules/cars.ts index bf7a1a3..7b0a3d8 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -4,7 +4,6 @@ import { Module } from "module"; import { prisma } from ".."; import { User } from "@prisma/client"; import Long from "long"; -let MersenneTwister = require('chancer'); // Import Proto import * as wm from "../wmmt/wm.proto"; @@ -134,13 +133,13 @@ export default class CarModule extends Module { // Randomize it 5 times for(let i=0; i<5; i++) { - random = MersenneTwister.int(0, opponentTargetCount - 1); // array 0 until max - 1 + random = Math.floor(Math.random() * opponentTargetCount); } // Try randomize it again if it's 1 if(random === 1) { - random = MersenneTwister.int(0, opponentTargetCount - 1); // array 0 until max - 1 + random = Math.floor(Math.random() * opponentTargetCount); } // Check opponents target @@ -415,25 +414,13 @@ export default class CarModule extends Module { // Randomize it 5 times for(let i=0; i<5; i++) { - regionId = MersenneTwister.int(1, 47); + regionId = Math.floor(Math.random() * 47) + 1; } // Try randomize it again if it's 1 if(regionId === 1) { - regionId = MersenneTwister.int(1, 47); - } - - // Error handling if regionId is below 1 - if(regionId < 1) - { - regionId = MersenneTwister.int(1, 47); - } - - // Error handling if regionId is above 47 - if(regionId > 47) - { - regionId = 47 + regionId = Math.floor(Math.random() * 47) + 1; } // Default car values diff --git a/src/modules/game.ts b/src/modules/game.ts index d619878..e8051a9 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -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"; @@ -250,7 +249,7 @@ export default class GameModule extends Module { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, // Set session for saving ghost trail Ghost Battle Mode or Crown Ghost Battle Mode - ghostSessionId: MersenneTwister.int(1, 100) + ghostSessionId: Math.floor(Math.random() * 100) + 1 } } // OCM Battle game mode is completed @@ -260,7 +259,7 @@ export default class GameModule extends Module { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, // Set session for saving ghost trail OCM Ghost Battle Mode - ghostSessionId: MersenneTwister.int(101, 200) + ghostSessionId: Math.floor(Math.random() * 100) + 101 } } // Story mode or TA mode is completed diff --git a/src/modules/ghost.ts b/src/modules/ghost.ts index 105215b..0f6d517 100644 --- a/src/modules/ghost.ts +++ b/src/modules/ghost.ts @@ -4,7 +4,6 @@ import { prisma } from ".."; import { CarPathandTuning } from "@prisma/client"; import Long from "long"; import { Config } from "../config"; -let MersenneTwister = require('chancer'); // Import Proto import * as wm from "../wmmt/wm.proto"; @@ -363,13 +362,13 @@ export default class GhostModule extends Module { // Randomize it 5 times for(let i=0; i<5; i++) { - random = MersenneTwister.int(0, car.length - 1); // array 0 until max - 1 + random = Math.floor(Math.random() * car.length); } // Try randomize it again if it's 1 if(random === 1) { - random = MersenneTwister.int(0, car.length - 1); // array 0 until max - 1 + random = Math.floor(Math.random() * car.length); } diff --git a/src/modules/resource.ts b/src/modules/resource.ts index 6c4a4ee..dc84b75 100644 --- a/src/modules/resource.ts +++ b/src/modules/resource.ts @@ -3,7 +3,6 @@ import { Module } from "module"; import { Config } from "../config"; import { prisma } from ".."; import path from 'path'; -let MersenneTwister = require('chancer'); // Import Proto import * as wm from "../wmmt/wm.proto"; @@ -133,8 +132,8 @@ export default class ResourceModule extends Module { result: resultTime, name: 'GUEST', regionId: 1, // Hokkaido - model: MersenneTwister.int(0, 50), // Randomizing GUEST Car data - visualModel: MersenneTwister.int(0, 100), // Randomizing GUEST Car data + model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data + visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data defaultColor: 0, tunePower: 0, tuneHandling: 0, @@ -171,8 +170,8 @@ export default class ResourceModule extends Module { result: resulttime, name: 'GUEST', regionId: 1, // Hokkaido - model: MersenneTwister.int(0, 50), // Randomizing GUEST Car data - visualModel: MersenneTwister.int(0, 100), // Randomizing GUEST Car data + model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data + visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data defaultColor: 0, tunePower: 0, tuneHandling: 0, @@ -235,8 +234,8 @@ export default class ResourceModule extends Module { result: 0, name: 'GUEST', regionId: 1, // Hokkaido - model: MersenneTwister.int(0, 50), // Randomizing GUEST Car data - visualModel: MersenneTwister.int(0, 100), // Randomizing GUEST Car data + model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data + visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data defaultColor: 0, tunePower: 0, tuneHandling: 0, @@ -298,8 +297,8 @@ export default class ResourceModule extends Module { result: 0, name: 'GUEST', regionId: 1, // Hokkaido - model: MersenneTwister.int(0, 50), // Randomizing GUEST Car data - visualModel: MersenneTwister.int(0, 100), // Randomizing GUEST Car data + model: Math.floor(Math.random() * 50), // Randomizing GUEST Car data + visualModel: Math.floor(Math.random() * 100), // Randomizing GUEST Car data defaultColor: 0, tunePower: 0, tuneHandling: 0, diff --git a/yarn.lock b/yarn.lock index 08557fd..9534504 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1360,13 +1360,6 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chancer@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/chancer/-/chancer-2.0.2.tgz#20b5e6a2009a2987a639f64d93670532ac6f4868" - integrity sha512-MFRbifjvvkHTTDyWtDDv5tWhRyFfR6ZvWVuRxdMnycaGFipjn5MHZC593MTuhNZatyQlys1eAfW+eUX4L2eJpA== - dependencies: - mersenne-twister "^1.0.1" - charenc@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" @@ -1964,11 +1957,6 @@ merge-descriptors@1.0.1: resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== -mersenne-twister@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" - integrity sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA== - methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"