Skip to content

Commit 528da9a

Browse files
committed
Fix bug: Multiple lines appearing after feedback
- If user has multiple locations unlocked and does not get negative feedback then lines would still to appear as if separating locations. - Also added a messaged to appear when no negative feedback received from any location.
1 parent a815cf1 commit 528da9a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

game.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ def run_day(stats):
170170
sold_out_text, feedback, rep_score,
171171
potential_cust
172172
]
173-
save_data(stats, False)
174173
clear_terminal()
174+
# Header for sales report
175175
text = cyan("12 noon time sales report:")
176176
print(f'{text}')
177177
stats = sales_report(stats, data)
@@ -181,14 +181,14 @@ def run_day(stats):
181181
for i in range(total_locations):
182182
sold += cust_count[i]
183183
stats = deduct_stock(stats, sold)
184-
save_data(stats, False)
185184
data = [
186185
cust_count, sold,
187186
open_loc_name, loc_sale_value,
188187
sold_out_text, feedback, rep_score,
189188
potential_cust
190189
]
191190
clear_terminal()
191+
# Header for sales report
192192
text = cyan("End of day sales report:")
193193
print(f'{text}')
194194
stats = sales_report(stats, data)
@@ -214,13 +214,16 @@ def sales_report(stats, data):
214214
# rep_score = data[6]
215215
# potential_cust = data[7]
216216

217+
# If sold out of prooduct during trading, show sold out message.
217218
if data[4]:
218219
print(data[4])
219220

221+
# Add up total values from different locations.
220222
total_sale_value = 0
221223
for i in data[3]:
222224
total_sale_value += i
223225

226+
# Show sales report to user. Location, units sold, net profit.
224227
print(constants.LINE)
225228
print(f'{"Location":<13}{"-":<3}{"Units":<8}{"-":<3}{"Value (£)":<8}')
226229
print(constants.LINE)
@@ -235,21 +238,30 @@ def sales_report(stats, data):
235238
text = green(f'£{floor(total_sale_value*100)/100}')
236239
print(f'Total daily sales value: {text} (var +/- £0.01)')
237240
print('\nSales values are net profit (Sold price minus product cost).')
241+
242+
# Get user input to continue.
238243
print_press_enter_to("Press Enter to see feedback..")
244+
245+
# Customer feedback
239246
print(f'\n{cyan("Customer feedback / improvements to be made:")}')
240247
print(constants.LINE)
241248
print(f'{"Location":<13}{"-":<3}{"Amount":<7}{"-":<3}{"Comment":<13}')
242249
print(constants.LINE)
243250

244251
txt_decline = red('(Declined)')
245252

253+
# Variable to count total feedback
254+
t_count = 0
255+
246256
for count in enumerate(data[0]):
257+
f_count = 0
247258
for key in data[5]:
248259
if data[5][key][count[0]] > 0:
249260

250-
if count[0] == 0:
261+
if f_count == 0:
251262
text = data[2][count[0]]
252263
dash = "-"
264+
t_count += 1
253265
else:
254266
text = ""
255267
dash = ""
@@ -260,13 +272,17 @@ def sales_report(stats, data):
260272
text2 = f"{txt_decline} Overpriced!"
261273

262274
text3 = data[5][key][count[0]]
263-
264275
print(f'{text:<13}{dash:<3}{text3:<7}{"-":<3}{text2:<13}')
276+
f_count += 1
265277

266-
if count[0] != 0:
278+
if f_count != 0:
267279
print(constants.LINE)
268280

281+
if t_count == 0:
282+
print(green('\nNo feedback for improvment was given.'))
283+
269284
print_press_enter_to("Press Enter to see if any reputation update...\n")
285+
270286
rep_change(stats, data[6], data[7])
271287

272288
if (stats["day"] % 1) == 0:

0 commit comments

Comments
 (0)