Mercurial > eagle-eye
diff warfare.pl @ 125:4374173bab47
collect hometown island information.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 31 Oct 2008 00:20:41 +0800 |
parents | f8c97e5d77ab |
children | a5517f0abb85 |
line wrap: on
line diff
--- a/warfare.pl Thu Oct 30 17:25:20 2008 +0800 +++ b/warfare.pl Fri Oct 31 00:20:41 2008 +0800 @@ -15,12 +15,16 @@ Ikariam::Cities->set_sql(sheeps => qq { SELECT cities.cityId FROM user, cities - WHERE user.id == cities.user - AND user.army_score_main == 0 + WHERE user.id = cities.user + AND user.army_score_main = 0 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) + AND cities.tradegood != ? ORDER BY cities.citylevel * (cities.citylevel - 1) * user.trader_score_secondary / 10000 DESC LIMIT 30 } ); +# $island->tradegood, +# qw/NULL 葡萄酒 大理石 水晶 硫磺/; +# 不打與自己相同的資源 Ikariam::Report->set_sql(victim => qq { SELECT report.id FROM report @@ -54,7 +58,7 @@ sub locateVictim { my ($self, $city, $x, $y) = @_; - my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6)); + my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6), $tradegood); foreach my $city (@cities) { my $sheep = $city->user; @@ -97,8 +101,8 @@ } sub engagement { - my ($self, $cityId, $x, $y) = @_; - my $victim = $self->locateVictim($cityId, $x, $y); + my ($self, $cityId, $x, $y, $tradegood) = @_; + my $victim = $self->locateVictim($cityId, $x, $y, $tradegood); if(defined($victim)) { $self->{ikariam}->changeCity($cityId); $self->{ikariam}->plunderCity($victim); @@ -109,9 +113,6 @@ package main; -if($#ARGV != 1) { die("Usage: $0 x y\n"); } -my ($x, $y) = @ARGV; - our $i = new Ikariam($::server, $::user, $::pass); our $rules = Ikariam::Warfare::Rules->new($i); @@ -119,7 +120,6 @@ my $cities = $i->check; $i->checkMilitaryAdvisorCombatReports(); - foreach my $cityId (keys(%$cities)) { print Dump($i->{'military'}); # build and upgrade for cities @@ -127,7 +127,8 @@ $cities->{$cityId}->{parse_path} = []; $cities->{$cityId}->{parse_answer} = undef; if(ParseTree($tree, $rules, $cities->{$cityId}) eq 'engagement') { - $rules->engagement($cityId, $x, $y); + my $island = Ikariam::Island->retrive($cities->{$cityId}->{island}->{id}); + $rules->engagement($cityId, $island->{x}, $island->{y}, $island->tradegood); sleep(30); $i->checkMilitaryAdvisorMilitaryMovements(); }