1
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet.git synced 2024-07-07 01:04:25 +03:00
salet/lib/character.coffee

28 lines
554 B
CoffeeScript
Raw Normal View History

2016-02-10 15:35:44 +02:00
class Character
constructor: (spec) ->
@inventory = []
@take = (thing) =>
@inventory.push thing
@drop = (thing) =>
for i in @inventory
if i.name == thing
index = @objects.indexOf(thing)
@inventory.splice(index, 1)
2016-03-20 14:41:47 +02:00
@has = (thing) =>
for i in @inventory
if i.name == thing
return true
return false
2016-02-10 15:35:44 +02:00
for index, value of spec
this[index] = value
return this
character = (spec) ->
spec ?= {}
return( new Character(spec) )
module.exports = character