Skip to content

Commit

Permalink
fix: add blk as argument to getValue and _GetDict
Browse files Browse the repository at this point in the history
  • Loading branch information
meganindya committed Feb 9, 2021
1 parent e88efc7 commit 3e08cbc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions js/blocks/DictBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function setupDictBlocks() {
const a = logo.parseArg(logo, turtle, cblk1, blk, receivedArg);
const k = logo.parseArg(logo, turtle, cblk2, blk, receivedArg);

return Turtle.DictActions.getValue(a, k, turtle);
return Turtle.DictActions.getValue(a, k, turtle, blk);
}
}

Expand Down Expand Up @@ -166,7 +166,7 @@ function setupDictBlocks() {
const a = turtles.ithTurtle(turtle).name;
const k = logo.parseArg(logo, turtle, cblk1, blk, receivedArg);

return Turtle.DictActions.getValue(a, k, turtle);
return Turtle.DictActions.getValue(a, k, turtle, blk);
}
}

Expand Down
32 changes: 18 additions & 14 deletions js/turtleactions/DictActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,28 @@
* Action methods are in camelCase.
*/

/* global _,Turtle,turtles,Singer,getNote,logo,INVALIDPITCH,blk,pitchToNumber,getTargetTurtle */
/*
Global Locations
js/utils/utils.js
/* global _, Turtle, turtles, Singer, getNote, logo, INVALIDPITCH, pitchToNumber, getTargetTurtle */

/*
Global Locations
js/utils/utils.js
_
js/turtle.js
js/turtle.js
Turtle
js/activity.js
js/activity.js
turtles
js/turtle-singer.js
js/turtle-singer.js
Singer
js/utils/musicutils.js
js/utils/musicutils.js
getNote, pitchToNumber
js/activity.js
js/activity.js
logo
js/logo.js
js/logo.js
INVALIDPITCH
js/blocks/EnsembleBlocks.js
js/blocks/EnsembleBlocks.js
getTargetTurtle
*/

/* exported setupDictActions */

/**
Expand All @@ -54,9 +56,10 @@ function setupDictActions() {
* @param {Number} target - target Turtle index in turtle.turtleList
* @param {Number} turtle - Turtle index in turtle.turtleList
* @param {String} key - key
* @param {Number?} blk - block index in blocks.blockList
* @returns {String|Number}
*/
static _GetDict(target, turtle, key) {
static _GetDict(target, turtle, key, blk) {
const targetTur = turtles.ithTurtle(target);

// This is the internal turtle dictionary that includes the turtle status.
Expand Down Expand Up @@ -262,15 +265,16 @@ function setupDictActions() {
* @param {String|Number} dict - dictionary name
* @param {String|Number} key
* @param {Number} turtle - Turtle index in turtles.turtleList
* @param {Number?} blk - block index in blocks.blockList
* @returns {String|Number}
*/
static getValue(dict, key, turtle) {
static getValue(dict, key, turtle, blk) {
// Not sure this can happen.
if (!(turtle in logo.turtleDicts)) return 0;
// Is the dictionary the same as a turtle name?
const target = getTargetTurtle(turtles, dict);
if (target !== null) {
return Turtle.DictActions._GetDict(target, turtle, key);
return Turtle.DictActions._GetDict(target, turtle, key, blk);
} else if (!(dict in logo.turtleDicts[turtle])) {
return 0;
}
Expand Down

0 comments on commit 3e08cbc

Please sign in to comment.