# HG changeset patch # User "Rex Tsai " # Date 1225266964 -28800 # Node ID d3bece9b06b237ecf684b33797ac2f1fe732ef63 # Parent 554bdd49c70337316c228bd5278a4eb7b6742838 fixed the couting *again* diff -r 554bdd49c703 -r d3bece9b06b2 warfare.pl --- a/warfare.pl Wed Oct 29 15:21:15 2008 +0800 +++ b/warfare.pl Wed Oct 29 15:56:04 2008 +0800 @@ -22,12 +22,12 @@ ORDER BY cities.citylevel * (cities.citylevel - 1) * user.trader_score_secondary / 10000 DESC LIMIT 30 } ); -Ikariam::Report->set_sql(attack => qq { +Ikariam::Report->set_sql(victim => qq { SELECT report.id FROM report WHERE report.city = ? AND report.date >= ? - } + } ); sub new { @@ -53,7 +53,6 @@ return ($city->{army}->{Swordsman} > 2 ) ? 1 : 0; } - sub locateVictim { my ($self, $city, $x, $y) = @_; my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6)); @@ -73,22 +72,22 @@ } # check if we over-attacked - my $c = Ikariam::Report->search_attack($city->cityId, time - 24*60*60 - 7*60*60)->count(); + my $c = Ikariam::Report->search_victim($city->cityId, time - 24*60*60 - 7*60*60)->count(); # check the current plunders - foreach ($self->{ikariam}->{'military'}->{'homeland'}) { - $c++ if($_{to} eq $city->cityId); - $c++ if($_{from} eq $city->cityId); + foreach (@{$self->{ikariam}->{'military'}->{'homeland'}}) { + # 出發跟回家都要計算唷 + $c++ if($_->{to} == $city->cityId || $_->{from} == $city->cityId); } next if($c >= 4); # { # if(1) { my $capture = $city->citylevel * ($city->citylevel - 1) * $sheep->trader_score_secondary / 10000; - my $line = sprintf("%d %s [%d,%d] %s (%d) %s/%s", + my $line = sprintf("%d %s [%d,%d] %s (%d) %s/%s. Attacked %d", $capture, $city->status, $island->x, $island->y, $city->cityname, $city->cityId, - $sheep->name, $sheep->ally); + $sheep->name, $sheep->ally, $c); printf("%s\n", $line); # } return $city->cityId;