mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 18:15:52 -05:00
26 lines
699 B
CoffeeScript
26 lines
699 B
CoffeeScript
|
CocoModel = require('./CocoModel')
|
||
|
|
||
|
module.exports = class LevelSession extends CocoModel
|
||
|
@className: "LevelSession"
|
||
|
urlRoot: "/db/level.session"
|
||
|
|
||
|
initialize: ->
|
||
|
super()
|
||
|
@on 'sync', (e) =>
|
||
|
state = @get('state') or {}
|
||
|
state.scripts ?= {}
|
||
|
@set('state', state)
|
||
|
|
||
|
updatePermissions: ->
|
||
|
permissions = @get 'permissions'
|
||
|
permissions = (p for p in permissions when p.target isnt 'public')
|
||
|
if @get('multiplayer')
|
||
|
permissions.push {target:'public', access:'write'}
|
||
|
@set 'permissions', permissions
|
||
|
|
||
|
getSourceFor: (spellKey) ->
|
||
|
# spellKey ex: 'tharin/plan'
|
||
|
code = @get('code')
|
||
|
parts = spellKey.split '/'
|
||
|
code?[parts[0]]?[parts[1]]
|