-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.rb
56 lines (47 loc) · 1.16 KB
/
user.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'thread'
class Queue
def to_yaml_properties
[]
end
end
class User < BasicLook
attr_accessor :queue
def initialize names, desc, parent
super names, desc, parent
@queue = Queue.new
end
def rebuild user=nil
super user
@queue = Queue.new
end
def whisper! user, *message
@queue << user.names(self)[0].to_s + " : " + message.map {|e| e.to_s }.join(" ") if user != self
""
end
def names user
user == self ? [:pocket,:pockets] : super(user)
end
def visible? user
user != self
end
def description! user
user == self ? nil : super(user)
end
def look! user,*args
if user == self or user.parent == self
contents = super(user,*args)
if args.any?
contents
else
[user.parent == self ? "It's quite dark in here" : "In your pockets you have", contents[1].flatten.compact.any? ? contents[1] : ["Nothing"]]
end
elsif args == []
description!(user)
else
nil
end
end
def inspect
"<#{self.class} #{@names[0].to_s} in #{@parent.instance_variable_get(:@names)[0].to_s} : #{@things.map {|e| e.instance_variable_get(:@names)[0].to_s } }>"
end
end