friedmag-warcraft-armory 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +2 -0
- data/LICENSE +20 -0
- data/README.textile +44 -0
- data/Rakefile +25 -0
- data/init.rb +2 -0
- data/lib/warcraft_armory.rb +34 -0
- data/lib/warcraft_armory/character.rb +142 -0
- data/lib/warcraft_armory/character_part.rb +41 -0
- data/lib/warcraft_armory/character_reputation.rb +66 -0
- data/lib/warcraft_armory/faction.rb +124 -0
- data/lib/warcraft_armory/faction_category.rb +22 -0
- data/lib/warcraft_armory/guild.rb +51 -0
- data/lib/warcraft_armory/guild_lite.rb +23 -0
- data/lib/warcraft_armory/guild_statistics.rb +111 -0
- data/lib/warcraft_armory_test_hacks.rb +17 -0
- data/test/assets/character.xml +114 -0
- data/test/assets/guild.xml +466 -0
- data/test/character_test.rb +57 -0
- data/test/guild_test.rb +31 -0
- data/warcraft-armory.gemspec +32 -0
- metadata +89 -0
data/Changelog
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Ariejan de Vroom, Andrea Nall
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
h1. Warcraft Armory
|
|
2
|
+
|
|
3
|
+
Warcraft Armory allows you to easily query the World of Warcraft Armory site to retrieve information about your character.
|
|
4
|
+
|
|
5
|
+
Both US and EU servers are supported.
|
|
6
|
+
|
|
7
|
+
Written by "Ariejan de Vroom":mailto:ariejan@ariejan.net
|
|
8
|
+
"Andrea Nall":mailto:anall@andreanall.com
|
|
9
|
+
|
|
10
|
+
Copyright 2008 Ariejan de Vroom, Andrea Nall
|
|
11
|
+
|
|
12
|
+
h2. Disclaimer
|
|
13
|
+
|
|
14
|
+
This is the usual dislaimer. I'm not liable when you use this gem. Using it may be against the current (or future) terms of service from Blizzard or WoWarmory.com.
|
|
15
|
+
|
|
16
|
+
h2. Download and installation
|
|
17
|
+
|
|
18
|
+
Simply install the RubyGem and require it in your project. If you're on rails, require it in your config/environment.rb.
|
|
19
|
+
|
|
20
|
+
<pre>gem install anall-warcraft-armory --source http://gems.github.com</pre>
|
|
21
|
+
|
|
22
|
+
And require it when you need it:
|
|
23
|
+
|
|
24
|
+
<pre><code>require 'warcraft-armory'</code></pre>
|
|
25
|
+
|
|
26
|
+
Add the following to your environment.rb if you want to use Rails 2.1's dependency manager (which is highly recommended):
|
|
27
|
+
|
|
28
|
+
<pre><code>config.gem "anall-warcraft-armory",
|
|
29
|
+
:lib => "warcraft-armory",
|
|
30
|
+
:source => "http://gems.github.com"</code></pre>
|
|
31
|
+
|
|
32
|
+
h2. Usage
|
|
33
|
+
|
|
34
|
+
<pre><code>character = WarcraftAmory.find(:eu, 'Aszune', 'Nosius')</code></pre>
|
|
35
|
+
|
|
36
|
+
This will either return a WarcraftCharacter object or nil when not character information was found.
|
|
37
|
+
|
|
38
|
+
h2. More Information
|
|
39
|
+
|
|
40
|
+
"Ariejan.net":http://ariejan.net
|
|
41
|
+
|
|
42
|
+
"Blizzard":http://www.blizzard.com
|
|
43
|
+
"WoW Armory US":http://www.wowarmory.com
|
|
44
|
+
"WoW Armory EU":http://eu.wowarmory.com
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'echoe'
|
|
4
|
+
|
|
5
|
+
Echoe.new('warcraft-armory', '0.0.1') do |p|
|
|
6
|
+
p.description = "Retrieve character information from the World of Warcraft Armory"
|
|
7
|
+
p.url = "http://github.com/anall/warcraft-armory"
|
|
8
|
+
p.author = "Andrea Nall"
|
|
9
|
+
p.email = "anall@andreanall.com"
|
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*", "coverage.data","lib/warcraft_armory_test_hacks.rb"]
|
|
11
|
+
p.development_dependencies = []
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
|
15
|
+
|
|
16
|
+
namespace :test do
|
|
17
|
+
desc 'Measures test coverage'
|
|
18
|
+
task :coverage do
|
|
19
|
+
rm_f "coverage"
|
|
20
|
+
rm_f "coverage.data"
|
|
21
|
+
rcov = "rcov --aggregate coverage.data --text-summary -Ilib"
|
|
22
|
+
system("#{rcov} test/*_test.rb")
|
|
23
|
+
system("open coverage/index.html") if PLATFORM['darwin']
|
|
24
|
+
end
|
|
25
|
+
end
|
data/init.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'warcraft_armory/character_part'
|
|
2
|
+
require 'warcraft_armory/character'
|
|
3
|
+
|
|
4
|
+
require 'warcraft_armory/character_reputation'
|
|
5
|
+
|
|
6
|
+
require 'warcraft_armory/guild_lite'
|
|
7
|
+
require 'warcraft_armory/guild'
|
|
8
|
+
require 'warcraft_armory/guild_statistics'
|
|
9
|
+
|
|
10
|
+
require 'warcraft_armory/faction'
|
|
11
|
+
require 'warcraft_armory/faction_category'
|
|
12
|
+
|
|
13
|
+
module WarcraftArmory
|
|
14
|
+
def self.getRace(id)
|
|
15
|
+
[nil,:human,:orc,:dwarf,:nightelf,:undead,:tauren,:gnome,:troll,nil,:bloodelf,:draenei][id]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.getRaceFaction(id)
|
|
19
|
+
[nil,:alliance,:horde,:alliance,:alliance,:horde,:horde,:alliance,:horde,nil,:horde,:alliance][id]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.getFaction(id)
|
|
23
|
+
[:alliance,:horde][id]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.getGender(id)
|
|
27
|
+
[:male,:female][id]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.getClass(id)
|
|
31
|
+
[nil,:warrior,:paladin,:hunter,:rogue,:priest,:deathknight,:shaman,:mage,:warlock,nil,:druid][id]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require "rexml/document"
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module WarcraftArmory
|
|
6
|
+
class Character < CharacterPart
|
|
7
|
+
def self.find(location, realm, character_name)
|
|
8
|
+
site = "http://#{location.to_s}.wowarmory.com"
|
|
9
|
+
url = "#{site}/character-sheet.xml?r=#{CGI.escape realm}&n=#{CGI.escape character_name}"
|
|
10
|
+
|
|
11
|
+
WarcraftArmory::Character.new(site,open(url,"User-Agent" => "Mozilla/5.0 (WarcraftArmory) Firefox/3.0.2"))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.fetch(site,urlArgs)
|
|
15
|
+
url = "#{site}/character-sheet.xml?#{urlArgs}"
|
|
16
|
+
WarcraftArmory::Character.new(site,open(url,"User-Agent" => "Mozilla/5.0 (WarcraftArmory) Firefox/3.0.2"))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize(site,xml_or_stream)
|
|
20
|
+
if (xml_or_stream.class == Hash)
|
|
21
|
+
@lite = true
|
|
22
|
+
super(site,xml_or_stream)
|
|
23
|
+
elsif (xml_or_stream.class == REXML::Attributes)
|
|
24
|
+
@lite = true
|
|
25
|
+
super(site,xml_or_stream)
|
|
26
|
+
else
|
|
27
|
+
@doc = REXML::Document.new xml_or_stream
|
|
28
|
+
|
|
29
|
+
info = REXML::XPath.first(@doc,"//characterInfo").attributes
|
|
30
|
+
if (info["errCode"] != nil)
|
|
31
|
+
raise info["errCode"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
attribs = REXML::XPath.first(@doc,"//character").attributes
|
|
35
|
+
@lite = false
|
|
36
|
+
|
|
37
|
+
super(site,attribs)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def inspect
|
|
42
|
+
full_name
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def current_title_format
|
|
46
|
+
if (@lite)
|
|
47
|
+
"%s"
|
|
48
|
+
else
|
|
49
|
+
@current_title_format ||= (REXML::XPath.first(@doc,"//title/@value") || "%s").to_s
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def title_formats
|
|
54
|
+
if (@lite)
|
|
55
|
+
[]
|
|
56
|
+
else
|
|
57
|
+
@title_formats ||= _title_formats
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def titles
|
|
62
|
+
title_formats.map { |x| sprintf(x,name) }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def full_name
|
|
66
|
+
if (@lite)
|
|
67
|
+
name
|
|
68
|
+
else
|
|
69
|
+
@full_name ||= sprintf(current_title_format,name)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def name
|
|
74
|
+
@name ||= @character["name"]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def faction
|
|
78
|
+
@faction ||= WarcraftArmory.getFaction(@character["factionId"].to_i)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def level
|
|
82
|
+
@level ||= @character["level"].to_i
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def race
|
|
86
|
+
@race ||= WarcraftArmory.getRace(@character["raceId"].to_i)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def gender
|
|
90
|
+
@gender ||= WarcraftArmory.getGender(@character["genderId"].to_i)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def class_name
|
|
94
|
+
@class ||= WarcraftArmory.getClass(@character["classId"].to_i)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def guild
|
|
98
|
+
if (@lite)
|
|
99
|
+
nil
|
|
100
|
+
else
|
|
101
|
+
@guild ||= _guild
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def full_character(location = nil)
|
|
106
|
+
if (@lite)
|
|
107
|
+
@site ||= "http://#{location.to_s}.wowarmory.com"
|
|
108
|
+
|
|
109
|
+
url = "#{@site}/character-sheet.xml?#{urlSuffix}"
|
|
110
|
+
stuff = open(url,"User-Agent" => "Mozilla/5.0 (WarcraftArmory) Firefox/3.0.2")
|
|
111
|
+
|
|
112
|
+
@doc = REXML::Document.new stuff
|
|
113
|
+
|
|
114
|
+
info = REXML::XPath.first(@doc,"//characterInfo").attributes
|
|
115
|
+
if (info["errCode"] != nil)
|
|
116
|
+
raise info["errCode"]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
@character = REXML::XPath.first(@doc,"//character").attributes
|
|
120
|
+
@lite = false
|
|
121
|
+
end
|
|
122
|
+
self
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
def _title_formats
|
|
127
|
+
tf = REXML::XPath.match(@doc,"//knownTitles/title/@value").map { |x| x.to_s }
|
|
128
|
+
tf << current_title_format if (current_title_format)
|
|
129
|
+
tf.sort
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def _guild
|
|
133
|
+
if (@character["guildName"] == nil)
|
|
134
|
+
nil
|
|
135
|
+
elsif (@site)
|
|
136
|
+
WarcraftArmory::Guild.fetch(@site,@character['guildUrl'])
|
|
137
|
+
else
|
|
138
|
+
WarcraftArmory::GuildLite.new(@character)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module WarcraftArmory
|
|
2
|
+
class CharacterPart
|
|
3
|
+
def initialize(site,attributes)
|
|
4
|
+
@site = site
|
|
5
|
+
|
|
6
|
+
@character = attributes
|
|
7
|
+
|
|
8
|
+
@other_parts = {}
|
|
9
|
+
_setBits(self)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def reputation(location = nil)
|
|
13
|
+
@site ||= "http://#{location.to_s}.wowarmory.com"
|
|
14
|
+
@other_parts[:reputation] ||= WarcraftArmory::CharacterReputation.fetch(@site,urlSuffix)
|
|
15
|
+
@other_parts[:reputation]._setBits(self)
|
|
16
|
+
@other_parts[:reputation]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def character(location = nil)
|
|
20
|
+
@site ||= "http://#{location.to_s}.wowarmory.com"
|
|
21
|
+
@other_parts[:character] ||= WarcraftArmory::Character.fetch(@site,urlSuffix)
|
|
22
|
+
@other_parts[:character]._setBits(self)
|
|
23
|
+
@other_parts[:character]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def urlSuffix
|
|
27
|
+
@urlSuffix ||= (@character["url"] || @character["charUrl"])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
def _setBits(what)
|
|
32
|
+
@other_parts = what._otherParts
|
|
33
|
+
@other_parts[:character] = what if (what.class == WarcraftArmory::Character)
|
|
34
|
+
@other_parts[:reputation] = what if (what.class == WarcraftArmory::CharacterReputation)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def _otherParts
|
|
38
|
+
@other_parts
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require "rexml/document"
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
5
|
+
module WarcraftArmory
|
|
6
|
+
class CharacterReputation < CharacterPart
|
|
7
|
+
def self.find(location, realm, character_name)
|
|
8
|
+
site = "http://#{location.to_s}.wowarmory.com"
|
|
9
|
+
url = "#{site}/character-reputation.xml?r=#{CGI.escape realm}&n=#{CGI.escape character_name}"
|
|
10
|
+
|
|
11
|
+
WarcraftArmory::CharacterReputation.new(site,open(url,"User-Agent" => "Mozilla/5.0 (WarcraftArmory) Firefox/3.0.2"))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def reputation(location = nil)
|
|
15
|
+
self
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.fetch(site,urlArgs)
|
|
19
|
+
url = "#{site}/character-reputation.xml?#{urlArgs}"
|
|
20
|
+
WarcraftArmory::CharacterReputation.new(site,open(url,"User-Agent" => "Mozilla/5.0 (WarcraftArmory) Firefox/3.0.2"))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initialize(site,xml_or_stream)
|
|
24
|
+
@doc = REXML::Document.new xml_or_stream
|
|
25
|
+
|
|
26
|
+
info = REXML::XPath.first(@doc,"//characterInfo").attributes
|
|
27
|
+
if (info["errCode"] != nil)
|
|
28
|
+
raise info["errCode"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
attribs = REXML::XPath.first(@doc,"//character").attributes
|
|
32
|
+
|
|
33
|
+
super(site,attribs)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def factions
|
|
37
|
+
parse
|
|
38
|
+
@factions
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def categories
|
|
42
|
+
parse
|
|
43
|
+
@categories
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
def parse
|
|
48
|
+
return if (@parsed)
|
|
49
|
+
@factions = {}
|
|
50
|
+
@categories = {}
|
|
51
|
+
REXML::XPath.each(@doc,"//factionCategory") do |cat|
|
|
52
|
+
factions = {}
|
|
53
|
+
REXML::XPath.each(cat,"faction") do |faction|
|
|
54
|
+
attrs = faction.attributes
|
|
55
|
+
_faction = WarcraftArmory::Faction.new(cat,attrs)
|
|
56
|
+
factions[attrs["key"]] = _faction
|
|
57
|
+
@factions[attrs["key"]] = _faction
|
|
58
|
+
end
|
|
59
|
+
attrs = cat.attributes
|
|
60
|
+
@categories[attrs["key"]] = WarcraftArmory::FactionCategory.new(attrs,factions)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
@parsed = true
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module WarcraftArmory
|
|
2
|
+
class Faction
|
|
3
|
+
def initialize(cat,faction)
|
|
4
|
+
@data = faction
|
|
5
|
+
@cat = cat
|
|
6
|
+
|
|
7
|
+
@name = faction["name"].to_s
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def inspect
|
|
11
|
+
sprintf("%s - %s - %i / %i",name,repLevel,currentRep,maxRep)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def name
|
|
15
|
+
@name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def category
|
|
19
|
+
@cat
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def percent
|
|
23
|
+
currentRep.to_f/maxRep.to_f
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def fullPercent
|
|
27
|
+
if rawReputation >= 0
|
|
28
|
+
rawReputation.to_f / 42999.0
|
|
29
|
+
else
|
|
30
|
+
(rawReputation.to_f / 42000.0)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def currentRep
|
|
35
|
+
_rep = rawReputation
|
|
36
|
+
if repLevelSymbol == :hated
|
|
37
|
+
42000 + _rep
|
|
38
|
+
elsif repLevelSymbol == :hostile
|
|
39
|
+
6000 + _rep
|
|
40
|
+
elsif repLevelSymbol == :unfriendly
|
|
41
|
+
3000 + _rep
|
|
42
|
+
elsif repLevelSymbol == :neutral
|
|
43
|
+
_rep
|
|
44
|
+
elsif repLevelSymbol == :friendly
|
|
45
|
+
_rep - 3000
|
|
46
|
+
elsif repLevelSymbol == :honored
|
|
47
|
+
_rep - 9000
|
|
48
|
+
elsif repLevelSymbol == :revered
|
|
49
|
+
_rep - 21000
|
|
50
|
+
elsif repLevelSymbol == :exalted
|
|
51
|
+
_rep - 42000
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def maxRep
|
|
56
|
+
if repLevelSymbol == :hated
|
|
57
|
+
36000
|
|
58
|
+
elsif repLevelSymbol == :hostile
|
|
59
|
+
3000
|
|
60
|
+
elsif repLevelSymbol == :unfriendly
|
|
61
|
+
3000
|
|
62
|
+
elsif repLevelSymbol == :neutral
|
|
63
|
+
3000
|
|
64
|
+
elsif repLevelSymbol == :friendly
|
|
65
|
+
6000
|
|
66
|
+
elsif repLevelSymbol == :honored
|
|
67
|
+
12000
|
|
68
|
+
elsif repLevelSymbol == :revered
|
|
69
|
+
21000
|
|
70
|
+
elsif repLevelSymbol == :exalted
|
|
71
|
+
999
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def repLevel
|
|
76
|
+
if repLevelSymbol == :hated
|
|
77
|
+
"Hated"
|
|
78
|
+
elsif repLevelSymbol == :hostile
|
|
79
|
+
"Hostile"
|
|
80
|
+
elsif repLevelSymbol == :unfriendly
|
|
81
|
+
"Unfriendly"
|
|
82
|
+
elsif repLevelSymbol == :neutral
|
|
83
|
+
"Neutral"
|
|
84
|
+
elsif repLevelSymbol == :friendly
|
|
85
|
+
"Friendly"
|
|
86
|
+
elsif repLevelSymbol == :honored
|
|
87
|
+
"Honored"
|
|
88
|
+
elsif repLevelSymbol == :revered
|
|
89
|
+
"Revered"
|
|
90
|
+
elsif repLevelSymbol == :exalted
|
|
91
|
+
"Exalted"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def repLevelSymbol
|
|
96
|
+
@repLevelSymbol ||= _repLevelSymbol
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
def _repLevelSymbol
|
|
101
|
+
if rawReputation <= -6000
|
|
102
|
+
:hated
|
|
103
|
+
elsif rawReputation <= -3000
|
|
104
|
+
:hostile
|
|
105
|
+
elsif rawReputation <= 0
|
|
106
|
+
:unfriendly
|
|
107
|
+
elsif rawReputation < 3000
|
|
108
|
+
:neutral
|
|
109
|
+
elsif rawReputation < 9000
|
|
110
|
+
:friendly
|
|
111
|
+
elsif rawReputation < 21000
|
|
112
|
+
:honored
|
|
113
|
+
elsif rawReputation < 42000
|
|
114
|
+
:revered
|
|
115
|
+
else
|
|
116
|
+
:exalted
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def rawReputation
|
|
121
|
+
@rawReputation ||= @data["reputation"].to_i
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|