Skip to content

Commit

Permalink
Wrap around from level 10 to 1, and "Next" behaves a bit more normall…
Browse files Browse the repository at this point in the history
…y, see #47
  • Loading branch information
jonathanolson committed Jan 15, 2019
1 parent 405d73e commit 64ae4c6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions js/game/model/BuildingGameModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,8 @@ define( require => {
const currentIndex = levels.indexOf( this.levelProperty.value );

if ( currentIndex >= 0 ) {
// Levels to search through next in order (see https://github.com/phetsims/fractions-common/issues/47)
this.levelProperty.value = [
...levels.slice( currentIndex + 1 ),
...levels.slice( 0, currentIndex + 1 )
].filter( level => {
// Fall back to the current level if all is lost (shouldn't generally happen)
return level.scoreProperty.value < level.numTargets || level === this.levelProperty.value;
} )[ 0 ];
// Wrap levels around if necessary
this.levelProperty.value = levels[ ( currentIndex + 1 ) % levels.length ];
}
} );
}
Expand Down

0 comments on commit 64ae4c6

Please sign in to comment.