{"size": 845, "ext": "js", "max_stars_repo_path": "src/states/score.js", "max_stars_repo_name": "feldmuesle/slotmachine", "max_stars_repo_stars_event_min_datetime": "2022-02-28T20:58:56.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T20:58:56.000Z", "max_issues_repo_path": "src/states/score.js", "max_issues_repo_name": "feldmuesle/slotmachine", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/states/score.js", "max_forks_repo_name": "feldmuesle/slotmachine", "max_forks_repo_forks_event_min_datetime": "2022-02-28T20:58:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-28T20:58:57.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 22.2368421053, "max_line_length": 75, "alphanum_fraction": 0.6165680473}
import State from './state'

const GEM_POS_Y = 450

export default class ScoreState extends State {

  execute(scene, _) {
    const gems = scene.gemSpawner.group
    let counter = 0

    gems.setVelocityY(-50)

    gems.children.iterate((gem) => {
      gem.body.allowGravity = false
      if (gem.y <= GEM_POS_Y ) {
        gem.body.stop()
        counter ++
      }
    })

    gems.rotate(0.02)

    if (counter === 3 && (!scene.winnerText || !scene.winnerText.active)) {

      const newScore = scene.calculateScore(scene.matches)

      gems.setVelocityY(0)
      scene.winnerText = scene.createWinnerText(400, 300, scene.matches)
      scene.scoreLabel.add(newScore)
      scene.score = scene.score + newScore

      scene.time.delayedCall(3000, () => {
          this.stateMachine.transition('restart')
      }, null, scene)
    }
  }
}
