blob: 156c1f8381a4d1298ca35ae8166eb823a685b8b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
oo::class create player {
constructor {} {
my variable satiation
set satiation 100
}
method status {} {
my variable satiation
return "Satiation: $satiation"
}
method died {} {
my variable satiation
return [expr $satiation <= 0]
}
method update {} {
my variable satiation
incr satiation -2
}
method eat {food} {
if {$food != ""} {
my variable satiation
set satiation [expr min($satiation + [$food value], 100)]
$food eat
} else {
puts "The town has no food."
}
}
method work {amount} {
my variable satiation
set satiation [expr $satiation - $amount]
puts "You wipe the sweat from your brow."
}
}
|