Mercurial > eagle-eye
comparison sheep.pl @ 361:81a2aeaf6bf7
refined sheep finder for 0.3.0
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 23 Feb 2009 16:26:30 +0800 |
parents | 84311fc6fe35 |
children |
comparison
equal
deleted
inserted
replaced
360:26f52b25aa06 | 361:81a2aeaf6bf7 |
---|---|
4 use Data::Dumper; | 4 use Data::Dumper; |
5 | 5 |
6 package main; | 6 package main; |
7 my $mime = Ikariam::User->retrieve ('name' => $::user); | 7 my $mime = Ikariam::User->retrieve ('name' => $::user); |
8 my $myAlly = undef; | 8 my $myAlly = undef; |
9 $myAlly = Ikariam::Ally->retrieve($mime->allyId) | 9 $myAlly = Ikariam::Ally->retrieve($mime->allyId) if(defined($mime->allyId) && $mime->allyId ne '0'); |
10 if(defined($mime->allyId) && $mime->allyId ne '0'); | |
11 | 10 |
12 # only challenge the small victims | 11 # only challenge the small victims |
13 my $army_score_main = ($mime->army_score_main / 3); | 12 # my $army_score_main = ($mime->army_score_main / 3); |
13 my $army_score_main = $mime->army_score_main; | |
14 | 14 |
15 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; | 15 my @tradegoodText = qw/NULL 葡萄酒 大理石 水晶 硫磺/; |
16 | 16 |
17 Ikariam::User->has_many(cities => 'Ikariam::Cities'); | 17 Ikariam::User->has_many(cities => 'Ikariam::Cities'); |
18 Ikariam::User->has_a(ally => 'Ikariam::Ally'); | 18 Ikariam::User->has_a(ally => 'Ikariam::Ally'); |
31 | 31 |
32 Ikariam::User->set_sql(sheeps => qq { | 32 Ikariam::User->set_sql(sheeps => qq { |
33 SELECT user.id | 33 SELECT user.id |
34 FROM user, cities | 34 FROM user, cities |
35 WHERE user.id == cities.user | 35 WHERE user.id == cities.user |
36 AND user.trader_score_secondary >= user.army_score_main*3 | 36 AND user.army_score_main <= $army_score_main |
37 AND user.army_score_main <= $army_score_main | |
38 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) | 37 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) |
39 } | 38 } |
40 ); | 39 ); |
41 | 40 |
42 sub travelTime { | 41 sub travelTime { |
73 # next if($ally->score > $myAlly->score); | 72 # next if($ally->score > $myAlly->score); |
74 # } | 73 # } |
75 # } | 74 # } |
76 # } | 75 # } |
77 | 76 |
78 next if($c->citylevel le 5); | 77 next if($mime->allyId == $sheep->allyId); |
79 next if($c->risk ge 50); | 78 next if($c->citylevel <= 5); |
79 next if($c->risk >= 50); | |
80 my $island = Ikariam::Island->retrieve($c->island); | 80 my $island = Ikariam::Island->retrieve($c->island); |
81 | |
82 | 81 |
83 $line = sprintf("%d %s score %d army %d risk %d %s/%s,", | 82 $line = sprintf("%d %s score %d army %d risk %d %s/%s,", |
84 travelTime($::x, $::y, $island->x, $island->y), | 83 travelTime($::x, $::y, $island->x, $island->y), |
85 # $capture, | 84 # $capture, |
86 $c->status, $sheep->score, $sheep->army_score_main, $c->risk, $sheep->name, $sheep->ally); | 85 $c->status, $sheep->score, $sheep->army_score_main, $c->risk, $sheep->name, $sheep->ally); |