-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex42a.py~
57 lines (45 loc) · 1.45 KB
/
ex42a.py~
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
45
46
47
48
49
50
51
52
53
54
55
56
57
#game with at least 2 classes: Map and Engine (when its done :)
#now i exported each room to it's own class
from sys import exit
from random import randint
import ex42princess as prin
import ex42koi as koi
import ex42bear as bear
import ex42gate as gate
class Map(object):
def __init__(self,start):
self.start=start
self.plh=prin.PrincessLivesHere()
self.gkp=koi.GoldKoiPond()
self.bws=bear.BearWithSword()
self.big=gate.BigIronGate()
class Engine(object):
def __init__(self,game_map):
self.quips = ["You died. You kinda suck at this.",
"Your mom would be proud. If she were smarter.",
"Such a loser.",
"I have a small puppy that's better at this."]
self.map=game_map
def death(self):
print self.quips[randint(0,len(self.quips)-1)]
exit(1)
def princess_lives_here(self):
self.plh.room()
return self.plh.go_to_next_room()
def gold_koi_pond(self):
self.gkp.room()
return self.gkp.go_to_next_room()
def bear_with_sword(self):
self.bws.room()
return self.bws.go_to_next_room()
def big_iron_gate(self):
self.big.room()
return self.big.go_to_next_room()
def play(self):
next = self.start
while True:
room=getattr(self,next)
next = room()
game_map=Map("princess_lives_here")
game=Engine(game_map)
game.play()