Remove pet state labeling & Neopets gem
This labeling technique hasn't worked in a long time bc it requires being logged in. These days we just manually label them with the 2020 support tools I think! Clearing out the Neopets gem should help us manage some gem dep conflicts in the 4.2 upgrade too (I think the nokogiri one gets tricky?)
This commit is contained in:
parent
0d4c6ca077
commit
a15cbeb307
4 changed files with 27 additions and 33 deletions
1
Gemfile
1
Gemfile
|
@ -39,7 +39,6 @@ gem 'sanitize', '~> 2.0.3'
|
||||||
# For working with Neopets APIs.
|
# For working with Neopets APIs.
|
||||||
# unstable version of RocketAMF interprets info registry as a hash instead of an array
|
# unstable version of RocketAMF interprets info registry as a hash instead of an array
|
||||||
gem 'RocketAMF', :git => 'https://github.com/rubyamf/rocketamf.git'
|
gem 'RocketAMF', :git => 'https://github.com/rubyamf/rocketamf.git'
|
||||||
gem 'neopets', '~> 0.2.0', :git => 'https://github.com/matchu/neopets.git'
|
|
||||||
|
|
||||||
# For working with the OpenNeo ID service.
|
# For working with the OpenNeo ID service.
|
||||||
gem 'msgpack', '~> 0.5.3'
|
gem 'msgpack', '~> 0.5.3'
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
GIT
|
|
||||||
remote: https://github.com/matchu/neopets.git
|
|
||||||
revision: 5d13a720b616ba57fbbd54541f3e5daf02b3fedc
|
|
||||||
specs:
|
|
||||||
neopets (0.2.0)
|
|
||||||
nokogiri (~> 1.5.2)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/rubyamf/rocketamf.git
|
remote: https://github.com/rubyamf/rocketamf.git
|
||||||
revision: 796f591d002b5cf47df436dbcbd6f2ab00e869ed
|
revision: 796f591d002b5cf47df436dbcbd6f2ab00e869ed
|
||||||
|
@ -228,7 +221,6 @@ DEPENDENCIES
|
||||||
memcache-client (~> 1.8.5)
|
memcache-client (~> 1.8.5)
|
||||||
msgpack (~> 0.5.3)
|
msgpack (~> 0.5.3)
|
||||||
mysql2 (>= 0.3.11)
|
mysql2 (>= 0.3.11)
|
||||||
neopets (~> 0.2.0)!
|
|
||||||
nokogiri (~> 1.5.2)
|
nokogiri (~> 1.5.2)
|
||||||
openneo-auth-signatory (~> 0.1.0)
|
openneo-auth-signatory (~> 0.1.0)
|
||||||
parallel (~> 1.13.0)
|
parallel (~> 1.13.0)
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Pet < ActiveRecord::Base
|
||||||
biology = pet_data[:biology_by_zone]
|
biology = pet_data[:biology_by_zone]
|
||||||
biology[0] = nil # remove effects if present
|
biology[0] = nil # remove effects if present
|
||||||
@pet_state = self.pet_type.add_pet_state_from_biology! biology
|
@pet_state = self.pet_type.add_pet_state_from_biology! biology
|
||||||
@pet_state.label_by_pet(self, pet_data[:owner])
|
|
||||||
@items = Item.collection_from_pet_type_and_registries(self.pet_type,
|
@items = Item.collection_from_pet_type_and_registries(self.pet_type,
|
||||||
viewer_data[:object_info_registry], viewer_data[:object_asset_registry],
|
viewer_data[:object_info_registry], viewer_data[:object_asset_registry],
|
||||||
options[:item_scope])
|
options[:item_scope])
|
||||||
|
|
|
@ -98,30 +98,8 @@ class PetState < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def label_by_pet(pet, username)
|
|
||||||
# If this pet is already labeled with a gender/mood, or it's unconverted
|
|
||||||
# and therefore has none, skip.
|
|
||||||
return false if self.labeled? || self.unconverted?
|
|
||||||
|
|
||||||
# Find this pet on the owner's userlookup, where we can get both its gender
|
|
||||||
# and its mood.
|
|
||||||
begin
|
|
||||||
user_pet = Neopets::User.new(username).pets.
|
|
||||||
find { |user_pet| user_pet.name.downcase == pet.name.strip.downcase }
|
|
||||||
self.female = user_pet.female?
|
|
||||||
self.mood_id = user_pet.mood.id
|
|
||||||
self.labeled = true
|
|
||||||
rescue
|
|
||||||
# If there's an error loading the userlookup data (e.g. account is
|
|
||||||
# frozen), no big deal; we just won't label the pet right now. Proceed
|
|
||||||
# as usual.
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def mood
|
def mood
|
||||||
Neopets::Pet::Mood.find(self.mood_id)
|
Mood.find(self.mood_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def gender_name
|
def gender_name
|
||||||
|
@ -246,5 +224,31 @@ class PetState < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Copied from https://github.com/matchu/neopets/blob/5d13a720b616ba57fbbd54541f3e5daf02b3fedc/lib/neopets/pet/mood.rb
|
||||||
|
class Mood
|
||||||
|
attr_reader :id, :name
|
||||||
|
|
||||||
|
def initialize(options)
|
||||||
|
@id = options[:id]
|
||||||
|
@name = options[:name]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find(id)
|
||||||
|
self.all_by_id[id.to_i]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.all
|
||||||
|
@all ||= [
|
||||||
|
Mood.new(:id => 1, :name => :happy),
|
||||||
|
Mood.new(:id => 2, :name => :sad),
|
||||||
|
Mood.new(:id => 4, :name => :sick)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.all_by_id
|
||||||
|
@all_by_id ||= self.all.inject({}) { |h, m| h[m.id] = m; h }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue