Skip to content

Commit 7c3a19c

Browse files
committed
Small improvements
1 parent d672ae4 commit 7c3a19c

File tree

3 files changed

+66
-44
lines changed

3 files changed

+66
-44
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
11
# Wanderer
2+
3+
Short guide:
4+
5+
Every time in a location you will see in top you health points (**HP**) and what's inside your backpack (**BKPCK**)
6+
7+
Then, there will be displayed list of actions (in square brackets, **bold**) and objects (after semicolon), with which you can perform an action
8+
First of all you should enter type of action. Then, if required, you would have to specify details (\*)
9+
10+
Every time you are asked to enter something (after \>) you can see possible options above. Type exactly the same option.
11+
12+
Commands (fight, talk, take, go) are case insensitive
13+
Locations are case sensitive
14+
15+
\*If there is a single personage to talk to, to fight with or a single item to take, it won't ask specification
16+
Otherwise, after typing action, you should specify on whom/what perform an action
17+

game.py

+22-17
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
term = blessed.Terminal()
88

9-
global defeated_num
10-
defeated_num = 0
11-
129

1310
class Hero:
1411
'''
@@ -25,16 +22,14 @@ def damage(self, points):
2522
self.hp = 0
2623

2724
def recover(self, points):
25+
'''
26+
This method is not used yet, but potentially could be realized to recover health with
27+
consumables
28+
'''
2829
self.hp += points
2930
if self.hp > 100:
3031
self.hp = 100
3132

32-
def alive(self):
33-
'''
34-
Checks if hero is alive. Returns bool value True if yes (hp > 0), False otherwise
35-
'''
36-
return bool(self.hp)
37-
3833

3934
class Location:
4035
def __init__(self, name):
@@ -47,6 +42,9 @@ def set_description(self, description):
4742
self.description = description
4843

4944
def link_loc(self, loc):
45+
'''
46+
Links another location to current location. It is ignorant to direction
47+
'''
5048
self.linked_locs.append(loc)
5149

5250
def set_character(self, character):
@@ -62,6 +60,9 @@ def get_details(self):
6260
print(self.name, '-', self.description)
6361

6462
def move(self, goto_loc):
63+
'''
64+
Moves location to new
65+
'''
6566
for linked_loc in self.linked_locs:
6667
if linked_loc.name == goto_loc:
6768
return linked_loc
@@ -101,9 +102,10 @@ def set_conversation(self, conversation):
101102
self.conversation = conversation
102103

103104
def talk(self):
105+
'This method prints thesis of speacers in conversation'
104106
for thesis in self.conversation:
105107
print(thesis)
106-
time.sleep(0.075)
108+
time.sleep(0.15)
107109

108110

109111

@@ -113,17 +115,24 @@ def __init__(self, *attrs):
113115
self.passable = True
114116

115117
def set_properties(self, hp, damage):
118+
'''
119+
This method sets enemies properties: health points and damage
120+
'''
116121
self.hp = hp
117122
self.damage = damage
118123

119124
def fight(self, fight_with):
125+
'''
126+
This method returns damage, taken during the fight
127+
'''
120128
fight_damage = max(self.hp//fight_with, 1) * self.damage
121129
return fight_damage
122130

123-
def get_defeated(self):
124-
return defeated_num
125-
126131
def not_passable(self):
132+
'''
133+
This method sets passable value of enemy. If enemy is not passable, hero can\'t go
134+
further without defeating him
135+
'''
127136
self.passable = False
128137

129138
def describe(self):
@@ -134,7 +143,3 @@ def set_drop(self, item):
134143

135144
def get_drop_item(self):
136145
return self.drop_item
137-
138-
class Friend(Character):
139-
pass
140-

main.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
Main module
33
'''
44
import time
5-
import game
65
import blessed
6+
import game
77

88
term = blessed.Terminal()
99

1010
def read_conversation(filename, hero_first):
11+
'''
12+
This function reads conversations from files and returns the list of formated thesis
13+
'''
1114
conversation_list, counter = [], 0
1215
with open('./conversations/'+filename, 'r') as conv_file:
1316
for line in conv_file:
@@ -17,16 +20,21 @@ def read_conversation(filename, hero_first):
1720
counter += 1
1821

1922
return conversation_list
20-
23+
2124

2225
def main_game():
26+
'''
27+
Main function that organises the flow of the game
28+
'''
2329
print_intro_screen()
2430

