Mercurial > eagle-eye
comparison warfare.pl @ 108:d3bece9b06b2
fixed the couting *again*
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 29 Oct 2008 15:56:04 +0800 |
parents | 554bdd49c703 |
children | 11541129a389 |
comparison
equal
deleted
inserted
replaced
107:554bdd49c703 | 108:d3bece9b06b2 |
---|---|
20 AND user.army_score_main == 0 | 20 AND user.army_score_main == 0 |
21 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) | 21 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) |
22 ORDER BY cities.citylevel * (cities.citylevel - 1) * user.trader_score_secondary / 10000 DESC LIMIT 30 | 22 ORDER BY cities.citylevel * (cities.citylevel - 1) * user.trader_score_secondary / 10000 DESC LIMIT 30 |
23 } | 23 } |
24 ); | 24 ); |
25 Ikariam::Report->set_sql(attack => qq { | 25 Ikariam::Report->set_sql(victim => qq { |
26 SELECT report.id | 26 SELECT report.id |
27 FROM report | 27 FROM report |
28 WHERE report.city = ? | 28 WHERE report.city = ? |
29 AND report.date >= ? | 29 AND report.date >= ? |
30 } | 30 } |
31 ); | 31 ); |
32 | 32 |
33 sub new { | 33 sub new { |
34 my ( $class, $i ) = @_; | 34 my ( $class, $i ) = @_; |
35 my $self = { | 35 my $self = { |
51 sub is_army_available { | 51 sub is_army_available { |
52 my ($self, $city) = @_; | 52 my ($self, $city) = @_; |
53 return ($city->{army}->{Swordsman} > 2 ) ? 1 : 0; | 53 return ($city->{army}->{Swordsman} > 2 ) ? 1 : 0; |
54 } | 54 } |
55 | 55 |
56 | |
57 sub locateVictim { | 56 sub locateVictim { |
58 my ($self, $city, $x, $y) = @_; | 57 my ($self, $city, $x, $y) = @_; |
59 my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6)); | 58 my @cities = Ikariam::Cities->search_sheeps(($x + 6), ($x - 6), ($y + 6), ($y - 6)); |
60 | 59 |
61 foreach my $city (@cities) { | 60 foreach my $city (@cities) { |
71 next if(defined($ally) && $ally->members > 10); | 70 next if(defined($ally) && $ally->members > 10); |
72 } | 71 } |
73 } | 72 } |
74 | 73 |
75 # check if we over-attacked | 74 # check if we over-attacked |
76 my $c = Ikariam::Report->search_attack($city->cityId, time - 24*60*60 - 7*60*60)->count(); | 75 my $c = Ikariam::Report->search_victim($city->cityId, time - 24*60*60 - 7*60*60)->count(); |
77 # check the current plunders | 76 # check the current plunders |
78 foreach ($self->{ikariam}->{'military'}->{'homeland'}) { | 77 foreach (@{$self->{ikariam}->{'military'}->{'homeland'}}) { |
79 $c++ if($_{to} eq $city->cityId); | 78 # 出發跟回家都要計算唷 |
80 $c++ if($_{from} eq $city->cityId); | 79 $c++ if($_->{to} == $city->cityId || $_->{from} == $city->cityId); |
81 } | 80 } |
82 next if($c >= 4); | 81 next if($c >= 4); |
83 | 82 |
84 # { | 83 # { |
85 # if(1) { | 84 # if(1) { |
86 my $capture = $city->citylevel * ($city->citylevel - 1) * $sheep->trader_score_secondary / 10000; | 85 my $capture = $city->citylevel * ($city->citylevel - 1) * $sheep->trader_score_secondary / 10000; |
87 my $line = sprintf("%d %s [%d,%d] %s (%d) %s/%s", | 86 my $line = sprintf("%d %s [%d,%d] %s (%d) %s/%s. Attacked %d", |
88 $capture, $city->status, | 87 $capture, $city->status, |
89 $island->x, $island->y, | 88 $island->x, $island->y, |
90 $city->cityname, $city->cityId, | 89 $city->cityname, $city->cityId, |
91 $sheep->name, $sheep->ally); | 90 $sheep->name, $sheep->ally, $c); |
92 printf("%s\n", $line); | 91 printf("%s\n", $line); |
93 # } | 92 # } |
94 return $city->cityId; | 93 return $city->cityId; |
95 } | 94 } |
96 return undef; | 95 return undef; |