diff --git a/js/common/model/CAVModel.ts b/js/common/model/CAVModel.ts index 358fbb32..7c9c5244 100644 --- a/js/common/model/CAVModel.ts +++ b/js/common/model/CAVModel.ts @@ -43,8 +43,8 @@ export type CAVModelOptions = SelfOptions; const TIME_BETWEEN_RAPID_KICKS = 0.5; // in seconds export default class CAVModel implements TModel { - public readonly soccerBallGroup: CAVObject[]; - public readonly soccerBallGroupCountProperty: NumberProperty; + public readonly soccerBalls: CAVObject[]; + public readonly soccerBallCountProperty: NumberProperty; public readonly isShowingTopMeanProperty: BooleanProperty; public readonly isShowingTopMedianProperty: BooleanProperty; @@ -92,12 +92,11 @@ export default class CAVModel implements TModel { const updateDataMeasures = () => this.updateDataMeasures(); - // TODO: Rename to soccerBalls - this.soccerBallGroupCountProperty = new NumberProperty( 0, { + this.soccerBallCountProperty = new NumberProperty( 0, { range: new Range( 0, this.maxNumberOfObjects ) } ); - this.soccerBallGroup = _.range( 0, this.maxNumberOfObjects ).map( index => { + this.soccerBalls = _.range( 0, this.maxNumberOfObjects ).map( index => { const y0 = CAVObjectType.SOCCER_BALL.radius; const position = new Vector2( 0, y0 ); @@ -142,9 +141,9 @@ export default class CAVModel implements TModel { return soccerBall; } ); - this.soccerBallGroup.forEach( soccerBall => { + this.soccerBalls.forEach( soccerBall => { soccerBall.isActiveProperty.link( isActive => { - this.soccerBallGroupCountProperty.value = this.getActiveSoccerBalls().length; + this.soccerBallCountProperty.value = this.getActiveSoccerBalls().length; } ); } ); @@ -214,8 +213,8 @@ export default class CAVModel implements TModel { this.numberOfUnkickedBallsProperty = DerivedProperty.deriveAny( [ this.numberOfScheduledSoccerBallsToKickProperty, - ...this.soccerBallGroup.map( soccerBall => soccerBall.valueProperty ), - ...this.soccerBallGroup.map( soccerBall => soccerBall.animationModeProperty ) ], () => { + ...this.soccerBalls.map( soccerBall => soccerBall.valueProperty ), + ...this.soccerBalls.map( soccerBall => soccerBall.animationModeProperty ) ], () => { const kickedSoccerBalls = this.getActiveSoccerBalls().filter( soccerBall => soccerBall.valueProperty.value !== null || @@ -257,7 +256,7 @@ export default class CAVModel implements TModel { } ); } ); - this.soccerBallGroup.forEach( soccerBall => { + this.soccerBalls.forEach( soccerBall => { soccerBall.valueProperty.link( updateDataMeasures ); soccerBall.positionProperty.link( updateDataMeasures ); } ); @@ -272,7 +271,7 @@ export default class CAVModel implements TModel { const sortedObjects = this.getSortedLandedObjects(); const medianObjects = CAVModel.getMedianObjectsFromSortedArray( sortedObjects ); - this.soccerBallGroup.forEach( object => { + this.soccerBalls.forEach( object => { object.isMedianObjectProperty.value = medianObjects.includes( object ); } ); @@ -302,7 +301,7 @@ export default class CAVModel implements TModel { * Returns all other objects at the target position of the provided object. */ public getOtherObjectsAtTarget( cavObject: CAVObject ): CAVObject[] { - return this.soccerBallGroup.filter( ( o: CAVObject ) => { + return this.soccerBalls.filter( ( o: CAVObject ) => { return o.valueProperty.value === cavObject.valueProperty.value && cavObject !== o; } ); } @@ -335,7 +334,7 @@ export default class CAVModel implements TModel { this.timeWhenLastBallWasKickedProperty.reset(); this.soccerPlayers.forEach( soccerPlayer => soccerPlayer.reset() ); - this.soccerBallGroup.forEach( soccerBall => soccerBall.reset() ); + this.soccerBalls.forEach( soccerBall => soccerBall.reset() ); this.getNextBallFromPool(); this.activeKickerIndexProperty.reset(); @@ -405,7 +404,7 @@ export default class CAVModel implements TModel { const elapsedTime = this.timeProperty.value - frontPlayer.timestampWhenPoisedBegan!; if ( elapsedTime > 0.075 ) { - const soccerBall = this.soccerBallGroup.find( soccerBall => + const soccerBall = this.soccerBalls.find( soccerBall => soccerBall.valueProperty.value === null && soccerBall.isActiveProperty.value && soccerBall.animationModeProperty.value === AnimationMode.NONE @@ -464,7 +463,7 @@ export default class CAVModel implements TModel { } public getActiveSoccerBalls(): CAVObject[] { - return this.soccerBallGroup.filter( soccerBall => soccerBall.isActiveProperty.value ); + return this.soccerBalls.filter( soccerBall => soccerBall.isActiveProperty.value ); } /** @@ -556,7 +555,7 @@ export default class CAVModel implements TModel { } private getNextBallFromPool(): CAVObject | null { - const nextBallFromPool = this.soccerBallGroup.find( ball => !ball.isActiveProperty.value ) || null; + const nextBallFromPool = this.soccerBalls.find( ball => !ball.isActiveProperty.value ) || null; if ( nextBallFromPool ) { nextBallFromPool.isActiveProperty.value = true; } diff --git a/js/common/view/CAVPlotNode.ts b/js/common/view/CAVPlotNode.ts index 4afd9639..8d953419 100644 --- a/js/common/view/CAVPlotNode.ts +++ b/js/common/view/CAVPlotNode.ts @@ -83,7 +83,7 @@ export default class CAVPlotNode extends Node { // TODO: This overlaps with draggingEnabled const dotPlotObjectNodesDraggableProperty = new BooleanProperty( false ); - model.soccerBallGroup.forEach( ( soccerBall, index ) => { + model.soccerBalls.forEach( ( soccerBall, index ) => { // TODO: This should be new DataPointNode const dotNode = new CAVObjectNode( soccerBall, model.isShowingTopMedianProperty, modelViewTransform, dotPlotObjectNodesDraggableProperty, { diff --git a/js/common/view/CAVScreenView.ts b/js/common/view/CAVScreenView.ts index 2f0769ca..6db2f8a4 100644 --- a/js/common/view/CAVScreenView.ts +++ b/js/common/view/CAVScreenView.ts @@ -91,10 +91,10 @@ export default class CAVScreenView extends ScreenView { tandem: objectNodeGroupTandem.createTandem( 'inputEnabledProperty' ) } ); - model.soccerBallGroup.map( ( soccerBall, index ) => { + model.soccerBalls.map( ( soccerBall, index ) => { const soccerBallNode = new CAVObjectNode( soccerBall, model.isShowingPlayAreaMedianProperty, modelViewTransform, objectNodesInputEnabledProperty, { fill: null, // Only depict as a soccer ball - tandem: options.tandem.createTandem( 'soccerBallGroup' ).createTandem( 'soccerBallNode' + index ) + tandem: options.tandem.createTandem( 'soccerBalls' ).createTandem( 'soccerBallNode' + index ) } ); this.backObjectLayer.addChild( soccerBallNode ); @@ -117,9 +117,9 @@ export default class CAVScreenView extends ScreenView { // add the dragIndicatorArrowNode above the last object when it is added to the play area. if an object was // moved before this happens, don't show the dragIndicatorArrowNode - if ( model.soccerBallGroupCountProperty.value === this.model.physicalRange.max && + if ( model.soccerBallCountProperty.value === this.model.physicalRange.max && objectNodesInputEnabledProperty.value && - _.every( model.soccerBallGroup, cavObject => cavObject.valueProperty.value !== null ) && + _.every( model.soccerBalls, cavObject => cavObject.valueProperty.value !== null ) && !objectHasBeenDragged ) { dragIndicatorArrowNode.centerX = this.modelViewTransform.modelToViewX( value ); @@ -165,7 +165,7 @@ export default class CAVScreenView extends ScreenView { if ( visible ) { // if there is a ball at that location, go above the ball - const ballsAtLocation = model.soccerBallGroup.filter( cavObject => cavObject.valueProperty.value === medianValue ); + const ballsAtLocation = model.soccerBalls.filter( cavObject => cavObject.valueProperty.value === medianValue ); const modelHeight = ballsAtLocation.length * CAVObjectType.SOCCER_BALL.radius * 2; // assumes no spacing const viewHeight = this.modelViewTransform.modelToViewDeltaY( modelHeight ); diff --git a/js/mean-and-median/model/MeanAndMedianModel.ts b/js/mean-and-median/model/MeanAndMedianModel.ts index 5b155e16..b933efc2 100644 --- a/js/mean-and-median/model/MeanAndMedianModel.ts +++ b/js/mean-and-median/model/MeanAndMedianModel.ts @@ -63,7 +63,7 @@ export default class MeanAndMedianModel extends CAVModel { private clearAnimation(): void { this.highlightAnimationIndex = null; - this.soccerBallGroup.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) ); + this.soccerBalls.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) ); } private updateAnimation(): void { diff --git a/js/mean-and-median/view/MedianPlotNode.ts b/js/mean-and-median/view/MedianPlotNode.ts index 7b18d783..435f41fb 100644 --- a/js/mean-and-median/view/MedianPlotNode.ts +++ b/js/mean-and-median/view/MedianPlotNode.ts @@ -34,6 +34,7 @@ export default class MedianPlotNode extends CAVPlotNode { ...providedOptions } ); + // TODO: Dead code // const checkboxGroup = new TopRepresentationCheckboxGroup( model, { // medianBarIconOptions: { // notchDirection: 'down', diff --git a/js/median/model/MedianModel.ts b/js/median/model/MedianModel.ts index f60503ba..91af23bc 100644 --- a/js/median/model/MedianModel.ts +++ b/js/median/model/MedianModel.ts @@ -19,7 +19,7 @@ export default class MedianModel extends CAVModel { public constructor( options: CAVModelOptions ) { super( options ); - this.cards = this.soccerBallGroup.map( ( soccerBall, index ) => new CardModel( soccerBall, { + this.cards = this.soccerBalls.map( ( soccerBall, index ) => new CardModel( soccerBall, { tandem: options.tandem.createTandem( 'cards' ).createTandem( 'card' + index ) } ) );