diff options
author | Nat Lasseter <user@4574.co.uk> | 2021-07-06 21:25:00 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2021-07-06 21:25:00 +0100 |
commit | 8619785617eb73f8a4246c69b115b76769130d6f (patch) | |
tree | 07cd1b52eb7024c19fa00ea742d60d46d8195fac /player.tcl |
Diffstat (limited to 'player.tcl')
-rw-r--r-- | player.tcl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/player.tcl b/player.tcl new file mode 100644 index 0000000..156c1f8 --- /dev/null +++ b/player.tcl @@ -0,0 +1,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." + } +} |