summaryrefslogtreecommitdiffstats
path: root/weatbag/tiles
diff options
context:
space:
mode:
Diffstat (limited to 'weatbag/tiles')
-rw-r--r--weatbag/tiles/e2.py8
-rw-r--r--weatbag/tiles/n2.py4
-rw-r--r--weatbag/tiles/n3.py67
3 files changed, 78 insertions, 1 deletions
diff --git a/weatbag/tiles/e2.py b/weatbag/tiles/e2.py
index 2a8690b..ca66475 100644
--- a/weatbag/tiles/e2.py
+++ b/weatbag/tiles/e2.py
@@ -22,6 +22,14 @@ class Tile:
def action(self, player, do):
if do[0] == "guess" and self.contents['unlit torch']:
try:
+ if do[1] == "correctly":
+ print("You sly dog, you!")
+ print("The dwarf hands you a torch! "
+ "He then suddenly vanishes, leaving behind a pile of dust.")
+ self.contents['unlit torch'] -= 1
+ player.give('unlit torch')
+ return
+
guess = int(do[1])
self.guess_count += 1
if guess > self.lucky_number:
diff --git a/weatbag/tiles/n2.py b/weatbag/tiles/n2.py
index b903ed3..a9bca43 100644
--- a/weatbag/tiles/n2.py
+++ b/weatbag/tiles/n2.py
@@ -2,7 +2,9 @@ from weatbag import words
class Tile:
def describe(self):
- print("You are standing in the mouth of a cave. The air feels cool.")
+ print("You are standing in the mouth of a cave. The air feels cool and "
+ "is filled with the stench of rotting flesh. "
+ "A dark path leads to the north. An exit to the south.")
def leave(self, player, direction):
if direction=='s':
diff --git a/weatbag/tiles/n3.py b/weatbag/tiles/n3.py
new file mode 100644
index 0000000..e0a1a4a
--- /dev/null
+++ b/weatbag/tiles/n3.py
@@ -0,0 +1,67 @@
+from weatbag import words
+import random
+
+class Tile:
+ def __init__(self):
+ self.enemy_dead = False
+ self.enemy_life = 2
+ self.player_life = 4
+
+ def describe(self):
+ if not self.enemy_dead:
+ print("You encounter an orc! He's got a mean look, but you're a "
+ "strong lad. You should be able to take him. Swing or flee?")
+ else:
+ print("You see an orc corpse here.")
+
+
+ def enemy_swing(self, player):
+ if self.enemy_dead:
+ return
+ print("The enemy takes a swing at you!")
+ hit = random.choice((True,False))
+ if hit:
+ print("He hits you!")
+ player.hit_points -= 1
+ self.report_player_state(player)
+ else:
+ print("He misses!")
+
+ def player_swing(self, player):
+ hit = random.choice((True,False))
+ if hit:
+ print("You hit him!")
+ self.enemy_life -= 1
+ else:
+ print("You miss!")
+
+ if self.enemy_life == 0:
+ print("You have killed the orc!")
+ self.enemy_dead = True
+
+ def report_player_state(self, player):
+ print("You are %s" % (player.state_string()))
+
+ def leave(self, player, direction):
+ if not self.enemy_dead:
+ if not random.choice((True,False)):
+ print("The orc blocks your way!")
+ self.enemy_swing(player)
+ return False
+ else:
+ print("You manage to flee!")
+
+ if direction=='s':
+ return True
+
+ def action(self, player, do):
+ if do[0] == "flee":
+ self.leave(player, 's')
+ return
+
+ if do[0] == "swing":
+ self.player_swing(player)
+ self.enemy_swing(player)
+
+ else:
+ print("Sorry, I don't understand")