mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-23 19:32:03 -04:00
Made while True snippets work in course levels
This commit is contained in:
parent
42b53dff20
commit
f6307ac04e
1 changed files with 19 additions and 4 deletions
|
@ -429,6 +429,7 @@ module.exports = class SpellView extends CocoView
|
||||||
return true if doc.owner is owner
|
return true if doc.owner is owner
|
||||||
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
||||||
if doc?.snippets?[e.language]
|
if doc?.snippets?[e.language]
|
||||||
|
name = doc.name
|
||||||
content = doc.snippets[e.language].code
|
content = doc.snippets[e.language].code
|
||||||
if /loop/.test(content) and @options.level.get 'moveRightLoopSnippet'
|
if /loop/.test(content) and @options.level.get 'moveRightLoopSnippet'
|
||||||
# Replace default loop snippet with an embedded moveRight()
|
# Replace default loop snippet with an embedded moveRight()
|
||||||
|
@ -436,15 +437,29 @@ module.exports = class SpellView extends CocoView
|
||||||
when 'python' then 'loop:\n self.moveRight()\n ${1:}'
|
when 'python' then 'loop:\n self.moveRight()\n ${1:}'
|
||||||
when 'javascript' then 'loop {\n this.moveRight();\n ${1:}\n}'
|
when 'javascript' then 'loop {\n this.moveRight();\n ${1:}\n}'
|
||||||
else content
|
else content
|
||||||
|
if /loop/.test(content) and @options.level.get('type') in ['course', 'course-ladder']
|
||||||
|
# Temporary hackery to make it look like we meant while True: in our loop snippets until we can update everything
|
||||||
|
content = switch e.language
|
||||||
|
when 'python' then content.replace /loop:/, 'while True:'
|
||||||
|
when 'javascript' then content.replace /loop/, 'while (true)'
|
||||||
|
when 'clojure' then content.replace /dotimes \[n 1000\]/, '(while true'
|
||||||
|
when 'lua' then content.replace /loop/, 'while true then'
|
||||||
|
when 'coffeescript' then content
|
||||||
|
when 'io' then content.replace /loop/, 'while true,'
|
||||||
|
else content
|
||||||
|
name = switch e.language
|
||||||
|
when 'python' then 'while True'
|
||||||
|
when 'coffeescript' then 'loop'
|
||||||
|
else 'while true'
|
||||||
entry =
|
entry =
|
||||||
content: content
|
content: content
|
||||||
meta: $.i18n.t('keyboard_shortcuts.press_enter', defaultValue: 'press enter')
|
meta: $.i18n.t('keyboard_shortcuts.press_enter', defaultValue: 'press enter')
|
||||||
name: doc.name
|
name: name
|
||||||
tabTrigger: doc.snippets[e.language].tab
|
tabTrigger: doc.snippets[e.language].tab
|
||||||
importance: doc.autoCompletePriority ? 1.0
|
importance: doc.autoCompletePriority ? 1.0
|
||||||
haveFindNearestEnemy ||= doc.name is 'findNearestEnemy'
|
haveFindNearestEnemy ||= name is 'findNearestEnemy'
|
||||||
haveFindNearest ||= doc.name is 'findNearest'
|
haveFindNearest ||= name is 'findNearest'
|
||||||
if doc.name is 'attack'
|
if name is 'attack'
|
||||||
# Postpone this until we know if findNearestEnemy is available
|
# Postpone this until we know if findNearestEnemy is available
|
||||||
attackEntry = entry
|
attackEntry = entry
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue