mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-04 21:01:06 -05:00
30 lines
921 B
CoffeeScript
30 lines
921 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 _.cloneDeep(@level.get('documentation')?.hints or [])
|
|
when 'hintsB' then _.cloneDeep(@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
|
|
total
|
|
})
|