Mercurial > eagle-eye
comparison inference.pl @ 28:99723b8f348b
added rule_corruption
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Fri, 10 Oct 2008 04:42:05 +0800 |
parents | dd85b55eec2a |
children | dbec53e754e3 |
comparison
equal
deleted
inserted
replaced
27:dd85b55eec2a | 28:99723b8f348b |
---|---|
22 | 22 |
23 sub rule_happiness | 23 sub rule_happiness |
24 { | 24 { |
25 my $id = shift; | 25 my $id = shift; |
26 | 26 |
27 if($cities->{$id}->{happiness} > 3) { | 27 if($cities->{$id}->{happiness} >= 3) { |
28 Warn($id, sprintf("is not happy (%s)!", $cities->{$id}->{happiness_text})); | 28 Warn($id, sprintf("is not happy (%s)!", $cities->{$id}->{happiness_text})); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 sub rule_resource | 32 sub rule_resource |
34 my $id = shift; | 34 my $id = shift; |
35 | 35 |
36 # checking goods | 36 # checking goods |
37 foreach my $good (qw/wood wine marble crystal/) { | 37 foreach my $good (qw/wood wine marble crystal/) { |
38 if($cities->{$id}->{$good} <= 100) { | 38 if($cities->{$id}->{$good} <= 100) { |
39 Warn($id, sprintf("Running out %s!", $good)); | 39 Warn($id, sprintf("Running out %s (%d)!", $good, $cities->{$id}->{$good})); |
40 } | 40 } |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 # 貪腐 | |
45 sub rule_corruption | |
46 { | |
47 my $id = shift; | |
48 | |
49 if($cities->{$id}->{corruption} > 0) { | |
50 Warn($id, sprintf("corruption is %d", $cities->{$id}->{corruption})); | |
51 } | |
52 } | |
53 | |
54 # space | |
44 # Checking rules | 55 # Checking rules |
45 foreach my $procedure (qw/rule_happiness rule_resource/) { | 56 foreach my $procedure (qw/rule_happiness rule_corruption rule_resource/) { |
46 foreach my $id (keys(%$cities)) { | 57 foreach my $id (keys(%$cities)) { |
47 eval(sprintf("%s(%s);", $procedure, $id)); | 58 eval(sprintf("%s(%s);", $procedure, $id)); |
48 } | 59 } |
49 } | 60 } |