| 1006 | } |
| 1007 | |
| 1008 | function 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 | |
| 1035 | const significantSpriteNames = ['Chicken Junior', 'Crab Monster Junior', 'Crates Junior', 'Gelatinous Cube Junior', 'Explosive Junior', 'Dragonfly Monster Junior', 'Gem Junior', 'Goal Junior'] |
| 1036 | const hittableSpriteNames = _.without(significantSpriteNames, 'Gem Junior', 'Goal Junior') // Is chicken hittable or zappable? |