-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Audit.rb
164 lines (135 loc) · 3.58 KB
/
Audit.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
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
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
colorize(32)
end
def yellow
colorize(33)
end
def blue
colorize(34)
end
def brown
colorize(33)
end
def pink
colorize(35)
end
def light_blue
colorize(36)
end
end
classes = ['mage', 'hunter', 'druid', 'paladin', 'priest', 'rogue', 'shaman',
'warlock', 'warrior'
]
class_pets = ['warlockpet', 'hunterpet']
class_audit = {}
classes.each do |c|
class_audit[c] = {
spell_count: 0,
talent_count: 0,
tome_count: 0,
zero_id_spells: 0,
rankless_spells: 0,
spell_costs: 0
}
end
# Build arrays for final output
classes.each do |c|
spell_type = 'spell'
# Parse the file and check for spellId = 0
File.open("#{Dir.pwd}/Libs/ClassSpells-1.0/#{c}.lua").each do |line|
# id = 0
if spell_type == 'spell'
if line.include?('cost =')
cost = line.gsub('cost = ', '').delete("\n").delete(',')
class_audit[c][:spell_costs] = class_audit[c][:spell_costs] + cost.to_i if (cost != 'unknown' && cost != 'quest')
elsif line.include?('id = 0')
class_audit[c][:zero_id_spells] = class_audit[c][:zero_id_spells] + 1
else
class_audit[c][:spell_count] = class_audit[c][:spell_count] + 1 if line.include?('id = ')
end
# Rankless Spells
class_audit[c][:rankless_spells] = class_audit[c][:rankless_spells] + 1 if line.include?('rank = 0')
end
# Are we in talents yet?
spell_type = 'talent' if line.include?('TalentSpells')
# Are we in tomes yet
spell_type = 'tome' if line.include?('Tomes')
# Talents
class_audit[c][:talent_count] = class_audit[c][:talent_count] + 1 if line.include?('spell_id') and spell_type == 'talent'
# Tomes
class_audit[c][:tome_count] = class_audit[c][:tome_count] + 1 if line.include?('spell_id') and spell_type == 'tome'
end
end
## ##
# Output the Audit Results #
## ##
def output_rated_value(value, zero_is_good = true)
if zero_is_good
if value == 0
return value.to_s.green
else
return value.to_s.red
end
else
if value == 0
return value.to_s.red
end
return value.to_s.green
end
value.to_s.green
end
def format_currency(value)
string = value.to_s
if string.length > 4 then
copper = string.slice!(string.length - 2, string.length)
silver = string.slice!(string.length - 2, string.length)
return string + 'g ' + silver + 's ' + copper + 'c'
elsif string.length > 2 then
copper = string.slice!(string.length - 2, string.length)
return string + 's ' + copper + 'c'
else
return string + 's'
end
return value
end
# By Class
classes.each do |c|
audit = class_audit[c]
case c
when 'mage'
puts c.upcase.light_blue
when 'hunter'
puts c.upcase.green
when 'rogue'
puts c.upcase.yellow
when 'shaman'
puts c.upcase.blue
when 'paladin'
puts c.upcase.pink
when 'warrior'
puts c.upcase.brown
else
puts c.upcase
end
(c.length - 1).times { print "-" }
puts "-"
spell_cost = format_currency(audit[:spell_costs]).blue
sep = " | "
output = ""
output << "Spells: #{output_rated_value(audit[:spell_count], false)}" << sep
output << "Zero ID: #{output_rated_value(audit[:zero_id_spells])}" << sep
output << "Talents: #{output_rated_value(audit[:talent_count], false)}" << sep
output << "Tomes: #{output_rated_value(audit[:tome_count], false)}" << sep
output << "Spell Costs: #{spell_cost}"
print output
puts " "
puts " "
end