Skip to content

Commit

Permalink
Rename objectGroup => soccerBallGroup, see #160
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Apr 27, 2023
1 parent 014d5a7 commit e6b1e18
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
28 changes: 14 additions & 14 deletions js/common/model/CAVModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type CAVModelOptions = SelfOptions;
const TIME_BETWEEN_RAPID_KICKS = 0.5; // in seconds

export default class CAVModel implements TModel {
public readonly objectGroup: PhetioGroup<CAVObject, [ StrictOmit<CAVObjectOptions, 'tandem'> ]>;
public readonly soccerBallGroup: PhetioGroup<CAVObject, [ StrictOmit<CAVObjectOptions, 'tandem'> ]>;

public readonly isShowingTopMeanProperty: BooleanProperty;
public readonly isShowingTopMedianProperty: BooleanProperty;
Expand Down Expand Up @@ -103,12 +103,12 @@ export default class CAVModel implements TModel {

const options = optionize<CAVModelOptions, SelfOptions>()( {}, providedOptions );

this.objectGroup = new PhetioGroup( ( tandem, providedOptions: StrictOmit<CAVObjectOptions, 'tandem'> ) => {
this.soccerBallGroup = new PhetioGroup( ( tandem, providedOptions: StrictOmit<CAVObjectOptions, 'tandem'> ) => {

const options = optionize<StrictOmit<CAVObjectOptions, 'tandem'>, EmptySelfOptions, CAVObjectOptions>()( {
// If it's the first element in the group, mark as isFirstObject. For creating archetype, the objectGroup does
// not yet exist, so just mark it as first
isFirstObject: this.objectGroup ? this.objectGroup.count === 0 : true,
isFirstObject: this.soccerBallGroup ? this.soccerBallGroup.count === 0 : true,
tandem: tandem
}, providedOptions );

Expand Down Expand Up @@ -231,10 +231,10 @@ export default class CAVModel implements TModel {
cavObject.valueProperty.link( () => this.objectChangedEmitter.emit( cavObject ) );
cavObject.positionProperty.link( () => this.objectChangedEmitter.emit( cavObject ) );
};
this.objectGroup.forEach( objectCreatedListener );
this.objectGroup.elementCreatedEmitter.addListener( objectCreatedListener );
this.soccerBallGroup.forEach( objectCreatedListener );
this.soccerBallGroup.elementCreatedEmitter.addListener( objectCreatedListener );

this.numberOfRemainingObjectsProperty = new DerivedProperty( [ this.objectGroup.countProperty ], count => {
this.numberOfRemainingObjectsProperty = new DerivedProperty( [ this.soccerBallGroup.countProperty ], count => {
return this.maxNumberOfObjects - count;
} );

Expand Down Expand Up @@ -289,7 +289,7 @@ export default class CAVModel implements TModel {
}
} );

this.objectGroup.elementCreatedEmitter.addListener( cavObject => {
this.soccerBallGroup.elementCreatedEmitter.addListener( cavObject => {
cavObject.valueProperty.link( ( value, oldValue ) => {
if ( value !== null && oldValue === null ) {
if ( !phet.joist.sim.isSettingPhetioStateProperty.value ) {
Expand Down Expand Up @@ -319,7 +319,7 @@ export default class CAVModel implements TModel {
const sortedObjects = this.getSortedLandedObjects();
const medianObjects = this.medianObjectsFromSortedArray( sortedObjects );

this.objectGroup.forEach( object => {
this.soccerBallGroup.forEach( object => {
object.isMedianObjectProperty.value = medianObjects.includes( object );
} );

Expand Down Expand Up @@ -365,7 +365,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.objectGroup.filter( ( o: CAVObject ) => {
return this.soccerBallGroup.filter( ( o: CAVObject ) => {
return o.valueProperty.value === cavObject.valueProperty.value && cavObject !== o;
} );
}
Expand Down Expand Up @@ -393,7 +393,7 @@ export default class CAVModel implements TModel {
* Clears out the data and the cards
*/
public clearData(): void {
this.objectGroup.clear();
this.soccerBallGroup.clear();

this.numberOfScheduledSoccerBallsToKickProperty.reset();
this.timeProperty.reset();
Expand Down Expand Up @@ -423,7 +423,7 @@ export default class CAVModel implements TModel {
}

public getSortedLandedObjects(): CAVObject[] {
return _.sortBy( this.objectGroup.filter( cavObject => cavObject.valueProperty.value !== null ),
return _.sortBy( this.soccerBallGroup.filter( cavObject => cavObject.valueProperty.value !== null ),

// The numerical value takes predence for sorting
cavObject => cavObject.valueProperty.value,
Expand All @@ -440,7 +440,7 @@ export default class CAVModel implements TModel {
*/
public step( dt: number ): void {
this.timeProperty.value += dt;
this.objectGroup.forEach( cavObject => cavObject.step( dt ) );
this.soccerBallGroup.forEach( cavObject => cavObject.step( dt ) );

const frontPlayer = this.soccerPlayers[ this.activeKickerIndexProperty.value ];

Expand Down Expand Up @@ -524,7 +524,7 @@ export default class CAVModel implements TModel {
const y0 = CAVObjectType.SOCCER_BALL.radius;
const position = new Vector2( 0, y0 );

return this.objectGroup.createNextElement( {
return this.soccerBallGroup.createNextElement( {
position: position
} );
}
Expand All @@ -533,7 +533,7 @@ export default class CAVModel implements TModel {
* When a ball lands on the ground, animate all other balls that were at this location above the landed ball.
*/
private soccerBallLandedListener( cavObject: CAVObject, value: number ): void {
const otherObjectsInStack = this.objectGroup.filter( x => x.valueProperty.value === value && x !== cavObject );
const otherObjectsInStack = this.soccerBallGroup.filter( x => x.valueProperty.value === value && x !== cavObject );
const sortedOthers = _.sortBy( otherObjectsInStack, object => object.positionProperty.value.y );

sortedOthers.forEach( ( cavObject, index ) => {
Expand Down
8 changes: 4 additions & 4 deletions js/common/view/CAVPlotNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class CAVPlotNode extends Node {
tandem: tandem,
fill: options.dataPointFill
} );
}, () => [ model.objectGroup.archetype ], {
}, () => [ model.soccerBallGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: options.tandem.createTandem( 'dotNodeGroup' ),
supportsDynamicState: false
Expand All @@ -112,10 +112,10 @@ export default class CAVPlotNode extends Node {
} );
map.set( cavObject, dotNode );
};
model.objectGroup.forEach( createDotNode );
model.objectGroup.elementCreatedEmitter.addListener( createDotNode );
model.soccerBallGroup.forEach( createDotNode );
model.soccerBallGroup.elementCreatedEmitter.addListener( createDotNode );

model.objectGroup.elementDisposedEmitter.addListener( cavObject => {
model.soccerBallGroup.elementDisposedEmitter.addListener( cavObject => {
const viewNode = map.get( cavObject )!;
dotNodeGroup.disposeElement( viewNode );
map.delete( cavObject );
Expand Down
14 changes: 7 additions & 7 deletions js/common/view/CAVScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class CAVScreenView extends ScreenView {
fill: null, // Only depict as a soccer ball
tandem: tandem
} );
}, () => [ model.objectGroup.archetype ], {
}, () => [ model.soccerBallGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( Node.NodeIO ),
tandem: objectNodeGroupTandem,
supportsDynamicState: false
Expand Down Expand Up @@ -128,9 +128,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.objectGroup.countProperty.value === this.model.physicalRange.max &&
if ( model.soccerBallGroup.countProperty.value === this.model.physicalRange.max &&
objectNodesInputEnabledProperty.value &&
_.every( model.objectGroup.getArray(), cavObject => cavObject.valueProperty.value !== null ) &&
_.every( model.soccerBallGroup.getArray(), cavObject => cavObject.valueProperty.value !== null ) &&
!objectHasBeenDragged ) {
dragIndicatorArrowNode.centerX = this.modelViewTransform.modelToViewX( value );

Expand All @@ -155,10 +155,10 @@ export default class CAVScreenView extends ScreenView {

map.set( cavObject, cavObjectNode );
};
model.objectGroup.forEach( createObjectNode );
model.objectGroup.elementCreatedEmitter.addListener( createObjectNode );
model.soccerBallGroup.forEach( createObjectNode );
model.soccerBallGroup.elementCreatedEmitter.addListener( createObjectNode );

model.objectGroup.elementDisposedEmitter.addListener( cavObject => {
model.soccerBallGroup.elementDisposedEmitter.addListener( cavObject => {
const viewNode = map.get( cavObject )!;
objectNodeGroup.disposeElement( viewNode );
map.delete( cavObject );
Expand All @@ -174,7 +174,7 @@ export default class CAVScreenView extends ScreenView {
if ( visible ) {

// if there is a ball at that location, go above the ball
const ballsAtLocation = model.objectGroup.filter( cavObject => cavObject.valueProperty.value === medianValue );
const ballsAtLocation = model.soccerBallGroup.filter( cavObject => cavObject.valueProperty.value === medianValue );
const modelHeight = ballsAtLocation.length * CAVObjectType.SOCCER_BALL.radius * 2; // assumes no spacing

const viewHeight = this.modelViewTransform.modelToViewDeltaY( modelHeight );
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/CardNodeContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export default class CardNodeContainer extends Node {
} );
};

model.objectGroup.forEach( objectCreatedListener );
model.objectGroup.elementCreatedEmitter.addListener( objectCreatedListener );
model.soccerBallGroup.forEach( objectCreatedListener );
model.soccerBallGroup.elementCreatedEmitter.addListener( objectCreatedListener );

model.cardModelGroup.elementDisposedEmitter.addListener( cardModel => {
const cardNode = this.getCardNode( cardModel.cavObject )!;
Expand Down
2 changes: 1 addition & 1 deletion js/mean-and-median/model/MeanAndMedianModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class MeanAndMedianModel extends CAVModel {

private clearAnimation(): void {
this.highlightAnimationIndex = null;
this.objectGroup.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) );
this.soccerBallGroup.forEach( cavObject => cavObject.isShowingAnimationHighlightProperty.set( false ) );
}

private updateAnimation(): void {
Expand Down
2 changes: 1 addition & 1 deletion js/mean-and-median/view/MedianPlotNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class MedianPlotNode extends CAVPlotNode {

const updateMedianBarNode = () => {

const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
object => object.valueProperty.value );
const leftmostDot = sortedDots[ 0 ];

Expand Down
2 changes: 1 addition & 1 deletion js/median/model/MedianModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class MedianModel extends CAVModel {
return new CardModel( cavObject, {
tandem: tandem
} );
}, () => [ this.objectGroup.archetype ], {
}, () => [ this.soccerBallGroup.archetype ], {
phetioType: PhetioGroup.PhetioGroupIO( CardModel.CardModelIO ),
tandem: options.tandem.createTandem( 'cardModelGroup' )
} );
Expand Down
2 changes: 1 addition & 1 deletion js/variability/view/IQRNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class IQRNode extends CAVPlotNode {

const updateIQRNode = () => {

const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
object => object.valueProperty.value );
const leftmostDot = sortedDots[ 0 ];
const rightmostDot = sortedDots[ sortedDots.length - 1 ];
Expand Down
2 changes: 1 addition & 1 deletion js/variability/view/MADNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class MADNode extends CAVPlotNode {

const children: Node[] = [];

const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
object => object.valueProperty.value );

if ( sortedDots.length > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion js/variability/view/RangeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class RangeNode extends CAVPlotNode {

const updateRangeNode = () => {

const sortedDots = _.sortBy( model.objectGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
const sortedDots = _.sortBy( model.soccerBallGroup.getArrayCopy().filter( object => object.valueProperty.value !== null ),
object => object.valueProperty.value );
const leftmostDot = sortedDots[ 0 ];
const rightmostDot = sortedDots[ sortedDots.length - 1 ];
Expand Down

0 comments on commit e6b1e18

Please sign in to comment.