mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-25 00:28:31 -05:00
31 lines
902 B
CoffeeScript
31 lines
902 B
CoffeeScript
|
module.exports = class HintsState extends Backbone.Model
|
||
|
|
||
|
initialize: (attributes, options) ->
|
||
|
{ @level, @session } = options
|
||
|
@listenTo(@level, 'change:documentation', @update)
|
||
|
@update()
|
||
|
|
||
|
getHint: (index) ->
|
||
|
@get('hints')?[index]
|
||
|
|
||
|
update: ->
|
||
|
hints = switch me.getHintsGroup()
|
||
|
when 'hints' then @level.get('documentation')?.hints or []
|
||
|
when 'hintsB' then @level.get('documentation')?.hintsB or []
|
||
|
else []
|
||
|
haveIntro = false
|
||
|
haveOverview = false
|
||
|
for article in @level.get('documentation')?.specificArticles ? []
|
||
|
if not haveIntro and article.name is 'Intro'
|
||
|
hints.unshift(article)
|
||
|
haveIntro = true
|
||
|
if not haveOverview and article.name is 'Overview'
|
||
|
hints.push(article)
|
||
|
haveOverview = true
|
||
|
break if haveIntro and haveOverview
|
||
|
total = _.size(hints)
|
||
|
@set({
|
||
|
hints: hints
|
||
|
total
|
||
|
})
|