Skip to content

Commit

Permalink
made the expression descriptions get loaded into the collection areas
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Feb 7, 2017
1 parent 23d72df commit bc40fff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions js/game/model/EEGameLevelModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ define( function( require ) {
'use strict';

// modules
var EEChallengeDescriptors = require( 'EXPRESSION_EXCHANGE/game/model/EEChallengeDescriptors' );
var ExpressionCollectionArea = require( 'EXPRESSION_EXCHANGE/game/model/ExpressionCollectionArea' );
var ExpressionManipulationModel = require( 'EXPRESSION_EXCHANGE/common/model/ExpressionManipulationModel' );
var expressionExchange = require( 'EXPRESSION_EXCHANGE/expressionExchange' );
var inherit = require( 'PHET_CORE/inherit' );
var Property = require( 'AXON/Property' );

// constants
var EXPRESSION_COLLECTION_AREA_X_OFFSET = 750;
Expand All @@ -27,10 +29,14 @@ define( function( require ) {
function EEGameLevelModel( level, allowedRepresentations ) {

var self = this;
this.level = level; // @public, read only
this.challengeNumber = 0;

// @public, model that allows user to manipulate coin terms and expressions
this.challengeNumber = 0; // TODO: Make this private later if possible
this.level = level; // {number} @public, read only

// @public - property that refers to the current challenge
this.currentChallengeProperty = new Property( EEChallengeDescriptors[ level ][ this.challengeNumber ] );

// @public, read only, model that allows user to manipulate coin terms and expressions
this.expressionManipulationModel = new ExpressionManipulationModel( {
allowedRepresentations: allowedRepresentations,
partialCancellationEnabled: false // partial cancellation isn't performed in the games
Expand All @@ -44,6 +50,13 @@ define( function( require ) {
EXPRESSION_COLLECTION_AREA_INITIAL_Y_OFFSET + index * EXPRESSION_COLLECTION_AREA_Y_SPACING
) );
} );

// update the expression description associated with the expression collection areas each time a new challenge is set
this.currentChallengeProperty.link( function( currentChallenge ) {
self.expressionCollectionAreas.forEach( function( expressionCollectionArea, index ) {
expressionCollectionArea.expressionDescriptionProperty.set( currentChallenge.expressionsToCollect[ index ] );
} );
} );
}

expressionExchange.register( 'EEGameLevelModel', EEGameLevelModel );
Expand Down
3 changes: 2 additions & 1 deletion js/game/view/EEGameLevelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define( function( require ) {
Node.call( this );

// add the coin term creator box
// TODO: Pass in the challenge itself instead of the number
var coinTermCreatorBox = CoinTermCreatorBoxFactory.createGameScreenCreatorBox(
levelModel.level,
levelModel.challengeNumber,
Expand All @@ -35,7 +36,7 @@ define( function( require ) {
);
this.addChild( coinTermCreatorBox );

// add the expression collection areas
// add the expression collection area nodes
levelModel.expressionCollectionAreas.forEach( function( expressionCollectionArea ) {
self.addChild( new ExpressionCollectionAreaNode( expressionCollectionArea ) );
} );
Expand Down

0 comments on commit bc40fff

Please sign in to comment.