MCPcopy Create free account
hub / github.com/codecombat/codecombat / retrieveProperty

Function retrieveProperty

app/assets/javascripts/workers/worker_world.js:223–282  ·  view source on GitHub ↗
(currentThangID, currentSpellID, variableChain)

Source from the content-addressed store, hash-verified

221self.retrieveValueFromFrame = function retrieveValueFromFrame(args) {
222
223 var retrieveProperty = function retrieveProperty(currentThangID, currentSpellID, variableChain)
224 {
225 var prop;
226 var value;
227 var keys = [];
228 for (var i = 0, len = variableChain.length; i < len; i++) {
229 prop = variableChain[i];
230 if (prop === "this")
231 {
232 value = self.debugWorld.thangMap[currentThangID];
233
234 }
235 else if (i === 0)
236 {
237 try
238 {
239 if (Aether.globals[prop])
240 {
241 value = Aether.globals[prop];
242 }
243 else
244 {
245 var flowStates = self.debugWorld.userCodeMap[currentThangID][currentSpellID].flow.states;
246 //we have to go to the second last flowState as we run the world for one additional frame
247 //to collect the flow
248 value = _.last(flowStates[flowStates.length - 1].statements).variables[prop];
249 }
250 }
251 catch (e)
252 {
253 value = undefined;
254 }
255
256 }
257 else
258 {
259 value = value[prop];
260 }
261 keys.push(prop);
262 if (!value) break;
263 var classOfValue;
264 if (classOfValue = serializedClasses[value.CN])
265 {
266 if (value.CN === "Thang")
267 {
268 var thang = self.debugWorld.thangMap[value.id];
269 value = thang || "<Thang " + value.id + " (non-existent)>";
270 }
271 else
272 {
273 value = classOfValue.deserializeFromAether(value);
274 }
275 }
276 }
277 var serializedProperty = {
278 "key": keys.join("."),
279 "value": self.stringifyValue(value,0)
280 };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected