comparison agent.pl @ 198:2dfeb4371db7

fixed train_navy counting and corruption counting
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Mon, 03 Nov 2008 11:42:59 +0800
parents dbdd7dcc91c6
children b33c8dbe9b04
comparison
equal deleted inserted replaced
197:dbdd7dcc91c6 198:2dfeb4371db7
54 return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1; 54 return ($city->{buildings}->{warehouse} > $warehouse[$#cities]) ? 0 : 1;
55 } 55 }
56 56
57 sub is_corruption { 57 sub is_corruption {
58 my ($self, $city) = @_; 58 my ($self, $city) = @_;
59 return $city->{corruption}; 59 return ($city->{corruption} > 0) ? 1 : 0;
60 } 60 }
61 61
62 sub is_any_corruption { 62 sub is_any_corruption {
63 my ($self, $city) = @_; 63 my ($self, $city) = @_;
64 64
65 foreach (keys(%{$self->{ikariam}->{cities}})) { 65 foreach (keys(%{$self->{ikariam}->{cities}})) {
66 return 1 if($self->{ikariam}->{cities}->{$_}->{corruption} == 1); 66 return ($self->{ikariam}->{cities}->{$_}->{corruption} > 0) ? 1 : 0;
67 } 67 }
68 return 0; 68 return 0;
69 } 69 }
70 70
71 sub is_happiness { 71 sub is_happiness {
223 my ($self, $city) = @_; 223 my ($self, $city) = @_;
224 my $cityId = $city->{id}; 224 my $cityId = $city->{id};
225 # TODO, 依照升級比例算 CP 值最高 225 # TODO, 依照升級比例算 CP 值最高
226 if($self->is_greekfire_researched() eq 1 && $city->{buildings}->{shipyard} >= 5) { 226 if($self->is_greekfire_researched() eq 1 && $city->{buildings}->{shipyard} >= 5) {
227 # ok, we can build Flamethrower. 227 # ok, we can build Flamethrower.
228 if(($city->{'fleet'}->{BallistaShip} / $city->{'fleet'}->{Flamethrower}) <= (1.5/1)) { 228 if(defined($city->{'fleet'}->{Flamethrower}) && ($city->{'fleet'}->{Flamethrower} > 0)
229 && ($city->{'fleet'}->{BallistaShip} / $city->{'fleet'}->{Flamethrower}) <= (1.5/1)) {
229 return 213; # 強弩船 230 return 213; # 強弩船
230 } else { 231 } else {
231 return 211; # 噴火船 232 return 211; # 噴火船
232 } 233 }
233 } else { 234 } else {