Mercurial > eagle-eye
changeset 30:de5de6d472f9
added space checking
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 10 Oct 2008 05:24:04 +0800 |
parents | dbec53e754e3 |
children | e992576ac97c |
files | Ikariam.pm inference.pl |
diffstat | 2 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Ikariam.pm Fri Oct 10 05:15:40 2008 +0800 +++ b/Ikariam.pm Fri Oct 10 05:24:04 2008 +0800 @@ -265,6 +265,10 @@ my ($elem) = $html->getElementsByAttribute("class", "city"); $self->{'cities'}->{$cityId}->{name} = $elem->innerText(); + my ($elem) = $html->getElementsByAttribute("class", 'constructionSite'); + $self->{'cities'}->{$cityId}->{construction} = 0; + $self->{'cities'}->{$cityId}->{construction} = 1 if(defined($elem)); + # check goods foreach my $good (qw/wood wine marble crystal sulfur/) { my ($elem) = $html->getElementsByAttribute("id", "value_" . $good);
--- a/inference.pl Fri Oct 10 05:15:40 2008 +0800 +++ b/inference.pl Fri Oct 10 05:24:04 2008 +0800 @@ -47,12 +47,25 @@ # 城鎮跟圍牆 if($cities->{$cityId}->{buildings}->{wall} < $cities->{$cityId}->{buildings}->{townHall}) { - Warn($cityId, sprintf("Wall level (%d) is lower then twon hall (%d)!", + Warn($cityId, sprintf("Wall level (%d) is lower then town hall (%d)!", $cities->{$cityId}->{buildings}->{wall}, $cities->{$cityId}->{buildings}->{townHall} )); } +} +sub rule_space +{ + my $cityId = shift; + + if($cities->{$cityId}->{space}->{total} == $cities->{$cityId}->{space}->{occupied}) + { + Warn($cityId, sprintf("your space is full, upgraded the hall")) if($cities->{$cityId}->{construction} != 1) + } +} + +sub rule_engagement +{ } # 貪腐 @@ -67,7 +80,7 @@ # space # Checking rules -foreach my $procedure (qw/rule_happiness rule_corruption rule_building rule_resource/) { +foreach my $procedure (qw/rule_happiness rule_corruption rule_building rule_space rule_resource/) { foreach my $id (keys(%$cities)) { eval(sprintf("%s(%s);", $procedure, $id)); }