Skip to content

Commit

Permalink
removed random functions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkarnold committed Oct 31, 2021
1 parent 9d3c61f commit fbba5d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
20 changes: 0 additions & 20 deletions src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export class HomeComponent implements OnInit, OnDestroy {


ngOnInit(): void {
console.log(getRandomInt(0, 5), getRandomInt(0, 5), getRandomInt(0, 5));
for (const tierObj of this.nations) {
for (let i = 0; i < tierObj.nations.length; i++) {
this.nationsList.push(tierObj.nations[i].name);
Expand Down Expand Up @@ -3161,22 +3160,3 @@ function getRandomInt(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) + min);
//The maximum is inclusive and the minimum is inclusive
}

// function xmur3(str: string) {
// for(var i = 0, h = 1779033703 ^ str.length; i < str.length; i++)
// h = Math.imul(h ^ str.charCodeAt(i), 3432918353),
// h = h << 13 | h >>> 19;
// return function() {
// h = Math.imul(h ^ h >>> 16, 2246822507);
// h = Math.imul(h ^ h >>> 13, 3266489909);
// return (h ^= h >>> 16) >>> 0;
// }
// }
// function mulberry32(a: number) {
// return function() {
// var t = a += 0x6D2B79F5;
// t = Math.imul(t ^ t >>> 15, t | 1);
// t ^= t + Math.imul(t ^ t >>> 7, t | 61);
// return ((t ^ t >>> 14) >>> 0) / 4294967296;
// }
// }
24 changes: 2 additions & 22 deletions src/app/services/firestore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,31 +649,11 @@ export class FirestoreService {
}

function getRandomInt(min: number, max: number) {
let seed = xmur3("string-seed");
let rand = mulberry32(seed());

min = Math.ceil(min);
max = Math.floor(max);

return Math.floor(rand() * (max - min + 1) + min);
return Math.floor(Math.random() * (max - min + 1) + min);
//The maximum is inclusive and the minimum is inclusive
}

function xmur3(str: string) {
for(var i = 0, h = 1779033703 ^ str.length; i < str.length; i++)
h = Math.imul(h ^ str.charCodeAt(i), 3432918353),
h = h << 13 | h >>> 19;
return function() {
h = Math.imul(h ^ h >>> 16, 2246822507);
h = Math.imul(h ^ h >>> 13, 3266489909);
return (h ^= h >>> 16) >>> 0;
}
}
function mulberry32(a: number) {
return function() {
var t = a += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
}

0 comments on commit fbba5d1

Please sign in to comment.