diff Ikariam.pm @ 173:e8a244ce5a1d

update the tavern setting
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 04:12:00 +0800
parents ba03aa8abdb2
children 0cfc7a19a4d2
line wrap: on
line diff
--- a/Ikariam.pm	Sun Nov 02 00:30:02 2008 +0800
+++ b/Ikariam.pm	Sun Nov 02 04:12:00 2008 +0800
@@ -1,4 +1,3 @@
-#!/usr/bin/env perl
 BEGIN {
     foreach (((getpwuid($<))[7], $ENV{HOME}, $ENV{LOGDIR}, ".")) {
         require "$_/.eagleeye.pm" if (-f "$_/.eagleeye.pm");
@@ -373,6 +372,32 @@
     }
 }
 
+# for tavern only
+sub set {
+    my $self = shift;
+    my $type = shift;
+    my $cityId = shift;
+
+    die ("we don't know about this city") unless(defined($self->{'cities'}->{$cityId}));
+
+    my $position = -1;
+    my @locations = @{$self->{'cities'}->{$cityId}->{locations}};
+    foreach (0..$#locations) {
+        $position = $_ if($locations[$_] eq $type);
+    }
+
+     if($position != -1) {
+         $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position));
+         $self->{mech}->submit_form(
+                 form_number => 1,
+                 fields      => {
+                 amount => $self->{'cities'}->{$cityId}->{$type}->{maxValue},
+                 }
+                 );
+ 
+    }
+}
+
 sub build {
     my $self = shift;
     my $type = shift;