comparison Ikariam.pm @ 179:8afd380c20ac

do not fight with friends.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 21:15:51 +0800
parents 0cfc7a19a4d2
children c6c6db6eea76
comparison
equal deleted inserted replaced
174:0cfc7a19a4d2 179:8afd380c20ac
140 } 140 }
141 }; 141 };
142 142
143 143
144 # if debug 144 # if debug
145 # LWP::Debug::level('+trace'); 145 LWP::Debug::level('+trace');
146 146
147 $self->{mech}->cookie_jar(HTTP::Cookies->new(file => "/tmp/ikariam-cookies.txt", autosave => 1)); 147 $self->{mech}->cookie_jar(HTTP::Cookies->new(file => "/tmp/ikariam-cookies.txt", autosave => 1));
148 $self->{mech}->default_headers->push_header('Accept-Encoding', 'deflate'); 148 $self->{mech}->default_headers->push_header('Accept-Encoding', 'deflate');
149 149
150 return bless $self, $class; 150 return bless $self, $class;
472 my $treaty = Ikariam::Extractor->new(content => $res->content)->find('//div[@class="warning"]'); 472 my $treaty = Ikariam::Extractor->new(content => $res->content)->find('//div[@class="warning"]');
473 if(!defined($treaty)) { 473 if(!defined($treaty)) {
474 $self->{mech}->submit_form( 474 $self->{mech}->submit_form(
475 form_number => 1, 475 form_number => 1,
476 fields => { 476 fields => {
477 cargo_army_302 => '2', 477 cargo_army_302 => '2', # 劍士
478 } 478 }
479 ); 479 );
480 } else { 480 } else {
481 warn ($treaty); 481 # put the id in the friends.txt file.
482 Ikariam::Cities->has_a(user => 'Ikariam::User');
483 my $city = Ikariam::Cities->retrieve($cityId);
484 my $sheep = $city->user;
485
486 open(OUT, ">>friends.txt") or Carp::carp("can not open friends.txt");
487 print OUT $sheep->name . "\n";
488 close(OUT);
489 Carp::carp($treaty);
482 } 490 }
483 } 491 }
484 492
485 sub changeCity { 493 sub changeCity {
486 my $self = shift; 494 my $self = shift;