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

Function actionToCode

app/lib/level-generation.js:1008–1033  ·  view source on GitHub ↗
(action)

Source from the content-addressed store, hash-verified

1006}
1007
1008function actionToCode (action) {
1009 // This could be a method of Action class
1010 let line
1011 if (action.type === 'go' && action.distance) {
1012 line = `${action.type}('${action.direction.name}', ${action.distance})`
1013 } else if (action.type === 'go') {
1014 line = `${action.type}('${action.direction.name}')`
1015 } else if (action.type === 'look') {
1016 // TODO: returns value
1017 line = `${action.type}('${action.direction.name}', ${action.distance})`
1018 } else if (action.type === 'hit') {
1019 line = `${action.type}('${action.direction.name}')`
1020 } else if (action.type === 'zap') {
1021 line = `${action.type}('${action.direction.name}')`
1022 } else if (action.type === 'spin') {
1023 line = `${action.type}()`
1024 } else if (action.type === 'for') {
1025 line = `for (let ${action.loopVariable} = 0; ${action.loopVariable} < ${action.loopCount}; ++${action.loopVariable}) {`
1026 } else if (action.type === '}') {
1027 line = '}'
1028 }
1029 if (action.invalid) {
1030 line += ' // invalid'
1031 }
1032 return line
1033}
1034
1035const significantSpriteNames = ['Chicken Junior', 'Crab Monster Junior', 'Crates Junior', 'Gelatinous Cube Junior', 'Explosive Junior', 'Dragonfly Monster Junior', 'Gem Junior', 'Goal Junior']
1036const hittableSpriteNames = _.without(significantSpriteNames, 'Gem Junior', 'Goal Junior') // Is chicken hittable or zappable?

Callers 1

compileActionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected