Skip to content

Commit

Permalink
Rename PlayArea -> CountingArea, see phetsims/number-suite-common#40
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed Mar 31, 2023
1 parent de52ae0 commit 4404f84
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 65 deletions.
115 changes: 115 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"comment": "# number-play 1.1.0-dev.10 Thu Mar 30 2023 16:43:37 GMT-0600 (Mountain Daylight Time)",
"assert": {
"sha": "c13a8c7741d95fbd8e37619c66ebcca8686dffe7",
"branch": "master"
},
"axon": {
"sha": "c954b7cf3cf0ac9d8b27911e1e3a85f709511547",
"branch": "master"
},
"brand": {
"sha": "d2b54ef4d29edc31e64adb2f9488803811cad03a",
"branch": "master"
},
"chipper": {
"sha": "83b6dcc1aa7b210f2fe59b85917d75ffa22f6649",
"branch": "master"
},
"counting-common": {
"sha": "2377cbdfeec6e3b0154860834e22ae9ef6e9131e",
"branch": "master"
},
"dot": {
"sha": "e0acfaf31c8847d2e95dbe116d270c22fadccad2",
"branch": "master"
},
"joist": {
"sha": "63178766e18032460eded6bfc522a59ee99030b6",
"branch": "master"
},
"kite": {
"sha": "1aeb2c03719b4445ad031ba112a419195fd072c9",
"branch": "master"
},
"number-play": {
"sha": "50d9ca2caeb14551c47dfc6bb16203d7ce3ea853",
"branch": "master"
},
"number-suite-common": {
"sha": "78a13c1708d1296aa91e462bb1cdaaba705ef723",
"branch": "master"
},
"perennial-alias": {
"sha": "a560491bc2433438b505cfd052fb205b14e7a402",
"branch": "master"
},
"phet-core": {
"sha": "3846be1447221ccc8b627c8c9e4126593b93e076",
"branch": "master"
},
"phet-io": {
"sha": "26f080f275b3272715160f7add4048385ee33316",
"branch": "master"
},
"phet-io-sim-specific": {
"sha": "5ed523a28a84469757fd165d1f0b4e334544b9f5",
"branch": "master"
},
"phet-io-wrappers": {
"sha": "91c730aa306d6c441b8f20e06ce921f39357f874",
"branch": "master"
},
"phetcommon": {
"sha": "1017d4f9b97256302f796146da155742e4eb5c3c",
"branch": "master"
},
"phetmarks": {
"sha": "c6c4e824e4bf13d0e467069c49381461787db16f",
"branch": "master"
},
"query-string-machine": {
"sha": "ff7b4489cd1ab78b08f1e3a38e89c6d89abcd56a",
"branch": "master"
},
"scenery": {
"sha": "33c28b269d28ea5e0d412e54ee1891b2d7ee8110",
"branch": "master"
},
"scenery-phet": {
"sha": "ec52f6e101d67c46ce4cc774b81f3c6576d0dccc",
"branch": "master"
},
"sherpa": {
"sha": "efff295ef6ba7c442cd868fb71b6d51d560104b1",
"branch": "master"
},
"studio": {
"sha": "77315e1a0390aa93d78122bb269bd13297f06e7b",
"branch": "master"
},
"sun": {
"sha": "dc743285f7fd10e85d475b26d030142ec565dcb4",
"branch": "master"
},
"tambo": {
"sha": "4e4aab289995d7f6e3ddb0f77116618a6aa33b43",
"branch": "master"
},
"tandem": {
"sha": "5c7294d5a741a24f500bb3b594d5603a5827675f",
"branch": "master"
},
"twixt": {
"sha": "408daa991138eeaacd7dcd0c144ebace9b6b36ad",
"branch": "master"
},
"utterance-queue": {
"sha": "5bc222ddf20559f18eb38f51a9e16b9af1a29106",
"branch": "master"
},
"vegas": {
"sha": "abfc0d4f20dc52c65c828291c6a81081a5e8305b",
"branch": "master"
}
}
2 changes: 1 addition & 1 deletion doc/implementation-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Both games rely on the abstract classes
[NumberPlayGameLevel](https://github.com/phetsims/number-play/blob/master/js/game/model/NumberPlayGameLevel.ts) and
[NumberPlayGameLevelNode](https://github.com/phetsims/number-play/blob/master/js/game/view/NumberPlayGameLevelNode.ts).

The 'Counting' game builds upon the play areas that are used in the _Ten_, _Twenty_, and _Compare_ screens, but doesn't
The 'Counting' game builds upon the countingAreas that are used in the _Ten_, _Twenty_, and _Compare_ screens, but doesn't
include the controls for changing the object type or adding/removing objects.
[Subitizer](https://github.com/phetsims/number-play/blob/master/js/game/model/Subitizer.ts) controls the game sequence
and determines the shapes to show in the 'Subitize' game.
Expand Down
6 changes: 3 additions & 3 deletions doc/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ the number that matches the number of objects. When the correct answer button is
### Counting

The 'Counting' game builds on the **Ten**, **Twenty**, and **Compare** screens by using a simpler version of the
"play areas" from those screens. Just like on those screens, the play areas display the objects in a variety of
"counting areas" from those screens. Just like on those screens, the counting areas display the objects in a variety of
representations, and allow the user to move the objects around. The game also uses the 'Ten Frame' representation from
the **Ten** and **Twenty** screens. Both levels show a representation of a number by alternating between objects in a
play area and a ten frame.
counting area and a ten frame.

In Level 1, objects in the play area are shown in the "ungrouped" state, where they do not
In Level 1, objects in the counting area are shown in the "ungrouped" state, where they do not
have card backgrounds and cannot be combined with other objects.

In Level 2, the objects are shown in the "grouped" state. The size of each group is randomly chosen from the divisors
Expand Down
52 changes: 26 additions & 26 deletions js/common/model/NumberPlayModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import numberPlay from '../../numberPlay.js';
import CountingPlayArea from '../../../../number-suite-common/js/common/model/CountingPlayArea.js';
import CountingArea from '../../../../number-suite-common/js/common/model/CountingArea.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js';
import GroupAndLinkType from '../../../../number-suite-common/js/common/model/GroupAndLinkType.js';
Expand All @@ -31,23 +31,23 @@ class NumberPlayModel implements TModel {
// the current "counted to" number, which is the central aspect of this whole sim
public readonly currentNumberProperty: Property<number>;

// the model for managing the play area in the OnesAccordionBox
public readonly onesPlayArea: CountingPlayArea;
// the model for managing the countingArea in the OnesAccordionBox
public readonly onesCountingArea: CountingArea;

// the model for managing the play area in the ObjectsAccordionBox
public readonly objectsPlayArea: CountingPlayArea;
// the model for managing the countingArea in the ObjectsAccordionBox
public readonly objectsCountingArea: CountingArea;

// the type of objects in the objects play area. primarily used in the view.
// the type of objects in the objectsCountingArea. primarily used in the view.
public readonly countingObjectTypeProperty: EnumerationProperty<CountingObjectType>;

// whether the objectsPlayArea is ungrouped, grouped, or linked. set by the view controls and used to link/unlink
// onesPlayArea and objectsPlayArea, and grouped/ungroup objects in the objectsPlayArea
// whether the objectsCountingArea is ungrouped, grouped, or linked. set by the view controls and used to link/unlink
// onesCountingArea and objectsCountingArea, and grouped/ungroup objects in the objectsCountingArea
public readonly objectsGroupAndLinkTypeProperty: EnumerationProperty<GroupAndLinkType>;

// emits when the objectsPlayArea becomes linked or unlinked to the onesPlayArea
// emits when the objectsCountingArea becomes linked or unlinked to the onesCountingArea
public readonly linkStatusChangedEmitter: TEmitter<[ boolean ]>;

// true when the sim is being reset. this is used so that playAreas don't return things to their creatorNodes the normal
// true when the sim is being reset. this is used so that countingAreas don't return things to their creatorNodes the normal
// way (with animations), but instead with a different reset case (no animations).
private readonly isResettingProperty: TProperty<boolean>;

Expand All @@ -70,9 +70,9 @@ class NumberPlayModel implements TModel {
return ( groupAndLinkType === GroupAndLinkType.GROUPED || groupAndLinkType === GroupAndLinkType.GROUPED_AND_LINKED );
} );

this.onesPlayArea = new CountingPlayArea( highestCount, new BooleanProperty( true ), 'countingPlayArea' );
this.onesCountingArea = new CountingArea( highestCount, new BooleanProperty( true ), 'countingArea' );

this.objectsPlayArea = new CountingPlayArea( highestCount, this.groupingEnabledProperty, 'objectsPlayArea' );
this.objectsCountingArea = new CountingArea( highestCount, this.groupingEnabledProperty, 'objectsCountingArea' );

let onesLeading = false;
let objectsLeading = false;
Expand All @@ -84,45 +84,45 @@ class NumberPlayModel implements TModel {
speechDataProperty.value = `${currentNumber}`;
} );

this.onesPlayArea.sumProperty.lazyLink( ( sum, oldSum ) => {
this.onesCountingArea.sumProperty.lazyLink( ( sum, oldSum ) => {
if ( !objectsLeading ) {
assert && assert( !onesLeading, 'onesLeading already true, reentrant detected' );
onesLeading = true;

this.currentNumberProperty.value = sum;
// console.log( 'countingPlayArea set to ' + sum + ', matching objectsPlayArea' );
this.matchPlayAreaToNewValue( sum, oldSum, this.objectsPlayArea );
// console.log( 'countingArea set to ' + sum + ', matching objectsCountingArea' );
this.matchCountingAreaToNewValue( sum, oldSum, this.objectsCountingArea );

onesLeading = false;
}
} );

this.objectsPlayArea.sumProperty.lazyLink( ( sum, oldSum ) => {
this.objectsCountingArea.sumProperty.lazyLink( ( sum, oldSum ) => {
if ( !onesLeading ) {
assert && assert( !objectsLeading, 'objectsLeading already true, reentrant detected' );
objectsLeading = true;

this.currentNumberProperty.value = sum;

// console.log( 'objectsPlayArea set to ' + sum + ', matching countingPlayArea' );
this.matchPlayAreaToNewValue( sum, oldSum, this.onesPlayArea );
// console.log( 'objectsCountingArea set to ' + sum + ', matching countingArea' );
this.matchCountingAreaToNewValue( sum, oldSum, this.onesCountingArea );

objectsLeading = false;
}
} );
}

private matchPlayAreaToNewValue( newValue: number, oldValue: number, playArea: CountingPlayArea ): void {
private matchCountingAreaToNewValue( newValue: number, oldValue: number, countingArea: CountingArea ): void {
const difference = newValue - oldValue;

// console.log( `matching ${playArea.name}: oldValue: ${oldValue}, newValue: ${newValue}` );
// console.log( `matching ${countingArea.name}: oldValue: ${oldValue}, newValue: ${newValue}` );
if ( difference > 0 ) {
assert && assert( difference === 1, 'A play area should not need to create more than one counting object' +
'at a time to match the opposite play area: ' + difference );
playArea.createCountingObjectFromCreatorNode();
assert && assert( difference === 1, 'A countingArea should not need to create more than one counting object' +
'at a time to match the opposite countingArea: ' + difference );
countingArea.createCountingObjectFromCreatorNode();
}
else {
playArea.returnCountingObjectToCreatorNode( Math.abs( difference ) );
countingArea.returnCountingObjectToCreatorNode( Math.abs( difference ) );
}
}

Expand All @@ -134,8 +134,8 @@ class NumberPlayModel implements TModel {
numberPlayPreferences.isPrimaryLocaleProperty.reset();
this.countingObjectTypeProperty.reset();
this.objectsGroupAndLinkTypeProperty.reset();
this.onesPlayArea.reset();
this.objectsPlayArea.reset();
this.onesCountingArea.reset();
this.objectsCountingArea.reset();
this.isResettingProperty.value = false;
}

Expand Down
20 changes: 10 additions & 10 deletions js/common/view/NumberPlayScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NumberPlayScreenView extends ScreenView {

// create and add the TotalAccordionBox
const totalAccordionBox = new TotalAccordionBox(
model.onesPlayArea,
model.onesCountingArea,
options.upperAccordionBoxHeight,
optionize<TotalAccordionBoxOptions, EmptySelfOptions, NumberSuiteCommonAccordionBoxOptions>()( {
expandedProperty: this.totalAccordionBoxExpandedProperty
Expand All @@ -112,7 +112,7 @@ class NumberPlayScreenView extends ScreenView {

// create and add the CountingAccordionBox for paper ones
const onesAccordionBox = new CountingAccordionBox(
model.onesPlayArea,
model.onesCountingArea,
new EnumerationProperty( CountingObjectType.PAPER_NUMBER ),
NumberPlayConstants.LOWER_ACCORDION_BOX_CONTENT_WIDTH,
options.lowerAccordionBoxHeight, {
Expand Down Expand Up @@ -142,14 +142,14 @@ class NumberPlayScreenView extends ScreenView {

// create and add the CountingAccordionBox for countingObjects
this.objectsAccordionBox = new CountingAccordionBox(
model.objectsPlayArea,
model.objectsCountingArea,
model.countingObjectTypeProperty,
NumberPlayConstants.LOWER_ACCORDION_BOX_CONTENT_WIDTH,
options.lowerAccordionBoxHeight, {
countingObjectTypes: [ CountingObjectType.DOG, CountingObjectType.APPLE, CountingObjectType.BUTTERFLY,
CountingObjectType.BALL ],
linkStatusChangedEmitter: model.linkStatusChangedEmitter,
linkedPlayArea: model.onesPlayArea,
linkedCountingArea: model.onesCountingArea,
expandedProperty: this.objectsAccordionBoxExpandedProperty,
fill: NumberPlayColors.blueBackgroundColorProperty
} );
Expand Down Expand Up @@ -210,7 +210,7 @@ class NumberPlayScreenView extends ScreenView {

// create and add a button to organize the onesAccordionBox paper ones in a grid
const organizeOnesButton = new OrganizeButton( NumberPlayColors.pinkBackgroundColorProperty, () => {
model.onesPlayArea.organizeObjects();
model.onesCountingArea.organizeObjects();
} );
organizeOnesButton.left = NumberSuiteCommonConstants.SCREEN_VIEW_PADDING_X;
organizeOnesButton.top = onesAccordionBox.top;
Expand All @@ -219,10 +219,10 @@ class NumberPlayScreenView extends ScreenView {
// create and add a button to organize the objectsAccordionBox countingObjects in a grid
const organizeObjectsButton = new OrganizeButton( NumberPlayColors.blueBackgroundColorProperty, () => {
if ( model.objectsGroupAndLinkTypeProperty.value === GroupAndLinkType.GROUPED_AND_LINKED ) {
model.onesPlayArea.organizeObjects();
model.onesCountingArea.organizeObjects();
}
else {
model.objectsPlayArea.organizeObjects();
model.objectsCountingArea.organizeObjects();
}
} );
organizeObjectsButton.centerX = resetAllButton.centerX;
Expand All @@ -239,10 +239,10 @@ class NumberPlayScreenView extends ScreenView {
const objectsLinkedToOnes = groupAndLinkType === GroupAndLinkType.GROUPED_AND_LINKED;
const objectsLinkedToOnesPreviously = previousGroupAndLinkType === GroupAndLinkType.GROUPED_AND_LINKED;

// If switching between linked and unlinked, set the objectsPlayArea to the appropriate state.
// If switching between linked and unlinked, set the objectsCountingArea to the appropriate state.
if ( objectsLinkedToOnes !== objectsLinkedToOnesPreviously ) {
model.objectsPlayArea.matchCountingObjectsToLinkedPlayArea(
onesAccordionBox.countingPlayAreaNode.getSerializedCountingObjectsIncludedInSum(),
model.objectsCountingArea.matchCountingObjectsToLinkedCountingArea(
onesAccordionBox.countingAreaNode.getSerializedCountingObjectsIncludedInSum(),
model.linkStatusChangedEmitter,
objectsLinkedToOnes,
groupAndLinkType
Expand Down
8 changes: 4 additions & 4 deletions js/game/model/CountingGameLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Luisa Vargas
*/

import CountingPlayArea from '../../../../number-suite-common/js/common/model/CountingPlayArea.js';
import CountingArea from '../../../../number-suite-common/js/common/model/CountingArea.js';
import numberPlay from '../../numberPlay.js';
import NumberPlayGameLevel from './NumberPlayGameLevel.js';
import CountingObjectType from '../../../../counting-common/js/common/model/CountingObjectType.js';
Expand All @@ -23,7 +23,7 @@ const LEVEL_INPUT_RANGE = 10;

class CountingGameLevel extends NumberPlayGameLevel {

public readonly objectsPlayArea: CountingPlayArea;
public readonly objectsCountingArea: CountingArea;

// the object type of the current challenge
public readonly countingObjectTypeProperty: EnumerationProperty<CountingObjectType>;
Expand All @@ -45,7 +45,7 @@ class CountingGameLevel extends NumberPlayGameLevel {

this.groupObjectsEnabledProperty = new BooleanProperty( this.groupObjectsAllowed );

this.objectsPlayArea = new CountingPlayArea( this.challengeNumberProperty.range.max, this.groupObjectsEnabledProperty, 'objectsPlayArea' );
this.objectsCountingArea = new CountingArea( this.challengeNumberProperty.range.max, this.groupObjectsEnabledProperty, 'objectsCountingArea' );

this.countingObjectTypeProperty = new EnumerationProperty( CountingGameLevel.getRandomCountingObjectType() );

Expand Down Expand Up @@ -77,7 +77,7 @@ class CountingGameLevel extends NumberPlayGameLevel {
}

this.countingObjectTypeProperty.value = CountingGameLevel.getRandomCountingObjectType();
this.objectsPlayArea.createAllObjects( this.challengeNumberProperty.value, this.groupObjectsEnabledProperty.value );
this.objectsCountingArea.createAllObjects( this.challengeNumberProperty.value, this.groupObjectsEnabledProperty.value );
}

/**
Expand Down
Loading

0 comments on commit 4404f84

Please sign in to comment.