# HG changeset patch # User "Rex Tsai " # Date 1223584925 -28800 # Node ID 99723b8f348b26574bacc46c8772c82b5ff789ff # Parent dd85b55eec2a6d14d84a6758ea100b4c0503a8e6 added rule_corruption diff -r dd85b55eec2a -r 99723b8f348b Ikariam.pm --- a/Ikariam.pm Fri Oct 10 03:38:49 2008 +0800 +++ b/Ikariam.pm Fri Oct 10 04:42:05 2008 +0800 @@ -299,10 +299,11 @@ } # Space, 房屋數 + $self->{'cities'}->{$cityId}->{"space"} = {}; foreach my $j (qw/occupied total/) { my ($elem) = $html->getElementsByAttribute("class", sprintf("value %s", $j)); if(defined($elem)) { - $self->{'cities'}->{$cityId}->{"space_" . $j} = $elem->innerText(); + $self->{'cities'}->{$cityId}->{"space"}->{$j} = $elem->innerText(); } } diff -r dd85b55eec2a -r 99723b8f348b inference.pl --- a/inference.pl Fri Oct 10 03:38:49 2008 +0800 +++ b/inference.pl Fri Oct 10 04:42:05 2008 +0800 @@ -24,7 +24,7 @@ { my $id = shift; - if($cities->{$id}->{happiness} > 3) { + if($cities->{$id}->{happiness} >= 3) { Warn($id, sprintf("is not happy (%s)!", $cities->{$id}->{happiness_text})); } } @@ -36,13 +36,24 @@ # checking goods foreach my $good (qw/wood wine marble crystal/) { if($cities->{$id}->{$good} <= 100) { - Warn($id, sprintf("Running out %s!", $good)); + Warn($id, sprintf("Running out %s (%d)!", $good, $cities->{$id}->{$good})); } } } +# 貪腐 +sub rule_corruption +{ + my $id = shift; + + if($cities->{$id}->{corruption} > 0) { + Warn($id, sprintf("corruption is %d", $cities->{$id}->{corruption})); + } +} + +# space # Checking rules -foreach my $procedure (qw/rule_happiness rule_resource/) { +foreach my $procedure (qw/rule_happiness rule_corruption rule_resource/) { foreach my $id (keys(%$cities)) { eval(sprintf("%s(%s);", $procedure, $id)); }