-
Notifications
You must be signed in to change notification settings - Fork 8
/
xp.lic
393 lines (356 loc) · 15.6 KB
/
xp.lic
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#quiet
=begin
This script sends the experience verb to the game and adds info to the results, including
experience and fame gained since first use, first use this login, and last use; average
rate of gain for those time periods, and time until next level/points and arbitrary goal
at those rates.
;xp help
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
version: 0.7
tags: cosmetic
changelog:
0.7 (2020-10-10):
fix for new exp verb output
0.6 (2014-12-12):
fix time since last use
0.5 (2014-12-10):
fix table spacing
0.4 (2014-12-10):
fix typo
0.3 (2014-12-10):
fix bug with ;xp reset
0.2 (2014-12-10):
add realtime tracking
reformat output
=end
if script.vars[1]
if script.vars[1].downcase == 'reset'
$xp = nil
if script.vars[2].downcase == 'all'
CharSettings['realtime'] = nil
end
echo "Experience tracking has been reset."
elsif (script.vars[1].downcase == 'goal') and (script.vars[2] =~ /^[0-9,]+$/)
CharSettings['goal'] = script.vars[2].gsub(',','').to_i
echo "Experience goal set to #{CharSettings['goal']}."
else
output = "\n"
output.concat "usage:\n"
output.concat "\n"
output.concat " #{$clean_lich_char}#{script.name} show experience with extra info\n"
output.concat " #{$clean_lich_char}#{script.name} reset reset experience tracking since login\n"
output.concat " #{$clean_lich_char}#{script.name} reset all reset all experience tracking\n"
output.concat " #{$clean_lich_char}#{script.name} goal <exp> set a goal to show time until\n"
output.concat "\n"
respond output
end
exit
end
CharSettings['goal'] ||= 0
now = Hash.new
xp_until_next = 0
time_since_max_width = Hash.new
time_until_next_max_width = Hash.new
time_until_goal_max_width = Hash.new
add_commas = proc { |num|
num.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
}
calc_seconds = proc { |foo|
seconds = foo % 60
foo = (foo - seconds) / 60
minutes = foo % 60
foo = (foo - minutes) / 60
hours = foo % 24
days = (foo - hours) / 24
[days, hours, minutes, seconds]
}
format_time_since = proc { |foo|
time = calc_seconds.call(foo)
list = Array.new
if time[0] > 0
list.push "#{time[0].to_s.rjust(time_since_max_width['days'])}d"
elsif time_since_max_width['days'] > 0
list.push ''.rjust(time_since_max_width['days'] + 1)
end
if time[1] > 0
list.push "#{time[1].to_s.rjust(time_since_max_width['hours'])}h"
elsif time_since_max_width['hours'] > 0
list.push ''.rjust(time_since_max_width['hours'] + 1)
end
if time[2] > 0
list.push "#{time[2].to_s.rjust(time_since_max_width['minutes'])}m"
elsif time_since_max_width['minutes'] > 0
list.push ''.rjust(time_since_max_width['minutes'] + 1)
end
if time[3] > 0
list.push "#{time[3].to_s.rjust(time_since_max_width['seconds'])}s"
elsif time_since_max_width['seconds'] > 0
list.push ''.rjust(time_since_max_width['seconds'] + 1)
end
list.join(' ')
}
format_time_until_next = proc { |time|
list = Array.new
if time[0] > 0
list.push "#{time[0].to_s.rjust(time_until_next_max_width['days'])}d"
elsif time_until_next_max_width['days'] > 0
list.push ''.rjust(time_until_next_max_width['days'] + 1)
end
if time[1] > 0
list.push "#{time[1].to_s.rjust(time_until_next_max_width['hours'])}h"
elsif time_until_next_max_width['hours'] > 0
list.push ''.rjust(time_until_next_max_width['hours'] + 1)
end
if time[2] > 0
list.push "#{time[2].to_s.rjust(time_until_next_max_width['minutes'])}m"
elsif time_until_next_max_width['minutes'] > 0
list.push ''.rjust(time_until_next_max_width['minutes'] + 1)
end
if time[3] > 0
list.push "#{time[3].to_s.rjust(time_until_next_max_width['seconds'])}s"
elsif time_until_next_max_width['seconds'] > 0
list.push ''.rjust(time_until_next_max_width['seconds'] + 1)
end
list.join(' ')
}
format_time_until_goal = proc { |time|
list = Array.new
if time[0] > 0
list.push "#{time[0].to_s.rjust(time_until_goal_max_width['days'])}d"
elsif time_until_goal_max_width['days'] > 0
list.push ''.rjust(time_until_goal_max_width['days'] + 1)
end
if time[1] > 0
list.push "#{time[1].to_s.rjust(time_until_goal_max_width['hours'])}h"
elsif time_until_goal_max_width['hours'] > 0
list.push ''.rjust(time_until_goal_max_width['hours'] + 1)
end
if time[2] > 0
list.push "#{time[2].to_s.rjust(time_until_goal_max_width['minutes'])}m"
elsif time_until_goal_max_width['minutes'] > 0
list.push ''.rjust(time_until_goal_max_width['minutes'] + 1)
end
if time[3] > 0
list.push "#{time[3].to_s.rjust(time_until_goal_max_width['seconds'])}s"
elsif time_until_goal_max_width['seconds'] > 0
list.push ''.rjust(time_until_goal_max_width['seconds'] + 1)
end
list.join(' ')
}
clear
silence_me
put "experience"
while (line = get)
if line =~ /^\s+Experience: ([0-9,]+)/
now['exp'] = $1.gsub(',','').to_i
elsif line =~ /^\s*Exp (?:until next|to next TP): (\-?[0-9,]+)/
xp_until_next = $1.gsub(',','').to_i
elsif line =~ /^\s+Level: [0-9,]+\s+Fame: ([0-9,]+)/
now['fame'] = $1.gsub(',','').to_i
elsif line =~ /PTPs\/MTPs/
break
end
end
now['time'] = Time.now.to_i
unless $xp
$xp = {}
$xp['first'] = now
$xp['last'] = now
echo 'no information yet'
exit
end
unless CharSettings['realtime']
CharSettings['realtime'] = Hash.new
CharSettings['realtime']['time'] = now['time']
CharSettings['realtime']['exp'] = now['exp']
CharSettings['realtime']['fame'] = now['fame']
end
unless (now['exp'] - $xp['first']['exp']) > 0
echo 'no information yet'
exit
end
secs_since_realtime = Time.now.to_i - CharSettings['realtime']['time']
time_since_realtime = calc_seconds.call(secs_since_realtime)
xp_since_realtime = now['exp'] - CharSettings['realtime']['exp']
xp_since_realtime_avg = (xp_since_realtime * (3600 / secs_since_realtime.to_f)).to_i.round
fame_since_realtime = now['fame'] - CharSettings['realtime']['fame']
fame_since_realtime_avg = (fame_since_realtime * (3600 / secs_since_realtime.to_f)).to_i.round
secs_since_first = now['time'] - $xp['first']['time']
time_since_first = calc_seconds.call(secs_since_first)
xp_since_first = now['exp'] - $xp['first']['exp']
xp_since_first_avg = (xp_since_first * (3600 / secs_since_first.to_f)).to_i.round
fame_since_first = now['fame'] - $xp['first']['fame']
fame_since_first_avg = (fame_since_first * (3600 / secs_since_first.to_f)).to_i.round
secs_since_last = now['time'] - $xp['last']['time']
time_since_last = calc_seconds.call(secs_since_last)
xp_since_last = now['exp'] - $xp['last']['exp']
xp_since_last_avg = (xp_since_last * (3600 / secs_since_last.to_f)).to_i.round
fame_since_last = now['fame'] - $xp['last']['fame']
fame_since_last_avg = (fame_since_last * (3600 / secs_since_last.to_f)).to_i.round
for time in [ time_since_realtime, time_since_first, time_since_last ]
time_since_max_width['days'] = [ time_since_max_width['days'].to_i, (time[0] > 0 ? time[0].to_s.length : 0) ].max
time_since_max_width['hours'] = [ time_since_max_width['hours'].to_i, (time[1] > 0 ? time[1].to_s.length : 0) ].max
time_since_max_width['minutes'] = [ time_since_max_width['minutes'].to_i, (time[2] > 0 ? time[2].to_s.length : 0) ].max
time_since_max_width['seconds'] = [ time_since_max_width['seconds'].to_i, (time[3] > 0 ? time[3].to_s.length : 0) ].max
end
time_since_label_width = [ (time_since_max_width['days'] + time_since_max_width['minutes'] + time_since_max_width['hours'] + time_since_max_width['seconds'] + ([ time_since_max_width['days'], time_since_max_width['minutes'], time_since_max_width['hours'], time_since_max_width['seconds'] ].count { |i| i > 0 } * 2) - 1), 10 ].max
begin
time_until_next_realtime = calc_seconds.call((xp_until_next / (xp_since_realtime / secs_since_realtime.to_f)).to_i)
rescue
time_until_next_realtime = nil
end
begin
time_until_next_first = calc_seconds.call((xp_until_next / (xp_since_first / secs_since_first.to_f)).to_i)
rescue
time_until_next_first = nil
end
begin
time_until_next_last = calc_seconds.call((xp_until_next / (xp_since_last / secs_since_last.to_f)).to_i)
rescue
time_until_next_last = nil
end
for time in [ time_until_next_realtime, time_until_next_first, time_until_next_last ]
time_until_next_max_width['days'] = [ time_until_next_max_width['days'].to_i, (time[0] > 0 ? time[0].to_s.length : 0) ].max
time_until_next_max_width['hours'] = [ time_until_next_max_width['hours'].to_i, (time[1] > 0 ? time[1].to_s.length : 0) ].max
time_until_next_max_width['minutes'] = [ time_until_next_max_width['minutes'].to_i, (time[2] > 0 ? time[2].to_s.length : 0) ].max
time_until_next_max_width['seconds'] = [ time_until_next_max_width['seconds'].to_i, (time[3] > 0 ? time[3].to_s.length : 0) ].max
end
time_until_next_label_width = [ (time_until_next_max_width['days'] + time_until_next_max_width['minutes'] + time_until_next_max_width['hours'] + time_until_next_max_width['seconds'] + ([ time_until_next_max_width['days'], time_until_next_max_width['minutes'], time_until_next_max_width['hours'], time_until_next_max_width['seconds'] ].count { |i| i > 0 } * 2) - 1), 10 ].max
xp_until_goal = CharSettings['goal'] - now['exp']
if xp_until_goal > 0
begin
time_until_goal_realtime = calc_seconds.call((xp_until_goal / (xp_since_realtime / secs_since_realtime.to_f)).to_i)
rescue
time_until_goal_realtime = nil
end
begin
time_until_goal_first = calc_seconds.call((xp_until_goal / (xp_since_first / secs_since_first.to_f)).to_i)
rescue
time_until_goal_first = nil
end
begin
time_until_goal_last = calc_seconds.call((xp_until_goal / (xp_since_last / secs_since_last.to_f)).to_i)
rescue
time_until_goal_last = nil
end
for time in [ time_since_realtime, time_since_first, time_since_last ]
time_until_goal_max_width['days'] = [ time_until_goal_max_width['days'].to_i, (time[0] > 0 ? time[0].to_s.length : 0) ].max
time_until_goal_max_width['hours'] = [ time_until_goal_max_width['hours'].to_i, (time[1] > 0 ? time[1].to_s.length : 0) ].max
time_until_goal_max_width['minutes'] = [ time_until_goal_max_width['minutes'].to_i, (time[2] > 0 ? time[2].to_s.length : 0) ].max
time_until_goal_max_width['seconds'] = [ time_until_goal_max_width['seconds'].to_i, (time[3] > 0 ? time[3].to_s.length : 0) ].max
end
time_until_goal_label_width = [ (time_until_goal_max_width['days'] + time_until_goal_max_width['minutes'] + time_until_goal_max_width['hours'] + time_until_goal_max_width['seconds'] + ([ time_until_goal_max_width['days'], time_until_goal_max_width['minutes'], time_until_goal_max_width['hours'], time_until_goal_max_width['seconds'] ].count { |i| i > 0 } * 2) - 1), 10 ].max
end
exp_width = [ add_commas.call(xp_since_realtime).length, add_commas.call(xp_since_first).length, add_commas.call(xp_since_last).length, 4 ].max
avg_exp_width = [ add_commas.call(xp_since_realtime_avg).length, add_commas.call(xp_since_first_avg).length, add_commas.call(xp_since_last_avg).length, 6 ].max
fame_width = [ add_commas.call(fame_since_realtime).length, add_commas.call(fame_since_first).length, add_commas.call(fame_since_last).length, 4 ].max
avg_fame_width = [ add_commas.call(fame_since_realtime_avg).length, add_commas.call(fame_since_first_avg).length, add_commas.call(fame_since_last_avg).length, 6 ].max
output = "\n"
output.concat ' gain'.rjust(time_since_label_width/2)
output.concat 'ed in'.ljust((time_since_label_width/2.0).ceil)
output.concat ' '
output.concat ' e'.rjust(exp_width/2)
output.concat 'xp'.ljust((exp_width/2.0).ceil)
output.concat ' '
output.concat ' av'.rjust(avg_exp_width/2)
output.concat 'g/h'.ljust((avg_exp_width/2.0).ceil)
output.concat ' '
if Vars.xp_ignore_fame != 'yes'
output.concat 'fa'.rjust(fame_width/2)
output.concat 'me'.ljust((fame_width/2.0).ceil)
output.concat ' '
output.concat ' av'.rjust(avg_exp_width/2)
output.concat 'g/h'.ljust((avg_exp_width/2.0).ceil)
output.concat ' '
end
output.concat 'until'.rjust(time_until_next_label_width/2)
output.concat ' next'.ljust((time_until_next_label_width/2.0).ceil)
if xp_until_goal > 0
output.concat ' '
output.concat 'until'.rjust(time_until_goal_label_width/2)
output.concat ' goal'.ljust((time_until_goal_label_width/2.0).ceil)
end
output.concat "\n"
output.concat ''.rjust(time_since_label_width, '-')
output.concat ' '
output.concat ''.rjust(exp_width, '-')
output.concat ' '
output.concat ''.rjust(avg_exp_width, '-')
output.concat ' '
if Vars.xp_ignore_fame != 'yes'
output.concat ''.rjust(fame_width, '-')
output.concat ' '
output.concat ''.rjust(avg_fame_width, '-')
output.concat ' '
end
output.concat ''.rjust(time_until_next_label_width, '-')
if xp_until_goal > 0
output.concat ' '
output.concat ''.rjust(time_until_goal_label_width, '-')
end
output.concat "\n"
output.concat format_time_since.call(secs_since_realtime).rjust(time_since_label_width)
output.concat " #{add_commas.call(xp_since_realtime).rjust(exp_width)} #{add_commas.call(xp_since_realtime_avg).rjust(avg_exp_width)} "
if Vars.xp_ignore_fame != 'yes'
output.concat "#{add_commas.call(fame_since_realtime).rjust(fame_width)} #{add_commas.call(fame_since_realtime_avg).rjust(avg_fame_width)} "
end
if time_until_next_realtime
output.concat format_time_until_next.call(time_until_next_realtime).rjust(time_until_next_label_width)
else
output.concat '~'.rjust(time_until_next_label_width)
end
if xp_until_goal > 0
output.concat ' '
if time_until_goal_realtime
output.concat format_time_until_goal.call(time_until_goal_realtime).rjust(time_until_goal_label_width)
else
output.concat '~'.rjust(time_until_goal_label_width)
end
end
output.concat "\n"
output.concat format_time_since.call(secs_since_first).rjust(time_since_label_width)
output.concat " #{add_commas.call(xp_since_first).rjust(exp_width)} #{add_commas.call(xp_since_first_avg).rjust(avg_exp_width)} "
if Vars.xp_ignore_fame != 'yes'
output.concat "#{add_commas.call(fame_since_first).rjust(fame_width)} #{add_commas.call(fame_since_first_avg).rjust(avg_fame_width)} "
end
if time_until_next_first
output.concat format_time_until_next.call(time_until_next_first).rjust(time_until_next_label_width)
else
output.concat '~'.rjust(time_until_next_label_width)
end
if xp_until_goal > 0
output.concat ' '
if time_until_goal_first
output.concat format_time_until_goal.call(time_until_goal_first).rjust(time_until_goal_label_width)
else
output.concat '~'.rjust(time_until_goal_label_width)
end
end
output.concat "\n"
output.concat format_time_since.call(secs_since_last).rjust(time_since_label_width)
output.concat " #{add_commas.call(xp_since_last).rjust(exp_width)} #{add_commas.call(xp_since_last_avg).rjust(avg_exp_width)} "
if Vars.xp_ignore_fame != 'yes'
output.concat "#{add_commas.call(fame_since_last).rjust(fame_width)} #{add_commas.call(fame_since_last_avg).rjust(avg_fame_width)} "
end
if time_until_next_last
output.concat format_time_until_next.call(time_until_next_last).rjust(time_until_next_label_width)
else
output.concat '~'.rjust(time_until_next_label_width)
end
if xp_until_goal > 0
output.concat ' '
if time_until_goal_last
output.concat format_time_until_goal.call(time_until_goal_last).rjust(time_until_goal_label_width)
else
output.concat '~'.rjust(time_until_goal_label_width)
end
end
output.concat "\n"
if xp_until_goal > 0
output.concat "\n"
output.concat "(#{add_commas.call(xp_until_goal)} experience needed to reach your goal of #{add_commas.call(CharSettings['goal'])})\n"
end
output.concat "\n"
respond output
$xp['last'] = now