# HG changeset patch # User "Rex Tsai " # Date 1223586940 -28800 # Node ID dbec53e754e33e4a299c1e7ee3979a25b551efb2 # Parent 99723b8f348b26574bacc46c8772c82b5ff789ff added rule_building diff -r 99723b8f348b -r dbec53e754e3 Ikariam.pm --- a/Ikariam.pm Fri Oct 10 04:42:05 2008 +0800 +++ b/Ikariam.pm Fri Oct 10 05:15:40 2008 +0800 @@ -272,6 +272,24 @@ $self->{'cities'}->{$cityId}->{$good} =~ s/,//g; } + # search locations + foreach my $i (0..14) { + my ($elem) = $html->getElementsByAttribute("id", "position" . $i); + my $building = $elem->getAttribute('class'); + if ($building ne "buildingGround land") { + $self->{'cities'}->{$cityId}->{locations}[$i] = $building; + my $span = getElementsByAttribute($elem, "class", "textLabel"); + my (undef, undef, $level) = split(/ /, $span->innerText()); + $self->{'cities'}->{$cityId}->{buildings}->{$building} = $level; + } + } + + # $res = $self->{mech}->get(sprintf('http://%s/index.php?view=townHall&id=%d', $self->{server}, $cityId)); + # gunzip \$res->content => \$content + # or die "gunzip failed: $GunzipError\n"; + + + # check townHall $res = $self->{mech}->get(sprintf('http://%s/index.php?view=townHall&id=%d', $self->{server}, $cityId)); gunzip \$res->content => \$content @@ -314,12 +332,6 @@ #
  • # -178 - #
  • - # 腐敗: - # - # 33% - # - #
  • my ($elem) = $html->getElementsByAttribute("title", "目前腐敗程度"); if(defined($elem)) { $self->{'cities'}->{$cityId}->{corruption} = $elem->innerText(); diff -r 99723b8f348b -r dbec53e754e3 inference.pl --- a/inference.pl Fri Oct 10 04:42:05 2008 +0800 +++ b/inference.pl Fri Oct 10 05:15:40 2008 +0800 @@ -41,6 +41,20 @@ } } +sub rule_building +{ + my $cityId = shift; + + # 城鎮跟圍牆 + if($cities->{$cityId}->{buildings}->{wall} < $cities->{$cityId}->{buildings}->{townHall}) { + Warn($cityId, sprintf("Wall level (%d) is lower then twon hall (%d)!", + $cities->{$cityId}->{buildings}->{wall}, + $cities->{$cityId}->{buildings}->{townHall} + )); + } + +} + # 貪腐 sub rule_corruption { @@ -53,7 +67,7 @@ # space # Checking rules -foreach my $procedure (qw/rule_happiness rule_corruption rule_resource/) { +foreach my $procedure (qw/rule_happiness rule_corruption rule_building rule_resource/) { foreach my $id (keys(%$cities)) { eval(sprintf("%s(%s);", $procedure, $id)); }