class Context
constructor: ->
@roles = {}
@interactions = {}
add_interaction: (intrxn) ->
@interactions[intrxn.name] = intrxn
class Role
constructor: (@name, @type) ->
class PlayerAsRole
constructor: (@player, @role_interface) ->
class RoleBinding
constructor: (@role, @player) ->
class Interaction
constructor: (@name, roles, args, @function_body) ->
@roles = []
@bound_roles = []
@args = []
@bound_args = []
for role in roles
@add_role(role)
for arg in args
@add_arg(arg)
add_role: (role) ->
@roles.push(role)
bind: (role, player) ->
@bound_roles.push(new RoleBinding(role, player))
execute: ->
if @roles.length isnt @bound_roles.length
throw new Error("not all roles are bound")
if @args.length isnt @bound_args.length
throw new Error("not all args are bound")
return @function_body()
(exports ? this).Context = Context
(exports ? this).Role = Role
(exports ? this).Interaction = Interaction