Skip to content

Commit

Permalink
move MOLECULE_NODE_CONSTRUCTORS to RPALRewardFactory, #80
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Feb 24, 2023
1 parent fafd98f commit 9e870f1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
12 changes: 0 additions & 12 deletions js/common/model/ReactionFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ const MOLECULE_NODE_OPTIONS = RPALConstants.MOLECULE_NODE_OPTIONS; // to improve

const ReactionFactory = {

// {Node} constructors for all atoms & molecules that appear in reactions
moleculeNodeConstructors: [
C2H2Node, C2H4Node, C2H5ClNode, C2H5OHNode, C2H6Node, CH2ONode,
CH3OHNode, CH4Node, Cl2Node, CNode, CO2Node, CONode, CS2Node,
F2Node,
H2Node, H2ONode, H2SNode, HClNode, HFNode,
N2Node, N2ONode, NH3Node, NO2Node, NONode,
O2Node, OF2Node,
P4Node, PCl3Node, PCl5Node, PF3Node, PH3Node,
SNode, SO2Node, SO3Node
],

//---------------------------------------------------------------------------------------
// Single-product reactions
//---------------------------------------------------------------------------------------
Expand Down
49 changes: 47 additions & 2 deletions js/game/view/RPALRewardNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,61 @@
* @author Chris Malley (PixelZoom, Inc.)
*/

import C2H2Node from '../../../../nitroglycerin/js/nodes/C2H2Node.js';
import C2H4Node from '../../../../nitroglycerin/js/nodes/C2H4Node.js';
import C2H5ClNode from '../../../../nitroglycerin/js/nodes/C2H5ClNode.js';
import C2H5OHNode from '../../../../nitroglycerin/js/nodes/C2H5OHNode.js';
import C2H6Node from '../../../../nitroglycerin/js/nodes/C2H6Node.js';
import CH2ONode from '../../../../nitroglycerin/js/nodes/CH2ONode.js';
import CH3OHNode from '../../../../nitroglycerin/js/nodes/CH3OHNode.js';
import CH4Node from '../../../../nitroglycerin/js/nodes/CH4Node.js';
import Cl2Node from '../../../../nitroglycerin/js/nodes/Cl2Node.js';
import CNode from '../../../../nitroglycerin/js/nodes/CNode.js';
import CO2Node from '../../../../nitroglycerin/js/nodes/CO2Node.js';
import CONode from '../../../../nitroglycerin/js/nodes/CONode.js';
import CS2Node from '../../../../nitroglycerin/js/nodes/CS2Node.js';
import F2Node from '../../../../nitroglycerin/js/nodes/F2Node.js';
import H2Node from '../../../../nitroglycerin/js/nodes/H2Node.js';
import H2ONode from '../../../../nitroglycerin/js/nodes/H2ONode.js';
import H2SNode from '../../../../nitroglycerin/js/nodes/H2SNode.js';
import HClNode from '../../../../nitroglycerin/js/nodes/HClNode.js';
import HFNode from '../../../../nitroglycerin/js/nodes/HFNode.js';
import N2Node from '../../../../nitroglycerin/js/nodes/N2Node.js';
import N2ONode from '../../../../nitroglycerin/js/nodes/N2ONode.js';
import NH3Node from '../../../../nitroglycerin/js/nodes/NH3Node.js';
import NO2Node from '../../../../nitroglycerin/js/nodes/NO2Node.js';
import NONode from '../../../../nitroglycerin/js/nodes/NONode.js';
import O2Node from '../../../../nitroglycerin/js/nodes/O2Node.js';
import OF2Node from '../../../../nitroglycerin/js/nodes/OF2Node.js';
import P4Node from '../../../../nitroglycerin/js/nodes/P4Node.js';
import PCl3Node from '../../../../nitroglycerin/js/nodes/PCl3Node.js';
import PCl5Node from '../../../../nitroglycerin/js/nodes/PCl5Node.js';
import PF3Node from '../../../../nitroglycerin/js/nodes/PF3Node.js';
import PH3Node from '../../../../nitroglycerin/js/nodes/PH3Node.js';
import SNode from '../../../../nitroglycerin/js/nodes/SNode.js';
import SO2Node from '../../../../nitroglycerin/js/nodes/SO2Node.js';
import SO3Node from '../../../../nitroglycerin/js/nodes/SO3Node.js';
import FaceNode from '../../../../scenery-phet/js/FaceNode.js';
import RewardNode from '../../../../vegas/js/RewardNode.js';
import ReactionFactory from '../../common/model/ReactionFactory.js';
import reactantsProductsAndLeftovers from '../../reactantsProductsAndLeftovers.js';
import SandwichNode from '../../sandwiches/view/SandwichNode.js';

// constants
const NUMBER_OF_NODES = 100;
const FACE_COLORS = [ 'yellow', 'rgb(255,85,0)', 'orange', 'magenta', 'cyan', 'rgb(100,255,100)' ];

// constructors for all atoms & molecules that appear in reactions, to appear in Level 1 reward
const MOLECULE_NODE_CONSTRUCTORS = [
C2H2Node, C2H4Node, C2H5ClNode, C2H5OHNode, C2H6Node, CH2ONode,
CH3OHNode, CH4Node, Cl2Node, CNode, CO2Node, CONode, CS2Node,
F2Node,
H2Node, H2ONode, H2SNode, HClNode, HFNode,
N2Node, N2ONode, NH3Node, NO2Node, NONode,
O2Node, OF2Node,
P4Node, PCl3Node, PCl5Node, PF3Node, PH3Node,
SNode, SO2Node, SO3Node
];

export default class RPALRewardNode extends RewardNode {

/**
Expand All @@ -38,7 +83,7 @@ export default class RPALRewardNode extends RewardNode {
// Level 1: molecules, @returns {Node[]}
function createNodesLevel1() {
const nodes = [];
ReactionFactory.moleculeNodeConstructors.forEach( MoleculeNodeConstructor => nodes.push( new MoleculeNodeConstructor() ) );
MOLECULE_NODE_CONSTRUCTORS.forEach( MoleculeNodeConstructor => nodes.push( new MoleculeNodeConstructor() ) );
return RewardNode.createRandomNodes( nodes, NUMBER_OF_NODES );
}

Expand Down

0 comments on commit 9e870f1

Please sign in to comment.