Skip to content

Instantly share code, notes, and snippets.

@tailot
Last active June 15, 2021 11:57
Show Gist options
  • Save tailot/2ccaa39f38335a9db466745e736a3427 to your computer and use it in GitHub Desktop.
Save tailot/2ccaa39f38335a9db466745e736a3427 to your computer and use it in GitHub Desktop.
"use strict"
export class MultiDim {
v: any;
constructor(N: number) {
if (N > 0) {
let a = [];
a[N - 1] = undefined;
this.v = a;
}
}
}
"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