annotate Ikariam/CitiesRules.pm @ 373:dd3d76f43999

update script for collecting ally information.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 14 Apr 2009 17:00:40 +0800
parents 0522468991c1
children
rev   line source
371
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
1 #!/usr/bin/perl
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
2
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
3 package Ikariam::CitiesRules;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
4 use strict;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
5 use Data::Dumper;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
6
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
7 sub new {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
8 my ( $class, $i ) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
9 my $self = {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
10 ikariam => $i,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
11 };
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
12 return bless $self, $class;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
13 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
14
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
15 sub is_attacked {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
16 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
17
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
18 return ($self->{'ikariam'}->{'military'}->{attack} > 0 ) ? 1 : 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
19 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
20
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
21 sub is_constructing {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
22 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
23 return ($city->{construction} > 0 ) ? 1 : 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
24 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
25
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
26 sub is_wall_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
27 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
28 # http://ikariam.wikia.com/wiki/Wall_Defense
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
29 # Basic rule - the wall level must equale or large then townHall level.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
30 return ($city->{buildings}->{wall} >= $city->{buildings}->{townHall} ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
31 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
32
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
33 sub is_academy_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
34 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
35 return ($city->{buildings}->{academy} >= 12 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
36 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
37
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
38 sub is_embassy_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
39 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
40 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
41 return ($city->{buildings}->{embassy} >= 1 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
42 return ($city->{buildings}->{embassy} >= 6 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
43 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
44
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
45 sub is_museum_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
46 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
47 return 1 if($city->{buildings}->{museum} >= 8);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
48 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
49
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
50 sub is_tavern_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
51 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
52 return 0 if(!defined($city->{buildings}->{tavern}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
53 return ($city->{buildings}->{tavern} >= 12 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
54 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
55
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
56 sub is_branchOffice_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
57 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
58 return ($city->{buildings}->{branchOffice} >= 6 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
59 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
60
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
61 sub is_port_available {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
62 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
63 return 0 if(!defined($city->{buildings}->{port}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
64 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
65 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
66
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
67 sub is_port_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
68 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
69 return ($city->{buildings}->{port} >= 12 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
70 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
71
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
72 sub is_space_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
73 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
74 # The maximum town hall is level 20, then we build new town
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
75 return 1 if($city->{buildings}->{townHall} >= 15);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
76 # TODO 應該以 成長率 * 升級所需時間計算
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
77 # 6 hours earlier, we upgrade the twonHall.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
78 return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*12)) ? 0 : 1)
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
79 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
80
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
81 sub is_safehouse_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
82 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
83
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
84 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
85
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
86 return 0 if(!defined($city->{buildings}->{safehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
87 return 1 if(($city->{buildings}->{townHall} - $city->{buildings}->{wall}) > 2);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
88 return 1 if($city->{buildings}->{townHall} >= 20);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
89
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
90 # build the higgest safehouse.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
91 # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
92 # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1)
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
93 # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
94
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
95 # Safehouse must be same level as townHall,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
96 return (($city->{buildings}->{townHall} >= $city->{buildings}->{safehouse}) ? 0 : 1);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
97 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
98
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
99 sub is_warehouse_available {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
100 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
101 return 0 if(!defined($city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
102 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
103 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
104
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
105 sub is_warehouse_more_then_eight {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
106 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
107 my $cityId = $city->{id};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
108 return 0 if(!defined($city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
109
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
110 my @locations = @{$city->{locations}};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
111 my $count = 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
112 foreach (3..14) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
113 $count++ if($locations[$_] eq "warehouse");
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
114 return 1 if($count >= 8);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
115 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
116 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
117 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
118
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
119 sub is_warehouse_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
120 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
121
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
122 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
123 # my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
124 my @warehouse = (qw/undef undef 0 4 9 15 17 18 19 20 21 22 23 24/);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
125 my @cities = keys(%{$self->{ikariam}->{cities}});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
126 my $nextCities = ($#cities + 1) + 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
127
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
128 Carp::carp(sprintf("Required warehouse level %s for next city (%s), current is %s\n", $warehouse[$nextCities], $nextCities, $city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
129 return 0 if(!defined($city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
130 return ($city->{buildings}->{warehouse} >= $warehouse[$nextCities]) ? 1 : 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
131 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
132
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
133
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
134 sub is_warehouse_enougn_for_governorsresidence {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
135 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
136 return (($city->{buildings}->{warehouse} >= 5) ? 0 : 1);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
137
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
138 my @warehouse = (qw/undef undef 0 4 9 16 18 19 20 21 22 23 24 25/);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
139 my @cities = keys(%{$self->{ikariam}->{cities}});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
140 my $citiesNumber = $#cities + 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
141
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
142 Carp::carp(sprintf("Required warehouse level %s for %s cities, current is %s\n", $warehouse[$citiesNumber], $citiesNumber, $city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
143 return 0 if(!defined($city->{buildings}->{warehouse}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
144 return ($city->{buildings}->{warehouse} >= $warehouse[$citiesNumber]) ? 1 : 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
145 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
146
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
147 sub is_corruption {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
148 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
149 return ($city->{corruption} > 0) ? 1 : 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
150 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
151
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
152 sub is_any_corruption {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
153 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
154
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
155 foreach (keys(%{$self->{ikariam}->{cities}})) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
156 return 1 if ($self->{ikariam}->{cities}->{$_}->{corruption} > 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
157 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
158 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
159 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
160
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
161 sub is_happiness {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
162 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
163
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
164 return ($city->{growth} >= 5 ? 1 : 0)
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
165 if($city->{buildings}->{townHall} <= 10);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
166
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
167 return ($city->{growth} >= 2 ? 1 : 0)
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
168 if($city->{buildings}->{townHall} <= 15);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
169
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
170 return 1 if($city->{buildings}->{townHall} >= 20);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
171 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
172
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
173
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
174 sub is_bacchanal {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
175 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
176 return ($city->{tavern}->{maxValue} == $city->{tavern}->{iniValue} ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
177 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
178
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
179 sub is_gold_enoughforcargo {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
180 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
181 my @cargoCost = qw/160 244 396 812 1240 1272 1832 1888 3848 3972 5204 5384 6868 7120 8864 9200 11268 11712 14108 14680 23320 24288 28664 29880 34956 36468 42348 44212 51024 53308 61236 64024 73096 76468 87020 91088 103224 116524 122072 137432 180060 202132 211964 237444 249108 278276 292076 306623 321963 338138 355198 373191 392171 412195 433320 455612 479135 503962 530166 557828 587031 617863 650420 684802 721113 759466 799981 842783 888005 935790 986286 1039654 1096062 1155689 1218724 1285369 1355837 1430353 1509159 1592508 1680670 1773932 1872597 1976989 2087448 2204338 2328045 2458976 2597567 2744276 2899594 3064040 3238163 3422550 3617820 3824635 4043693 4275738 4521561 4782000 5057946 5350345 5660202 5988585 6336630 6705540 7096598 7511164 7950683 8416694 8910828 9434823 9990523 10579889 11205006 11868090 12571498 13317734 14109462 14949514/;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
182
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
183 if($city->{resources}->{gold} >= ($cargoCost[$city->{transporters}->{sum}]*5)) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
184 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
185 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
186 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
187 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
188 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
189
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
190 sub is_resource_enoghforHall {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
191 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
192 my @wood = qw/udnef 0 70 98 65 129 236 402 594 849 1176 1586 2101 3208 4937 7171 10139 14537 18420 22896 28047 33934 40623 48017 56511 226044 452088 904176 1808352 3616704 7233408 14466816 28933632/;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
193 my @marble = qw/undef 0 0 17 28 66 95 156 243 406 579 799 1348 2124 2951 4409 6461 8187 10176 12466 15082 18055 21381 25116 100464 200928 401856 803712 1607424 3214848 6429696 12859392/;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
194
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
195 my $level = $city->{buildings}->{townHall};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
196 if($city->{resources}->{wood} >= $wood[$level] && $city->{resources}->{marble} >= $marble[$level] ) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
197 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
198 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
199 warn(sprintf("Resource is short for build city hall. wood [%d] marble [%d] ", $wood[$level], $marble[$level]));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
200 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
201 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
202
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
203 sub is_expansion_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
204 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
205 # $self->{'ikariam'}->
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
206 return (defined($self->{'ikariam'}->{research}->{1030}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
207 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
208
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
209 sub is_foreigncultures_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
210 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
211 return (defined($self->{'ikariam'}->{research}->{1040}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
212 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
213
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
214 sub is_greekfire_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
215 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
216 return (defined($self->{'ikariam'}->{research}->{1060}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
217 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
218
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
219 sub is_paddlewheelengine_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
220 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
221 return (defined($self->{'ikariam'}->{research}->{1100}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
222 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
223
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
224 sub is_conservation_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
225 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
226 return (defined($self->{'ikariam'}->{research}->{2010}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
227 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
228
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
229 sub is_wealth_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
230 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
231 return (defined($self->{'ikariam'}->{research}->{2030}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
232 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
233
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
234 sub is_winepress_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
235 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
236 return (defined($self->{'ikariam'}->{research}->{2040}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
237 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
238
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
239 sub is_paper_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
240 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
241 return (defined($self->{'ikariam'}->{research}->{3020}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
242 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
243
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
244 sub is_espionage_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
245 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
246 return (defined($self->{'ikariam'}->{research}->{3030}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
247 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
248
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
249 sub is_invention_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
250 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
251 return (defined($self->{'ikariam'}->{research}->{3040}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
252 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
253
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
254 sub is_culturalexchange_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
255 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
256 return (defined($self->{'ikariam'}->{research}->{3060}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
257 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
258
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
259 sub is_professionalarmy_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
260 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
261 return (defined($self->{'ikariam'}->{research}->{4030}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
262 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
263
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
264 sub is_drydock_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
265 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
266 return (defined($self->{'ikariam'}->{research}->{4010}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
267 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
268
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
269 sub is_robotics_researched {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
270 my ($self) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
271 return (defined($self->{'ikariam'}->{research}->{4110}) ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
272 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
273
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
274 sub is_barracks_available {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
275 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
276 return 0 if(!defined($city->{buildings}->{barracks}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
277 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
278 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
279
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
280 sub is_barracks_level_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
281 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
282 return 0 if(!defined($city->{buildings}->{barracks}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
283 if($self->is_robotics_researched() eq 1) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
284 return ($city->{buildings}->{barracks} >= 24 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
285 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
286
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
287 if($city->{buildings}->{townHall} >= 10) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
288 # optimum is 5
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
289 return ($city->{buildings}->{barracks} >= 5 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
290 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
291 # 方陣兵需要 level 4
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
292 return ($city->{buildings}->{barracks} >= 4 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
293 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
294 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
295
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
296 sub is_shipyard_availble {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
297 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
298 return 0 if(!defined($city->{buildings}->{shipyard}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
299 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
300 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
301
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
302 sub is_shipyard_level_enough {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
303 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
304 return 0 if(!defined($city->{buildings}->{shipyard}));
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
305 if ($self->is_paddlewheelengine_researched() eq 1) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
306 return ($city->{buildings}->{shipyard} >= 16 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
307 } elsif ($self->is_greekfire_researched() eq 1) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
308 return ($city->{buildings}->{shipyard} >= 5 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
309 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
310 return ($city->{buildings}->{shipyard} >= 3 ? 1 : 0);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
311 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
312 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
313
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
314 sub is_shipyard_upgrading {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
315 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
316 return $self->{'ikariam'}->is_shipyard_upgrading($city->{id});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
317 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
318
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
319 sub is_navy_trainning {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
320 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
321 return $self->{'ikariam'}->is_navy_trainning($city->{id});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
322 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
323
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
324 sub train_navy {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
325 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
326 my $cityId = $city->{id};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
327 # TODO, 依照升級比例算 CP 值最高
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
328 if($self->is_greekfire_researched() eq 1 && $city->{buildings}->{shipyard} >= 5) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
329 # ok, we can build Flamethrower.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
330 if(defined($city->{'fleet'}->{Flamethrower}) && ($city->{'fleet'}->{Flamethrower} > 0)
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
331 && ($city->{'fleet'}->{BallistaShip} / $city->{'fleet'}->{Flamethrower}) <= (1.5/1)) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
332 return 213; # 強弩船
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
333 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
334 return 211; # 噴火船
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
335 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
336 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
337 return 213; # 強弩船
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
338 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
339 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
340
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
341 sub is_barracks_upgrading {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
342 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
343 return $self->{ikariam}->is_barracks_upgrading($city->{id});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
344 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
345
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
346 sub is_army_trainning {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
347 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
348 return $self->{ikariam}->is_army_trainning($city->{id});
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
349 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
350 sub train_army {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
351 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
352 my $cityId = $city->{id};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
353
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
354 # TODO, 依照升級比例算 CP 值最高
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
355 my $assault = 'Swordsman';
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
356 my $resistance = 'Phalanx';
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
357
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
358 if(($city->{'army'}->{$assault} / $city->{'army'}->{$resistance}) <= (2/1)) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
359 return 302; # Swordsman
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
360 } else {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
361 return 303; # Phalanx
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
362 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
363 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
364
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
365 # navy
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
366 sub is_navyExpenditure_available
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
367 {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
368 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
369 my $cityId = $city->{id};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
370
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
371 # move this to somewhere else.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
372 my $workersRatio = {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
373 'citizens' => 0.4,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
374 'specialworkers' => 0.3,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
375 'woodworkers' => 0.7,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
376 };
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
377
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
378 my $currentCost = $self->{'ikariam'}->getNavyExpenditure($cityId);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
379 my $netincome = $self->{'ikariam'}->getNetIncome($cityId);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
380
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
381 # 軍費為 兩成 淨收入
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
382 # 陸軍佔用 0.3
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
383 # 海軍佔用 0.7
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
384 my $militaryExpenditure = int($netincome * 0.2 * 0.7);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
385
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
386 if($currentCost < $militaryExpenditure) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
387 printf("Current navy expenditure total=%s, affordable %s\n", $currentCost, $militaryExpenditure);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
388 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
389 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
390 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
391 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
392
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
393 # army
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
394 sub is_milityExpenditure_available
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
395 {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
396 my ($self, $city) = @_;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
397 my $cityId = $city->{id};
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
398
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
399 # move this to somewhere else.
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
400 my $workersRatio = {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
401 'citizens' => 0.4,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
402 'specialworkers' => 0.3,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
403 'woodworkers' => 0.7,
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
404 };
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
405
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
406 my $currentCost = $self->{'ikariam'}->getMilityExpenditure($cityId);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
407 my $netincome = $self->{'ikariam'}->getNetIncome($cityId);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
408
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
409 # 軍費為 兩成 淨收入
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
410 # 陸軍佔用 0.3
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
411 # 海軍佔用 0.7
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
412
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
413 my $militaryExpenditure = int($netincome * 0.2 * 0.3);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
414
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
415 if($currentCost < $militaryExpenditure) {
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
416 Carp::carp("Current army expenditure total=%s, affordable %s\n", $currentCost, $militaryExpenditure);
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
417 return 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
418 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
419 return 0;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
420 }
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
421
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
422 1;
0522468991c1 added flash attacking script.
"Rex Tsai <chihchun@kalug.linux.org.tw>"
parents:
diff changeset
423