diff --git a/js/common/GLQueryParameters.ts b/js/common/GLQueryParameters.ts index 19aed44f..9ca9f1a3 100644 --- a/js/common/GLQueryParameters.ts +++ b/js/common/GLQueryParameters.ts @@ -9,12 +9,14 @@ import logGlobal from '../../../phet-core/js/logGlobal.js'; import graphingLines from '../graphingLines.js'; import getGameLevelsSchema from '../../../vegas/js/getGameLevelsSchema.js'; -import LineGameConstants from '../linegame/LineGameConstants.js'; + +const NUMBER_OF_GAME_LEVELS = 6; +export { NUMBER_OF_GAME_LEVELS }; const GLQueryParameters = QueryStringMachine.getAll( { // The levels to show in the Line Game screen. - gameLevels: getGameLevelsSchema( LineGameConstants.NUMBER_OF_GAME_LEVELS ), + gameLevels: getGameLevelsSchema( NUMBER_OF_GAME_LEVELS ), // Shows the game reward regardless of score. // For internal use only. diff --git a/js/linegame/LineGameConstants.ts b/js/linegame/LineGameConstants.ts index 676c9790..d3ac3916 100644 --- a/js/linegame/LineGameConstants.ts +++ b/js/linegame/LineGameConstants.ts @@ -15,8 +15,6 @@ const LineGameConstants = { ORIGIN_OFFSET: new Vector2( 790, 300 ), // graph (0,0) will be positioned at these view coordinates - NUMBER_OF_GAME_LEVELS: 6, - // fonts TITLE_FONT: new PhetFont( { size: 40, weight: 'bold' } ), BUTTON_FONT: new PhetFont( { size: 30, weight: 'bold' } ), diff --git a/js/linegame/model/LineGameModel.ts b/js/linegame/model/LineGameModel.ts index 994634b5..2189d577 100644 --- a/js/linegame/model/LineGameModel.ts +++ b/js/linegame/model/LineGameModel.ts @@ -15,7 +15,7 @@ import ChallengeFactory3 from './ChallengeFactory3.js'; import ChallengeFactory4 from './ChallengeFactory4.js'; import ChallengeFactory5 from './ChallengeFactory5.js'; import ChallengeFactory6 from './ChallengeFactory6.js'; -import LineGameConstants from '../LineGameConstants.js'; +import { NUMBER_OF_GAME_LEVELS } from '../../common/GLQueryParameters.js'; export default class LineGameModel extends BaseGameModel { @@ -30,7 +30,7 @@ export default class LineGameModel extends BaseGameModel { new ChallengeFactory5(), new ChallengeFactory6() ]; - assert && assert( challengeFactories.length === LineGameConstants.NUMBER_OF_GAME_LEVELS ); + assert && assert( challengeFactories.length === NUMBER_OF_GAME_LEVELS ); super( challengeFactories, tandem ); } diff --git a/js/linegame/view/BaseGameScreenView.ts b/js/linegame/view/BaseGameScreenView.ts index f7112257..28d13c22 100644 --- a/js/linegame/view/BaseGameScreenView.ts +++ b/js/linegame/view/BaseGameScreenView.ts @@ -27,11 +27,13 @@ export default class BaseGameScreenView extends ScreenView { /** * @param model + * @param gameLevels - show buttons for these game levels * @param levelImages - grid of images for the level-selection buttons, ordered by level * @param rewardNodeFunctions - functions that create nodes for the game reward, ordered by level * @param tandem */ public constructor( model: BaseGameModel, + gameLevels: number[], levelImages: HTMLImageElement[], rewardNodeFunctions: RewardNodeFunction[], tandem: Tandem ) { @@ -44,7 +46,7 @@ export default class BaseGameScreenView extends ScreenView { // sounds const audioPlayer = new GameAudioPlayer(); - this.settingsNode = new SettingsNode( model, this.layoutBounds, levelImages, tandem.createTandem( 'settingsNode' ) ); + this.settingsNode = new SettingsNode( model, this.layoutBounds, levelImages, gameLevels, tandem.createTandem( 'settingsNode' ) ); this.playNode = new PlayNode( model, this.layoutBounds, this.visibleBoundsProperty, audioPlayer ); this.resultsNode = new ResultsNode( model, this.layoutBounds, audioPlayer, rewardNodeFunctions ); diff --git a/js/linegame/view/LineGameLevelSelectionButtonGroup.ts b/js/linegame/view/LineGameLevelSelectionButtonGroup.ts index 3c425ad9..1bf675ae 100644 --- a/js/linegame/view/LineGameLevelSelectionButtonGroup.ts +++ b/js/linegame/view/LineGameLevelSelectionButtonGroup.ts @@ -16,7 +16,6 @@ import GraphingLinesStrings from '../../GraphingLinesStrings.js'; import GamePhase from '../model/GamePhase.js'; import LineGameModel from '../model/LineGameModel.js'; import DerivedStringProperty from '../../../../axon/js/DerivedStringProperty.js'; -import GLQueryParameters from '../../common/GLQueryParameters.js'; import Tandem from '../../../../tandem/js/Tandem.js'; const BUTTON_WIDTH = 175; @@ -31,9 +30,10 @@ export default class LineGameLevelSelectionButtonGroup extends LevelSelectionBut /** * @param model * @param levelImages - images for the level-selection buttons, ordered by level + * @param gameLevels - show buttons for these game levels * @param tandem */ - public constructor( model: LineGameModel, levelImages: HTMLImageElement[], tandem: Tandem ) { + public constructor( model: LineGameModel, levelImages: HTMLImageElement[], gameLevels: number[], tandem: Tandem ) { assert && assert( levelImages.length === model.numberOfLevels, 'one image is required for each game level' ); // To give all button icons the same effective size @@ -59,7 +59,7 @@ export default class LineGameLevelSelectionButtonGroup extends LevelSelectionBut } ); } - const buttonsPerRow = ( GLQueryParameters.gameLevels.length <= 4 ) ? 4 : 3; + const buttonsPerRow = ( gameLevels.length <= 4 ) ? 4 : 3; super( levelSelectionButtonItems, { @@ -78,7 +78,7 @@ export default class LineGameLevelSelectionButtonGroup extends LevelSelectionBut wrap: true, // start a new row when preferredWidth is reached justify: 'center' // horizontal justification }, - gameLevels: GLQueryParameters.gameLevels, + gameLevels: gameLevels, tandem: tandem } ); } diff --git a/js/linegame/view/LineGameScreenView.ts b/js/linegame/view/LineGameScreenView.ts index 48ca7b19..4748a18c 100644 --- a/js/linegame/view/LineGameScreenView.ts +++ b/js/linegame/view/LineGameScreenView.ts @@ -13,6 +13,7 @@ import level3_svg from '../../../images/usa/level3_svg.js'; import level4_svg from '../../../images/usa/level4_svg.js'; import level5_svg from '../../../images/usa/level5_svg.js'; import level6_svg from '../../../images/usa/level6_svg.js'; +import GLQueryParameters, { NUMBER_OF_GAME_LEVELS } from '../../common/GLQueryParameters.js'; import graphingLines from '../../graphingLines.js'; import LineGameModel from '../model/LineGameModel.js'; import BaseGameScreenView from './BaseGameScreenView.js'; @@ -24,6 +25,7 @@ export default class LineGameScreenView extends BaseGameScreenView { // Images for the level-selection buttons, ordered by level const levelImages = [ level1_svg, level2_svg, level3_svg, level4_svg, level5_svg, level6_svg ]; + assert && assert( levelImages.length === NUMBER_OF_GAME_LEVELS ); // functions that create nodes for the game reward, ordered by level const rewardNodeFunctions = [ @@ -34,8 +36,9 @@ export default class LineGameScreenView extends BaseGameScreenView { GLRewardNode.createPaperAirplaneNodes, GLRewardNode.createAssortedNodes ]; + assert && assert( rewardNodeFunctions.length === NUMBER_OF_GAME_LEVELS ); - super( model, levelImages, rewardNodeFunctions, tandem ); + super( model, GLQueryParameters.gameLevels, levelImages, rewardNodeFunctions, tandem ); } } diff --git a/js/linegame/view/SettingsNode.ts b/js/linegame/view/SettingsNode.ts index d2696c7d..53d83ecf 100644 --- a/js/linegame/view/SettingsNode.ts +++ b/js/linegame/view/SettingsNode.ts @@ -25,9 +25,11 @@ export default class SettingsNode extends Node { * @param model * @param layoutBounds * @param levelImages - images for the level-selection buttons, ordered by level + * @param gameLevels - show buttons for these game levels * @param tandem */ - public constructor( model: LineGameModel, layoutBounds: Bounds2, levelImages: HTMLImageElement[], tandem: Tandem ) { + public constructor( model: LineGameModel, layoutBounds: Bounds2, levelImages: HTMLImageElement[], + gameLevels: number[], tandem: Tandem ) { assert && assert( levelImages.length === model.numberOfLevels, 'one image is required for each game level' ); @@ -38,7 +40,7 @@ export default class SettingsNode extends Node { } ); // Group of LevelSelectionButtons - const levelSelectionButtonGroup = new LineGameLevelSelectionButtonGroup( model, levelImages, + const levelSelectionButtonGroup = new LineGameLevelSelectionButtonGroup( model, levelImages, gameLevels, tandem.createTandem( 'levelSelectionButtonGroup' ) ); // title is centered on level-selection buttons