blob: 7ae7b81d7906148bb87fb16aee97c454b13465d5 (
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
38
39
40
41
42
43
44
|
from weatbag import words
from weatbag.utils import transfer
class Tile:
def __init__(self):
self.contents = {'match': 42}
def describe(self):
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.")
if self.contents['match'] > 0:
print("Someone has dropped a box of matches on the ground.")
def leave(self, player, direction):
if direction=='n' and not player.has('flaming torch'):
print("You can't explore the cave without being able to see. "
"You'll need that stalwart friend of the adventurer, "
"the flaming torch.")
return False
else:
return True
def action(self, player, do):
if (do[0] in words.take) and ('matches' in do):
if transfer('match', self.contents, player.inventory, n=42):
print("You pick up the matches.")
else:
print("You've already taken the matches.")
elif (do[0] in words.use or do[0]=='light') and do[1]=='torch':
if player.has('unlit torch') and player.has('match'):
player.take('unlit torch')
player.take('match')
player.give('flaming torch')
print("The torch catches, casting a flickering light on the "
"cave walls.")
else:
print("You'll need a torch and a match.")
else:
print("Sorry, I don't understand")
test_items = ['unlit torch']
|