-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRacer.py
1561 lines (1075 loc) · 33.5 KB
/
Racer.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
__version__ = '0.1.23.6' #weeding
'''Racer
(c)2017->
stOneskull'''
import pickle
from time import sleep as pause
from random import randint as d, choice
from horse import Horse
from player import U
Heart = True
def clr(lines=99):
'''print new lines'''
print('\n' * lines)
def sh(secs):
'''pause by wait'''
pause(secs * u.wait)
def shpsh(secsa, text, secsb):
sh(secsa)
print(text)
sh(secsb)
def nature():
'''temperature and moisture random'''
temp = d(7, 42)
rains = d(0, 3)
if temp < 17: feel = 'cool'
elif temp > 23: feel = 'warm'
else: feel = 'mild'
dirt = ['hard', 'soft', 'damp', 'muddy'][rains]
sky = ['clear', 'breezy', 'cloudy', 'rainy'][rains]
return {'temp': temp, 'feel': feel,
'dirt': dirt, 'sky': sky}
def saybag():
'''prints out inventory'''
clr()
print("\n You own..\n")
for thing, amount in u.bag.items():
if amount < 1: continue
amount = '' if amount == 1 else f'({amount})'
print(' ', thing, amount)
print(' ',
f'and ${u.money:.2f} cash')
return menu
def saymoney():
'''prints out player wallet value'''
u.money = round(u.money, 2)
print(f'\nYou have ${u.money:0.2f}')
def flag(theflag, hide=1):
'''hide from menu, 1 is hidden'''
u.flags[theflag] = hide
theday = 'done' # maybe.. let's check..
for v in u.flags.values():
if v == 0:
theday = 'notdone'
u.flags['sleep'] = 1
break
if theday == 'done':
u.flags['sleep'] = 0 # time for bed
def switch():
''' switch two horses next to each other
can be two spots if 9 racers'''
h = u.horses_per - 1
i = h // 4
while True:
m = d(0, h)
a = d(0, h)
if a == m: continue
if i < (m - a) or i < (a - m): continue
break
u.possy[m], u.possy[a] = u.possy[a], u.possy[m]
def startpossy():
u.possy = []
sortpossy = {}
for horse in u.lanes.values():
oddmeter = horse.odds
while oddmeter in sortpossy:
oddmeter += 0.001
sortpossy[oddmeter] = horse
oddslist = sorted(sortpossy)
u.possy.extend(sortpossy[oddz] for oddz in oddslist)
def startrace():
startpossy()
switch()
switch()
switch()
sh(2)
clr(3)
print()
sh(1.5)
print()
print('A', u.weather['feel'], u.today, 'afternoon at the races!')
sh(2)
clr()
sh(1.5)
print('\n\n The horses shake their legs..')
sh(1.5)
print('\n and begin their equine dance')
sh(1.5)
print('\n across the', u.weather['dirt'], 'track..\n\n')
sh(2.3)
clr()
print('Out of the gate..')
sh(2.3)
def possy(horses, halt=0):
'''create order of horses in a list,
halt 1 won't check diffs from last list'''
if u.seggy == 1: # if start of race
startrace()
else:
shuffler = shuffle()
u.possy = []
pointlist = sorted(shuffler)
pointlist.reverse()
u.possy.extend(shuffler[each] for each in pointlist)
switch()
if halt == 0:
diffs(horses)
def diffs(oldpossy):
'''working out the difference of horse position
between race legs for commentating'''
diffsdict = {
horse: oldpossy.index(horse) - position
for position, horse in enumerate(u.possy)
if horse != oldpossy[position]
}
# change is the old position in the possy minus the new position
# third place to fifth would be change of minus two
# send diffs to updown func to commentate position changes
updown(diffsdict)
shpsh(1.5, '\n', 0)
for position, horsey in enumerate(u.possy):
print(f'{position + 1}: {horsey}', end=" ")
print(' <-- your horse') if horsey in u.ticket else print()
shpsh(1, '', 2.3)
def bye():
'''wave'''
input('Ready?\n')
clr()
u.wait = 1
shpsh(0, '\n you think about your life in the gutter..', 2)
shpsh(1, f'\n and these last {u.day} days of the groundhog grind..', 0)
shpsh(2, "\n it's time to move on..", 3)
shpsh(1, '\n and be..', 3)
print('\n\n !0! ! !Happy Happy Ever After! ! !0!')
shpsh(5, '\n\namazing game...', 5)
say = input('\n howzat?\n ')
print('\n\n indeed..', say)
sh(2)
return gameover
def odds(horse):
'''secret bookie formula'''
theodds = horse.rank / 2 + 1.23
changer = d(-23, 23)
if changer == 0: changer = 0.01
else: changer *= 0.007
changer += 1
theodds *= changer
horse.odds = theodds
horse.oddstring = f'{round(theodds, 1):05.2f}'
def startnhalf():
'''extra commentary at beginning of race
and halfway if there is a second lap'''
if u.seggy == 5:
clr()
print('\n..at the halfway mark now..')
sh(2)
for position, horsey in enumerate(u.possy):
if position == 0:
if u.seggy == 1:
print(choice([
f'\n {horsey} has a tops start..',
f'\n {horsey} has an ace start..',
f"\n out in front it's {horsey}",
]))
else:
print(choice([
f'\n {horsey} is in the lead..',
f'\n {horsey} is leading the pack..',
f"\n out in front it's {horsey}",
]))
elif position == 1:
print(choice([
f'just followed by {horsey}',
f"in second place it's {horsey}",
f'{horsey} is just behind in second',
]))
elif position == 2:
print(choice([
f'{horsey} in third',
f' and {horsey}',
]))
elif horsey == u.possy[-1]:
print(choice([
f' and it\'s {horsey} in last place',
f' and in last.. it\'s {horsey}',
f' with {horsey} in the rear',
]))
else:
print(choice([
f' followed by {horsey}',
f' and then {horsey}',
f" then it's {horsey}",
]))
sh(1.8)
sh(2.5); clr(3)
def laneresistance(horse, lane):
return(
u.horses_per - lane < 2 and horse.weakness == 4 or
lane < 3 and horse.weakness == 3
)
def veryhot(horse):
return horse.weakness == 1 and u.weather['temp'] > 33
def hot(horse):
return horse.weakness == 1 and u.weather['temp'] > 26
def damptrack(horse):
return horse.weakness == 2 and u.weather['dirt'] == 'damp'
def muddytrack(horse):
return horse.weakness == 2 and u.weather['dirt'] == 'muddy'
def lanestrength(horse, lane):
return(
u.horses_per - lane < 2 and horse.secret == 4
or (lane < 3 and horse.secret == 3)
)
def hotstrength(horse):
return horse.secret == 1 and u.weather['temp'] > 33
def warmstrength(horse):
return horse.secret == 1 and u.weather['temp'] > 26
def dampstrength(horse):
return horse.secret == 2 and u.weather['dirt'] == 'damp'
def muddystrength(horse):
return horse.secret == 2 and u.weather['dirt'] == 'muddy'
def checkhorseweakness(horse, lane):
if laneresistance(horse, lane):
horse.rise('speed', d(-4, 0))
elif veryhot(horse):
if d(0,1): horse.rise('str', d(-4, -2))
else: horse.rise('both', d(-2, -1))
elif hot(horse):
horse.rise('both', d(-2, 1))
elif damptrack(horse):
if d(0, 1) == 1: horse.rise('str', d(0, 1))
else: horse.rise('speed', d(-2, -1))
elif muddytrack(horse):
if d(0, 1) == 1: horse.rise('str', d(0, 1))
else: horse.rise('speed', 0 - d(2, 3))
def checkhorsestrength(horse, lane):
if lanestrength(horse, lane):
horse.rise('speed', d(0, 2))
elif hotstrength(horse):
if d(0, 1) == 1:
horse.rise('both', d(0, 1))
else: horse.rise('str', d(0, 2))
elif warmstrength(horse):
if d(0, 1) == 1:
horse.rise('str', d(0, 1))
else: horse.rise('both', d(0, 1))
elif dampstrength(horse):
if d(0, 1) == 1:
horse.rise('str', 1)
else: horse.rise('speed', 1)
elif muddystrength(horse):
if d(0, 1) == 1:
horse.rise('both', 1)
else: horse.rise('str', 1)
def otherhorsechecks(horse):
if u.seggy > 5 and horse.strength > 90:
horse.rise('speed', 1)
horse.rise('str', -1)
elif u.seggy > 4 and horse.strength in range(80, 90):
horse.rise('speed', 1)
if horse.strength < 70 and horse.speed > 70:
horse.rise('str', d(1, 2))
horse.rise('speed', d(-1, 0))
if horse.speed < 70 and horse.strength > 70:
horse.rise('speed', d(1, 2))
horse.rise('str', d(-2, 0))
if u.seggy > 6 and horse.strength > 75 and horse.speed < 75:
horse.speed += horse.speed * 0.023
def shuffle():
'''monitor conditions through race'''
shuffler = {}
for lane, horse in u.lanes.items():
points = horse.trackpoints * 0.23
strength = horse.strength
speed = horse.speed
checkhorseweakness(horse, lane)
checkhorsestrength(horse, lane)
otherhorsechecks(horse)
horse.strength += horse.strength * 0.023
horse.trackpoints += (horse.strength - strength)
horse.trackpoints += (horse.speed - speed)
points += horse.trackpoints * 0.23
while points in shuffler:
points += 0.01
shuffler[points] = horse
return shuffler
def shufflepossy(say=''):
possy(u.possy, halt=1)
clr()
print(say)
def raceroutine(segments):
'''take in race legs and direct each leg accordingly'''
for segment in range(segments):
u.seggy = segment + 1
clr()
if u.seggy == segments:
segger = 'last'
else:
segs = {1: 'first', 2: 'second', 3: 'third', 4: 'fourth',
5: 'fifth', 6: 'sixth', 7: 'seventh'}
segger = segs[u.seggy]
# check for action depending on segment
if segger == 'first':
possy(u.lanes.values())
startnhalf()
elif u.seggy == segments: # if last leg
shufflepossy()
elif u.seggy == 5: # if into a second lap
startnhalf()
else:
possy(u.possy)
if u.seggy <= segments:
print(f'\n Into the {segger} turn..')
shpsh(1, ' ~-------------------------~\n', 2)
if u.seggy == segments - 1: # if second last segment
clr()
possy(u.possy)
if segger == 'last':
shufflepossy('\nOh ho ho..')
print(' The final leg..')
print()
shpsh(2, f'\nIn front is {u.possy[0]}', 1)
print(f"\n In second it's {u.possy[1]}")
shpsh(1, f'\n In third is {u.possy[2]}', 2.3)
shufflepossy('\nComing in toward the finish line..')
shpsh(1.5, f"\n it's {u.possy[0]}..", 1.2)
print(f"\n just in front of {u.possy[1]}..")
shpsh(1.2, f'\n with {u.possy[2]} just behind them', 3)
clr()
print('\nThe horses pass the post..')
shpsh(1, "\nIt's all over..", 3)
shufflepossy()
for position, horsey in enumerate(u.possy):
horsey.runs += 1
if position == 0:
print(f'\n\nWinner is {horsey}!\n')
sh(3)
print(f'{position + 1}: {horsey}', end=" ")
print(' <-- your horse') if horsey in u.ticket else print()
sh(1)
clr(2)
sh(1.5)
def updown(diffsdict):
'''horse and the position changed put into the commentary'''
for h, v in diffsdict.items():
s = 'spot' if v in (-1, 1) else 'spots'
if v > 4: m = 'leaps'
elif v > 2: m = 'jumps'
elif v < -4: m = 'slides'
elif v < -2: m = 'slips'
else: m = 'moves'
e = u.possy.index(h) + 1
if e < 4:
r = {1: 'into first', 2: 'into second', 3: 'into third'}[e]
elif u.possy[-1] == h:
r = 'into last'
else: r = '..'
if v < 0:
a = str(v)[1:]
c = ' \\/'
t = 'back'
else:
a = str(v)
c = '/\\'
t = 'up'
print(c, h, m, a, s, t, r)
sh(1.4)
def veryhothorse(horse):
pass
def hothorse(horse):
horse.rise('both', -3)
if d(0, 1) == 1:
print(' There is a little delay..',
horse, 'looks a little weak..')
horse.rise('both', -2)
sh(d(3, 5))
def resistance(horse):
horse.rise('speed', -3)
if d(0, 1) == 1:
print(' There is a little delay as',
horse, 'resists')
horse.rise('both', -2)
sh(d(3, 5))
def waitclearsaywait(say, wait=0):
sh(3)
clr()
print(say)
sh(wait)
def race():
'''at the track and the race is about to begin'''
clr()
print(f'On this {u.weather["feel"]}, {u.weather["sky"]} {u.today}...')
print(f'We have {u.horses_per} racers.')
for horse, thebet in u.ticket.items():
money = 'bucks'
if thebet == 1: money = 'dollar'
print(f'\nYou have {thebet} {money} bet on {horse}')
input('\nReady? \n')
clr()
sh(2)
print(' The horses are led into their stalls.')
sh(3)
# weaknesses.. 1 - hot, 2 - wet, 3 - inside, 4 - outside
for lane, horse in u.lanes.items():
print(f'\n {horse} enters stall {lane}')
sh(1.5)
if laneresistance(horse, lane):
resistance(horse)
elif hot(horse):
hothorse(horse)
elif horse.weakness == 2 and u.weather['dirt'] == 'wet':
horse.rise('str', -3)
if d(0, 1) == 1:
print(' There is a little delay..',
horse, 'is taking its time..')
horse.rise('both', -2)
sh(d(3, 5))
waitclearsaywait(
'''
The horses are in the blocks..
We're awaiting the starting gun..
''',
2,
)
for _ in range(d(5, 10)):
print('.')
sh(1)
clr(2)
print(' !! Honk !!')
clr(2)
waitclearsaywait(
'\nThe stall gates open and the horses are off and racing!', 3
)
segments = u.laps * 4
raceroutine(segments)
def sleep():
'''zzZ'''
shpsh(2, '\n sleep time..\n', 1)
for _z in range(d(6, 9)):
for _zz in range(d(2, 7)):
print('.', end="")
print('...zzZ..'); sh(d(0, 2))
print('\n' * d(0, 1))
for theflag in u.flags: u.flags[theflag] = 0
flag('guide')
flag('bookie')
return game
def trackdetails():
print('track details..\n')
print(' track:', u.weather['dirt'])
print(' weather:', u.weather['feel'], '&', u.weather['sky'])
flag('track') # track now closes until bet made
laps = 'lap' if u.laps == 1 else 'laps'
print(f'\ntoday, {u.today.lower()}:')
print(f'there will be {u.laps} {laps} of the track for the race')
return menu
def track():
'''if no bets: show info about track
otherwise: race()!'''
clr()
if u.betyet == 0:
return trackdetails
race()
shpsh(2, '\n amazing race...', 3)
u.flags['bookie'] = 0 # bookie opens again
flag('track') # after race, track closes access for the day
return menu
def clues(five):
'''fivespys'''
letter = 'tad'
word = f'{letter}.'
word += letter
word = word[::-1]
wordtoyomama = 'word'
spy = get(word)
return spy[five]
def endings(something):
flag('options')
flag('garden')
return something
def clue():
'''garden adventures'''
something = ("\nDid you know it's already " +
"into the 26th century in Buddhism?\n")
if u.clued == 1:
u.clued = 0
u.met = 0
if u.met == 0:
u.meetnext = [person for person in u.meet if u.meet[person][1] == 0]
they = 'The person'
someone = 'a person'
else:
someone = u.someone
they = 'She' if someone == 'May Lee' else 'He'
if u.nexts > 2:
if u.ends < 3:
flag('garden')
return sumting(something)
elif u.money < 2350:
flag('garden')
u.ends = 2
u.nexts = 2
return something
u.bye = 1
return ('\nThere is a limo standing by the garden entrance.' +
'\nThe passenger window slides down' + '\nMay Lee gestures'
+ '\nIt is time.')
if not u.meetnext and u.met == 0: # no more unmet peeps, all done
u.clued = 2
u.met = 2
return endings(something)
elif u.met == 0:
meeter = choice(u.meetnext)
u.meetnext.remove(meeter)
u.meet[meeter][1] = 1
u.someone = u.meet[meeter][0]
u.met = 1
sh(2)
print(f'''
You see {someone} sitting on a wooden bench.
{they} gestures. You approach.''')
sh(2)
if someone == 'a person':
sayhi(they)
else:
sh(2)
print(f'''\n {they} asks:
Have you got the answer yet?''')
something = '\nYou keep the clue in your pocket..\n'
sh(2)
if d(1, 3) != 3:
silver = input('\nSolve the clue? y/n -> ')
if 'n' not in silver.lower():
if d(1, 3) == 1:
something = gotcha()
else:
print(' no. not this time..')
sh(2)
return endings(something)
def gotcha():
u.clued = 1
u.clues += 1
u.met = 0
u.bag['clues'] = 0
sh(1)
print(clues(u.clues))
return "\nCool bananas!\n"
def sayhi(they):
print(f" {they} says: I have a clue for you")
sh(2)
print(f'\n My name is {u.someone}')
sh(1.5)
print(" Come see me when you're ready")
u.bag['clues'] = 1
def getguide():
sh(2.3)
print('''
You find today's newspaper sitting on a wooden bench.
The story of the criminal underworld war continues...
There is a racing guide in the paper. You take it.
''')
u.bag['guide'] = 1
u.flags['guide'] = 0 # guide available
u.flags['bookie'] = 0 # bookie open
sh(2)
def findmoney():
sh(1.5)
lucky = d(1, 10)
if lucky == 1:
print(' You find a dollar.')
else:
print(' You find', lucky, 'dollars.')
u.money += lucky
sh(1.5); saymoney(); sh(1.5)
def garden():
'''a little place to get away'''
clr()
print('''
Outside your home on the east of the tunnel..
This is a special garden area,
created by the local Chinese community
Many lovely trees to sit under
Nice place to meditate and think
''')
sh(2.3)
if u.money < 4 and u.betyet == 0:
findmoney()
if u.betyet == 0 and u.flags['guide'] == 1 and u.bye != 1:
getguide()
if u.met == 2 and u.bye != 1:
if u.nexts > 2:
something = clue()
sh(1.5)
for line in something.splitlines():
sh(1.5)
print('\n'+line)
sh(3)
else:
print('\n You feel a presence here.'); sh(1.5)
print(choice([' .. there is a sweet flower smell ..\n',
' .. you sense a warmth nearby ..\n',
' .. you feel a shiver, your hairs bristle ..\n']))
u.nexts += 1
flag('garden')
flag('options')
if (u.betyet == 1 and u.flags['track'] == 1
and u.flags['bookie'] == 1):
something = clue()
sh(1.5); print(something); sh(3)
return bye if u.bye == 1 else menu
def guide():
'''show list of horses and their odds
on picking a horse, show bio about horse'''
clr()
print(u.today)
print("\nLet's see who's racing today..\n")
print(' Lanes - Odds - Horse\n')
for lane in u.lanes:
pony = u.lanes[lane]
theodds = pony.oddstring
ponynum = f'{pony.number:02d}'
name = pony.name
note = pony.notice
print(
f'Lane {lane:02d} - [{theodds}] <{ponynum}> {name} {note}'
)
lane = 23
print('\nEnter lane number to view horse details')
while lane - 1 not in range(u.horses_per) and lane != 0:
try: lane = int(input('type 0 to close guide\n'))
except: continue
if lane != 0:
return bio(lane)
clr()
return menu
def betdone():
'''finished with bookie, track opens, get a ticket'''
u.betyet = 1
u.flags['track'] = 0
flag('bookie')
sh(1.5)
print('\n You no longer need the guide.')
sh(1.5)
print('\n You trash it on the way out of the bookie tent.\n')
del u.bag['guide']
flag('guide')
u.bag['ticket'] = 1
def bet(lane):
'''at the bookie, making a bet'''
horse = u.lanes[lane]
while True:
print('\nYou are betting on %s' % horse)
print('Enter 0 to cancel bet')
saymoney()
try:
thebet = int(input('\nHow much to bet? '))
except Exception:
print('''
We cannot accept cents for bets.
We apologise for the inconvenience.
Only whole numbers please.
''')
continue
if thebet > u.money:
print("\n You don't have enough money")
continue
if thebet < 0:
print("\n That doesn't work")
continue
if thebet == 0: return bookie
u.ticket[horse] = thebet
u.money -= thebet
print('\n Ticket:', u.ticket)
if len(u.ticket) < u.bets and u.money >= 1:
print('\n You may bet on another horse')
if input(' Enter 1 to bet again. ') == '1':
return bookie
betdone()
return menu
def checkticket():
flag('bookie')
print(f'\nYour ticket: {u.ticket}')
winner = u.possy[0]
winner.wins += 1
print(f'\nWinner: {winner}')
if winner in u.ticket: uwin(winner)
else: shpsh(2, '\nBetter luck tomorrow..', 0)
u.bag['ticket'] = 0
def uwin(winner):
sh(5)
print('\n !! ! !! ! Winner ! !! ! !!')
sh(3)
saymoney()
sh(3)
a = u.ticket[winner] * winner.odds
winnings = round(a, 2)
u.money += winnings
print(f'\nYou receive ${winnings:0.2f}!')