Skip to content

Commit

Permalink
refactoring: add types+“const that”
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Jun 14, 2024
1 parent 0f58d96 commit 8702e59
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fc-solve/site/wml/src/ts/web-fcs-api-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ class MSRand {
that.module_wrapper.ms_rand__init(that.rander, "" + that.gamenumber);
return;
}
public max_rand(mymax) {
public max_rand(mymax: number): number {
const that = this;
return that.module_wrapper.ms_rand__mod_rand(that.rander, mymax);
}
public shuffle(deck) {
const that = this;
if (deck.length) {
let i = deck.length;
while (--i) {
const j = this.max_rand(i + 1);
const j = that.max_rand(i + 1);
const tmp = deck[i];
deck[i] = deck[j];
deck[j] = tmp;
Expand Down

0 comments on commit 8702e59

Please sign in to comment.