Skip to content

Commit

Permalink
Merge pull request #42 from samarsha/samarsha/no-return
Browse files Browse the repository at this point in the history
Replace return with if-else chain
  • Loading branch information
bamarsha authored Jun 9, 2020
2 parents ef146c7 + b519f53 commit c16d678
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/superposition/system/LevelSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@ final class LevelSystem(levels: LevelPlaylist) extends EntitySystem {
override def update(deltaTime: Float): Unit = {
if (input.isKeyJustPressed(P)) {
levels.prev()
return
}
if (input.isKeyJustPressed(R)) {
} else if (input.isKeyJustPressed(R)) {
levels.play()
return
}
val multiverse = levels.current.get.multiverse
val allExitSquares = exits.flatMap(ClassicalPosition.mapper.get(_).cells).toSet
val playersAtExits = players.map(QuantumPosition.mapper.get(_).cell)
.forall(entityCell => multiverse.universes.map(_.state(entityCell)).forall(allExitSquares.contains))
if (input.isKeyJustPressed(N) || playersAtExits) {
levels.next()
return
} else {
val multiverse = levels.current.get.multiverse
val allExitSquares = exits.flatMap(ClassicalPosition.mapper.get(_).cells).toSet
val playersAtExits = players.map(QuantumPosition.mapper.get(_).cell)
.forall(entityCell => multiverse.universes.map(_.state(entityCell)).forall(allExitSquares.contains))
if (input.isKeyJustPressed(N) || playersAtExits) {
levels.next()
}
}
}
}

0 comments on commit c16d678

Please sign in to comment.