75 lines
1.3 KiB
Ruby
75 lines
1.3 KiB
Ruby
class Folder
|
|
def initialize()
|
|
@steves = []
|
|
@fallen = []
|
|
@submissions = []
|
|
@idgen = 1
|
|
end
|
|
|
|
def add_steve(uid)
|
|
@steves.append(uid)
|
|
end
|
|
|
|
def curse(user)
|
|
if @steves.include?(user.id)
|
|
@steves.delete(user.id)
|
|
@fallen.append(user.id)
|
|
end
|
|
end
|
|
|
|
def bless(user)
|
|
if @fallen.include?(user.id)
|
|
@steves.append(user.id)
|
|
@fallen.delete(user.id)
|
|
end
|
|
end
|
|
|
|
def steve?(user)
|
|
return (@steves.include?(user) or @fallen.include?(user))
|
|
end
|
|
|
|
def submit(sub)
|
|
sub.set_id(@idgen)
|
|
@submissions.append(sub)
|
|
@idgen = @idgen + 1
|
|
end
|
|
|
|
def harass_steve()
|
|
if @steves.length <= 0
|
|
return nil
|
|
end
|
|
target = @steves.sample
|
|
if @submissions.length <= 0
|
|
return nil
|
|
end
|
|
message = @submissions.sample
|
|
i = 0
|
|
until message.sender != target or i == 5 do
|
|
message = @submissions.sample
|
|
i = i + 1
|
|
end
|
|
if i == 5
|
|
return nil
|
|
end
|
|
@submissions.delete(message)
|
|
if message.local and not File.exist?(message.content)
|
|
return nil
|
|
end
|
|
return target,message
|
|
end
|
|
end
|
|
|
|
|
|
class Submission
|
|
def initialize(content,local,sender)
|
|
@local = local
|
|
@content = content
|
|
@sender = sender
|
|
end
|
|
def set_id(i)
|
|
@id = i
|
|
end
|
|
attr_reader :local,:content,:sender,:id
|
|
end
|
|
|