-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
executable file
·100 lines (78 loc) · 2.58 KB
/
game.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/python3
from hero import Beast, Character
from thing import Thing
from maze import Maze
me = Character("Герой")
enemy = Beast("Враг")
maze = Maze()
maze.read_from_file ("maze_description.txt")
x = 0
y = 0
actionVariants = {
"t": "Взять вещь", \
"h": "Ударить врага", \
"a": "Пойти влево", \
"s": "Пойти назад", \
"d": "Пойти вправо", \
"w": "Пойти вперед", \
"i": "Заглянуть в мешок", \
"m": "Открыть карту", \
"v": "Посмотреть характеристики вещи или врага", \
}
while True :
maze.move_to_room( (x, y) )
curRoom = maze.rooms[x, y]
if ( len(curRoom.thingsInRoom) > 0 ):
print("В комнате находятся:")
for thing in curRoom.thingsInRoom:
print(thing.name)
if ( len(curRoom.beastsInRoom) > 0 ):
print("А еще вылезли существа:")
for beast in curRoom.beastsInRoom:
print(beast.name)
while True:
ask = ""
for key in actionVariants:
ask += key + " : " + actionVariants[key] + "\n"
choice = input (ask)
if choice == "t":
take_thing(curRoom.thingsInRoom)
elif choice == "h":
hit_enemy(curRoom.beastsInRoom)
elif choice == "i":
look_at_invenories()
elif choice == "m":
show_map()
elif choice == "v":
show_parameters(curRoom.thingsInRoom, curRoom.beastsInRoom)
elif choice == "a":
enemy_action(curRoom.beastsInRoom)
x = x-1
continue
elif choice == "s":
enemy_action(curRoom.beastsInRoom)
y = y-1
continue
elif choice == "d":
enemy_action(curRoom.beastsInRoom)
x = x+1
continue
elif choice == "w":
enemy_action(curRoom.beastsInRoom)
y = y+1
continue
else:
print("Неизвестное действие")
pass
curRoom.get_chose(chose)
me.attacked_by (enemy)
if not me.alive :
print(me.name, "is dead")
break
print("My health=",me.health)
# enemy.attacked_by(me)
me.attack(enemy)
if not enemy.alive:
print(enemy.name, "is dead")
break
print(enemy.name,"'s health=",enemy.health)