Skip to content

Commit

Permalink
Removed micro-delay, when awaiting for the last reel spinning
Browse files Browse the repository at this point in the history
  • Loading branch information
asiryk committed Sep 17, 2020
1 parent 09856a1 commit 4788a35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slot-game",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"license": "MIT",
"scripts": {
Expand Down
18 changes: 7 additions & 11 deletions src/core/ReelsContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ export default class ReelsContainer {
if (Date.now() >= start + 2000) break;
}

const arr = this.reels.map(reel => reel.sprites[1]);
return this.checkIfWin(arr);
// reel.sprites[2] - Middle visible symbol of the reel
//
return this.checkIfWin(this.reels.map(reel => reel.sprites[2]));
}

private async* infiniteSpinning() {
while (true) {
for (let i = 0; i < this.reels.length; i++) {
if (i === this.reels.length - 1) {
await this.reels[i].spinOneTime();
this.blessRNG();
yield;
}

this.reels[i].spinOneTime();
}
const spinningPromises = this.reels.map(reel => reel.spinOneTime());
await Promise.all(spinningPromises);
this.blessRNG();
yield;
}
}

Expand Down

0 comments on commit 4788a35

Please sign in to comment.