2531
reception = game.Location('Reception')
26-
reception.set_description('Sheptytsky Center reception on the first floor next to entrance. With monitors, termometer and guards')
32+
reception.set_description('Sheptytsky Center reception on the first floor next to entrance.\
33+
With monitors, termometer and guards')
2734

2835
basement = game.Location('Basement')
29-
basement.set_description('Sheptytsky Center Underground Basement with lots of tables, chairs, desks and sofas to study')
36+
basement.set_description('Sheptytsky Center Underground Basement with lots of tables,\
37+
chairs, desks and sofas to study')
3038

3139
it_space = game.Location('IT Space')
3240
it_space.set_description('Basement in Academic Corps with tables and comfortable chairs')
@@ -35,13 +43,16 @@ def main_game():
3543
trapezna.set_description('Place to eat. Large room with tables')
3644

3745
striysky_park_south = game.Location('Stryiskyi Park South Side Entrance')
38-
striysky_park_south.set_description('Dark park. Nobody knows what a mistery and dangerous creatures hides inside')
46+
striysky_park_south.set_description('Dark park. Nobody knows what a mistery and dangerous\
47+
creatures hides inside')
3948

4049
railway_station = game.Location('Children Railway Station')
41-
railway_station.set_description('Forgoten and abandoned childrens railway station. Old building and trains')
50+
railway_station.set_description('Forgoten and abandoned childrens railway station.\
51+
Old building and trains')
4252

4353
striysky_park_fountain = game.Location('Stryiskyi Park Fountain')
44-
striysky_park_fountain .set_description('Fountain in Stryiskyi Park, with some infrastructure around')
54+
striysky_park_fountain.set_description('Fountain in Stryiskyi Park, with some\
55+
infrastructure around')
4556

4657

4758
luno = game.Item('LUNO')
@@ -121,30 +132,12 @@ def main_game():
121132
pencil.set_damage(20)
122133
basement.set_item(pencil)
123134

124-
# dave = game.Enemy("Dave", "A smelly zombie")
125-
# dave.set_conversation("What's up, dude! I'm hungry.")
126-
# dave.set_weakness("cheese")
127-
# dining_hall.set_character(dave)
128-
129-
# tabitha = game.Enemy("Tabitha", "An enormous spider with countless eyes and furry legs.")
130-
# tabitha.set_conversation("Sssss....I'm so bored...")
131-
# tabitha.set_weakness("book")
132-
# ballroom.set_character(tabitha)
133-
134-
# cheese = game.Item("cheese")
135-
# cheese.set_description("A large and smelly block of cheese")
136-
# ballroom.set_item(cheese)
137-
138-
# book = game.Item("book")
139-
# book.set_description("A really good book entitled 'Knitting for dummies'")
140-
# dining_hall.set_item(book)
141-
142135
current_location = basement
143136
previous_location = None
144137
backpack = {}
145138

146139

147-
while hero.alive():
140+
while True:
148141
time.sleep(0.9)
149142
print('\n')
150143
print(term.bold(f'HP: {hero.hp}'))
@@ -292,7 +285,15 @@ def main_game():
292285

293286

294287
def print_intro_screen():
295-
print('It\'s Friday, 22:17 PM. Outside is dark. You are sitting in Sheptytsky Center Basement for 5th our now in attempt to finish your project. You can\'t go home, deadline ends in 13 minutes. You wasn\'t watching at clock for a couple of hour so eventually you don\'t know time. Finally, you did it, you finished you work and glanced at clock terrified. Time to go home. In order to win you should survive and manage to go to fountain')
288+
'''
289+
This function print main screen infomation and legend
290+
'''
291+
print('It\'s Friday.', 'You are sitting in Sheptytsky Center Basement for 5 hour now\
292+
in attempt to finish your project.', 'You can\'t go home, deadline ends in 13 minutes but you still\
293+
have some work to do.', 'You wasn\'t watching at clock for a couple of hour so you don\'t\
294+
know time.', 'Finally, you did it, you finished you work and glanced at clock terrified:\
295+
it\'s 22:17 PM.', 'Outside darkness covered the streets. Time to go home.\n',
296+
'In order to win you should survive and arrive to Sheptytsky Park Fountain', sep='\n')
296297

297298

298299
if __name__ == '__main__':

0 commit comments

Comments
 (0)