-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathprettybounty.lic
More file actions
51 lines (47 loc) · 1.78 KB
/
prettybounty.lic
File metadata and controls
51 lines (47 loc) · 1.78 KB
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
=begin
This script formats the output of the bounty verb, and keeps track of
how many tasks have been completed recently, and how many bounty points
have been gained recently.
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
tags: cosmetic
version: 0.1
=end
start_time = Time.now
counter = Hash.new
counter['start'] = Hash.new
counter['now'] = Hash.new
action = proc { |server_string|
if server_string =~ /^You have succeeded at the (.*?) task ([0-9]+) times?( and failed [0-9]+ times?)?\./
task = $1
counter['start'][task] ||= $2.to_i
counter['now'][task] = $2.to_i
fail = $3.slice(/[0-9]+/)
if counter['now'][task] == 1
total_str = "#{counter['now'][task].to_s.rjust(5)} time total "
else
total_str = "#{counter['now'][task].to_s.rjust(5)} times total"
end
recent_count = counter['now'][task] - counter['start'][task]
if recent_count < 1
recent_str = " "
elsif recent_count == 1
recent_str = "#{recent_count.to_s.rjust(3)} time recently "
else
recent_str = "#{recent_count.to_s.rjust(3)} times recently"
end
if fail
fail_str = "#{fail.to_s.rjust(3)} failures"
else
fail_str = ""
end
server_string = "You have succeeded at the #{task.dup.concat(' task:').ljust(29)} #{total_str} #{recent_str} #{fail_str}\r\n"
elsif server_string =~ /^You have accumulated a total of ([0-9]+) lifetime bounty points\./
counter['start']['points'] ||= $1.to_i
counter['now']['points'] = $1.to_i
server_string = "You have accumulated #{counter['now']['points'] - counter['start']['points']} bounty points recently (#{((counter['now']['points'] - counter['start']['points'])/((Time.now - start_time)/3600.0)).to_i} pts/hr), #{counter['now']['points']} total.\r\n"
else
server_string
end
}
DownstreamHook.add('prettybounty', action)