Created
April 22, 2012 16:14
-
-
Save anonymous/2465011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
class Neggbreaker | |
Conn = Net::HTTP.start 'www.neopets.com' | |
@headers = {'User-Agent' => 'Mozilla/5.0'} | |
def self.login username, password | |
resp = Conn.get "/login.phtml?username=#{username}&password=#{password}" | |
cookie = resp.get_fields('Set-Cookie').map { |c| c.split(';')[0] } * ';' | |
@headers['Cookie'] = cookie | |
end | |
def self.start username, password, count | |
login username, password | |
resp = Conn.get '/battledome/battledome.phtml?type=status', @headers | |
pet = resp.body[/ref.phtml.+?b>(.+?)</, 1] | |
count.times do |i| | |
resp = Conn.post '/battledome/process_battledome.phtml', "petselect=#{pet}&type=oneplayerchallenge&opponent_id=205", @headers | |
url = resp['Location'] | |
fight, hp = url[/\=(\d+)&/, 1], nil | |
until hp == '0' | |
resp = Conn.post '/battledome/process_fight_oneplayer.phtml', "obj_check_5=on&selectmove=abil_10003&equip_item_1=5&pet1_name=#{pet}&pet2_name=Neggbreaker&fight_id=#{fight}", @headers | |
hp = resp.body[/e SET current_hp='(.+?)'/, 1] | |
puts "Neggbreaker's HP: #{hp}" | |
end | |
Conn.get '/battledome/' + url, @headers | |
puts "Beat the Neggbreaker #{i + 1} times." | |
end | |
end | |
end | |
Neggbreaker.start 'username', 'password', 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment