Last active
June 15, 2021 11:57
-
-
Save tailot/2ccaa39f38335a9db466745e736a3427 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
export class MultiDim { | |
v: any; | |
constructor(N: number) { | |
if (N > 0) { | |
let a = []; | |
a[N - 1] = undefined; | |
this.v = a; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
import { MultiDim } from "./MultiDim" | |
class FileCombat { | |
FileFighters: Array<MultiDim>; | |
constructor(FileFighters: Array<MultiDim>) { | |
this.FileFighters = FileFighters; | |
this.generator(); | |
} | |
private generator() { | |
this.FileFighters.forEach((v, i, a) => { | |
let ve = this.random(v.v.length); | |
while (ve > 0) { | |
let iter = []; | |
let xe = this.random(v.v.length); | |
iter[xe] = undefined; | |
iter.forEach((m, o, x) => { | |
this.FileFighters[i].v[o] = true; | |
}) | |
ve--; | |
} | |
}) | |
} | |
private random(n: number): number { | |
return Math.floor(Math.random() * n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment