From 66a720d1d3da1e3113d9ea40f41552b8d46ae23b Mon Sep 17 00:00:00 2001 From: Luisav1 Date: Sat, 11 Dec 2021 01:00:30 -0700 Subject: [PATCH] Add parentheses for readability and documentation improvements. See https://github.com/phetsims/number-play/issues/75. --- js/game/model/NumberPlayGameLevel.ts | 2 +- js/game/model/NumberPlayGameModel.ts | 2 +- js/game/model/Subitizer.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/game/model/NumberPlayGameLevel.ts b/js/game/model/NumberPlayGameLevel.ts index 12bac875..25bf94bc 100644 --- a/js/game/model/NumberPlayGameLevel.ts +++ b/js/game/model/NumberPlayGameLevel.ts @@ -90,7 +90,7 @@ abstract class NumberPlayGameLevel { this.oldChallengeNumberOne = this.challengeNumberProperty.value; let newChallengeNumber = this.getRandomChallengeNumber(); - while ( newChallengeNumber === this.oldChallengeNumberOne && newChallengeNumber === this.oldChallengeNumberTwo ) { + while ( ( newChallengeNumber === this.oldChallengeNumberOne ) && ( newChallengeNumber === this.oldChallengeNumberTwo ) ) { newChallengeNumber = this.getRandomChallengeNumber(); } this.challengeNumberProperty.value = newChallengeNumber; diff --git a/js/game/model/NumberPlayGameModel.ts b/js/game/model/NumberPlayGameModel.ts index 4757d864..8ac4fbb8 100644 --- a/js/game/model/NumberPlayGameModel.ts +++ b/js/game/model/NumberPlayGameModel.ts @@ -32,7 +32,7 @@ class NumberPlayGameModel { this.subitizeLevels = gameBLevelNumbers.map( gameBLevelNumber => new SubitizeGameLevel( gameBLevelNumber ) ); this.levels = [ ...this.countingLevels, ...this.subitizeLevels ]; - // the selected game level - null means 'no selection' and causes the view to return to the level-selection UI + // the selected game level - null means 'no selection' so that the view returns to the level-selection UI this.levelProperty = new Property( null, { validValues: [ null, ...this.levels ] } ); diff --git a/js/game/model/Subitizer.ts b/js/game/model/Subitizer.ts index 4eb699e0..c25040a2 100644 --- a/js/game/model/Subitizer.ts +++ b/js/game/model/Subitizer.ts @@ -280,7 +280,7 @@ class Subitizer { const challengeNumber = this.challengeNumberProperty.value; let points; - if ( this.randomOrPredetermined && dotRandom.nextDouble() <= PROBABILITY_OF_PREDETERMINED_SHAPE ) { + if ( this.randomOrPredetermined && ( dotRandom.nextDouble() <= PROBABILITY_OF_PREDETERMINED_SHAPE ) ) { points = Subitizer.getPredeterminedShapePoints( challengeNumber ); } else if ( this.randomOrPredetermined ) { @@ -339,7 +339,7 @@ class Subitizer { // add a new point if it doesn't exist yet and does not overlap with the existing points const objectsOverlap = Subitizer.objectsOverlap( points, randomX, randomY ); - if ( !_.find( points, object => object.x === randomX && object.y === randomY ) && !objectsOverlap ) { + if ( !_.find( points, object => ( object.x === randomX ) && ( object.y === randomY ) ) && !objectsOverlap ) { points.push( new Vector2( randomX, randomY ) ); } }