mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Inferring and documenting cooldown, action/spell name, damage, range, radius, and duration when possible.
This commit is contained in:
parent
b301ab1c3b
commit
a7905db316
2 changed files with 57 additions and 2 deletions
|
@ -8,7 +8,43 @@ h4
|
|||
else
|
||||
| (read-only)
|
||||
|
||||
.description!= marked(doc.description || 'Still undocumented, sorry.')
|
||||
.description
|
||||
p!= marked(doc.description || 'Still undocumented, sorry.')
|
||||
if cooldowns && (cooldowns.cooldown || cooldowns.specificCooldown)
|
||||
p
|
||||
span
|
||||
| #{cooldowns.type == 'spell' ? 'Spell' : 'Action'} name:
|
||||
code "#{cooldowns.name}"
|
||||
| .
|
||||
span.spl
|
||||
| Cooldown:
|
||||
code= cooldowns.cooldown
|
||||
| s.
|
||||
if cooldowns.specificCooldown
|
||||
span.spl
|
||||
| Specific cooldown:
|
||||
code= cooldowns.specificCooldown
|
||||
| s.
|
||||
if cooldowns.damage
|
||||
span.spl
|
||||
| Damage:
|
||||
code= cooldowns.damage
|
||||
| .
|
||||
if cooldowns.range
|
||||
span.spl
|
||||
| Range:
|
||||
code= cooldowns.range
|
||||
| m.
|
||||
if cooldowns.radius
|
||||
span.spl
|
||||
| Radius:
|
||||
code= cooldowns.radius
|
||||
| m.
|
||||
if cooldowns.duration
|
||||
span.spl
|
||||
| Duration:
|
||||
code= cooldowns.duration
|
||||
| s.
|
||||
|
||||
if !selectedMethod
|
||||
if doc.example
|
||||
|
|
|
@ -93,7 +93,7 @@ module.exports = class DocFormatter
|
|||
obj[prop] = null
|
||||
|
||||
formatPopover: ->
|
||||
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod
|
||||
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns()
|
||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||
content = content.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName # Prefer type, and excluded the quotes we'd get with @formatValue
|
||||
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||
|
@ -122,3 +122,22 @@ module.exports = class DocFormatter
|
|||
if _.isPlainObject v
|
||||
return safeJSONStringify v, 2
|
||||
v
|
||||
|
||||
inferCooldowns: ->
|
||||
return null unless @doc.type is 'function' and @doc.owner is 'this'
|
||||
owner = @options.thang
|
||||
cooldowns = null
|
||||
spellName = @doc.name.match /^cast(.+)$/
|
||||
if spellName
|
||||
actionName = _.string.slugify _.string.underscored spellName[1]
|
||||
action = owner.spells?[actionName]
|
||||
type = 'spell'
|
||||
else
|
||||
actionName = _.string.slugify _.string.underscored @doc.name
|
||||
action = owner.actions?[actionName]
|
||||
type = 'action'
|
||||
return null unless action
|
||||
cooldowns = cooldown: action.cooldown, specificCooldown: action.specificCooldown, name: actionName, type: type
|
||||
for prop in ['range', 'radius', 'duration', 'damage']
|
||||
cooldowns[prop] = owner[_.string.camelize actionName + _.string.capitalize(prop)]
|
||||
cooldowns
|
||||
|
|
Loading…
Reference in a new issue