Mercurial > eagle-eye
changeset 240:937fc672df56
count by Ally's score
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 07 Nov 2008 15:01:11 +0800 |
parents | 38e1a82627a9 |
children | 64549ddddf4a |
files | Ikariam.pm ikariam.sql sheep.pl |
diffstat | 3 files changed, 18 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/Ikariam.pm Fri Nov 07 11:46:03 2008 +0800 +++ b/Ikariam.pm Fri Nov 07 15:01:11 2008 +0800 @@ -140,6 +140,10 @@ $ally{'id'} = $allyId; $ally{'name'} = $extractor->find("//table[\@id='allyinfo']/tr[1]/td[2]/text()"); $ally{'members'} = $extractor->find("//table[\@id='allyinfo']/tr[2]/td[2]/text()"); + $ally{'score'} = $extractor->find("//table[\@id='allyinfo']/tr[4]/td[2]/text()"); + $ally{'score'} =~ s/\d+ \(([\d,]+)\)/$1/; + $ally{'score'} =~ s/,//g; + $ally{'url'} = $extractor->find("//table[\@id='allyinfo']/tr[5]/td[2]/text()"); delete($ally{'url'}) if($ally{'url'} eq '-');
--- a/ikariam.sql Fri Nov 07 11:46:03 2008 +0800 +++ b/ikariam.sql Fri Nov 07 15:01:11 2008 +0800 @@ -1,4 +1,4 @@ -CREATE TABLE "ally" ("id" INTEGER PRIMARY KEY NOT NULL , "name" TEXT, "members" INTEGER, "url" TEXT, "time" DATETIME); +CREATE TABLE "ally" ("id" INTEGER PRIMARY KEY NOT NULL , "name" TEXT, "members" INTEGER, "url" TEXT, "time" DATETIME, "score" INTEGER); CREATE TABLE "cities" ( cityId INTEGER PRIMARY KEY UNIQUE, citylevel INTEGER, cityname TEXT, user INTEGER, owner TEXT, ally TEXT, island INTEGER, "status" CHAR, "time" INTEGER, "allyId" INTEGER); CREATE TABLE "island" ( id BIGINT PRIMARY KEY UNIQUE, x INTEGER, y INTEGER, name TEXT, tradegood INTEGER, wonder INTEGER, people INTEGER, "time" INTEGER); CREATE TABLE "report" ("id" INTEGER PRIMARY KEY NOT NULL , "cityLevel" INTEGER, "wallLevel" INTEGER, "attacker" TEXT, "defender" TEXT, "winner" TEXT, "targetCity" TEXT, "island" INTEGER NOT NULL , "city" INTEGER NOT NULL , "gold" INTEGER DEFAULT 0, "wood" INTEGER DEFAULT 0, "crystal" INTEGER DEFAULT 0, "wine" INTEGER DEFAULT 0, "sulfur" INTEGER DEFAULT 0, "date" DATETIME, "time" DATETIME);
--- a/sheep.pl Fri Nov 07 11:46:03 2008 +0800 +++ b/sheep.pl Fri Nov 07 15:01:11 2008 +0800 @@ -5,6 +5,10 @@ package main; my $mime = Ikariam::User->retrieve ('name' => $::user); +my $myAlly = undef; +$myAlly = Ikariam::Ally->retrieve($mime->allyId) + if(defined($mime->allyId) && $mime->allyId ne '0'); + # only challenge the small victims my $army_score_main = ($mime->army_score_main / 3); @@ -45,14 +49,6 @@ # avoid duplicate next if($sheep->id == $s); $s = $sheep->id; - # 查聯盟數量 - my $members = 1; - unless ($sheep->allyId == '0') { - unless (!defined($sheep->allyId) || $sheep->allyId == 0) { - my $ally = Ikariam::Ally->retrieve($sheep->allyId); - $members = $ally->members; - } - } foreach my $c ($sheep->cities) { my $line = ""; @@ -60,9 +56,13 @@ next if($c->status eq 'v'); unless($c->status eq 'i') { - # Ignore 聯盟人數大於五 - # TODO 應該依照影響力來分 - next if($members > 10); + # 依照影響力區分 + unless ($sheep->allyId == '0') { + unless (!defined($sheep->allyId) || $sheep->allyId == 0) { + my $ally = Ikariam::Ally->retrieve($sheep->allyId); + next if($ally->score > $myAlly->score); + } + } } my $island = Ikariam::Island->retrieve($c->island); @@ -75,9 +75,9 @@ # 測試風險評估 # $capture = $capture - ($sheep->army_score_main*100); - $line = sprintf("%d %s score %d army %d %s/%s(%d),", + $line = sprintf("%d %s score %d army %d %s/%s,", $capture, - $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally, $members); + $c->status, $sheep->score, $sheep->army_score_main, $sheep->name, $sheep->ally); $line .= sprintf("\"%s\" %d [%d,%d] %s http://%s/index.php?view=island&id=%d&selectCity=%d\n", $c->cityname, $c->citylevel,