-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
162 lines (146 loc) · 4.66 KB
/
ui.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import interaction
import engine
import main
import util
player_was_here = [
[0 for x in range(0, main.BOARD_WIDTH - 2)]
for y in range(0, main.BOARD_HEIGHT - 2)
]
def display_board(board, was_here=player_was_here):
"""
Displays complete game board on the screen
Returns:
Nothing
"""
corners = engine.room_corners
monkey = [engine.monkey["row"], engine.monkey["col"]]
FAKE_NUMBER = 100
this_rectangle = [[FAKE_NUMBER, FAKE_NUMBER], [FAKE_NUMBER, FAKE_NUMBER]]
for item in corners:
if (
item[0][0] <= monkey[0] <= item[1][0]
and item[1][1] <= monkey[1] <= item[2][1]
):
this_rectangle = item
break
row_counter = 0
current_row = monkey[0]
current_col = monkey[1]
for row in board:
show_row = ""
if this_rectangle[0][0] <= row_counter <= this_rectangle[1][0]:
col_counter = 0
for mark in row:
if this_rectangle[1][1] <= col_counter <= this_rectangle[2][1]:
show_row += mark
player_was_here[row_counter][col_counter] = 1
elif player_was_here[row_counter][col_counter] == 1:
show_row += mark
else:
show_row += " "
col_counter += 1
elif (
monkey[0] == row_counter
or current_row - 2 < row_counter < current_row + 2
):
col_counter = 0
for mark in row:
if (
current_col - 2 < col_counter < current_col + 2
and monkey[1] == col_counter
and monkey[0] == row_counter
):
show_row += mark
player_was_here[row_counter][col_counter] = 1
elif (
player_was_here[row_counter][col_counter] == 1
or current_col - 2 < col_counter < current_col + 2
):
show_row += mark
else:
show_row += " "
col_counter += 1
else:
col_counter = 0
for mark in row:
if player_was_here[row_counter][col_counter] == 1:
show_row += mark
else:
show_row += " "
col_counter += 1
print(show_row)
row_counter += 1
def display_stats():
stat = interaction.characters["hero"]
print(
f'Gracz: {stat["name"]} '
+ f'Zdrowie: {stat["live"]} '
+ f'Atak: {stat["attack"]} '
+ f'Moc: {stat["chances critical hit"]} '
+ f'Punkty: {stat["points"]}\n'
)
def display_stats_fight(stat):
print(
f'\t{stat["name"]}\n'
+ f'\tZnacznik: {stat["print_character"]}\t'
+ f'Zdrowie: {stat["live"]}\t'
+ f'Atak: {stat["attack"]} \t'
+ f'Moc: {stat["chances critical hit"]}\n'
)
def display_fight(fight_text, enemy, quit_possible=False):
"""
displayes fight screen with fight text
fight_text: string
enemy: dictionary
quit_possible: True or False
"""
util.clear_screen()
print("\n\n\tKONFRONTACJA\n")
display_stats_fight(interaction.characters["hero"])
display_stats_fight(enemy)
print(f"\t~ {fight_text}")
if quit_possible:
print(
"\n\tOpcje"
+ "\n\t[1] Wciśnij Q aby przerwac konfrontacje"
+ "\n\t[2] Wciśnij I aby użyć posiadanych przedmiotów"
+ "\n\t[3] Wciśnij dowolny klawisz aby kontynuować walkę"
)
key = util.key_pressed().lower()
if key == "q":
return False
else:
return True
else:
print(
"\n\tOpcje"
+ "\n\t[1] Wciśnij I aby użyć posiadanych przedmiotów"
+ "\n\t[2] Wciśnij dowolny klawisz aby kontynuować walkę"
)
key = util.key_pressed().lower()
return True
def display_meets(txt, quit_possible=False):
"""
displayes meets screen with text
fight_text: string
enemy: dictionary
quit_possible: True or False
"""
util.clear_screen()
print("\n\n\tSPOTYKASZ PRACOWNIKA BIEDRY\n")
print(f"\t~ {txt}")
if quit_possible:
print("\n\tOpcje" + "\n\tWciśnij Q aby przerwac konfrontacje")
key = util.key_pressed().lower()
if key == "q":
return False
else:
return True
else:
print("")
key = util.key_pressed().lower()
return True
# add opening screen with game info, story line and player setup
# add display dialog box
# add display palyer stats
# add display inventory