-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
1290 lines (1066 loc) · 46.6 KB
/
main.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
import pickle
import random as r
import discord
from discord.ext import commands
from item import *
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True
client = commands.Bot(command_prefix=".", intents=intents)
client.remove_command('help')
# Credit to Eshaan for assisting with enums as well as the player class and the item list.
"""
Notes for future interactivity update
for cornucopia allow each player to declare intent (whcih item they're going for, whether theyre staying or not, whether they team, etc)
Note- for balance update, ctrl f .set_stat( and adjust as necessary.
Note- for next update try to al,;..................,,,,,,,,,dd in weapons during standard battles.
"""
@client.event
async def on_ready():
await client.change_presence(activity=discord.Game(name='being one buggy mfer'))
print("Ready")
class stats(enum.Enum):
STR = 'S'
CHA = 'C'
WIS = 'W'
DEX = 'D'
CON = 'C'
Names = [
"Bob1", "Bob2", "Bob3", "Bob4", "Bob5", "Bob6", "Bob7", "Bob8", "Bo1b9",
"Bob10", "Bob11", "Bob12", "Bob13", "Bob14", "Bob15", "Bob16", "Bob17",
"Bob18", "Bob19", "Bob20", "Bob21", "Bob22", "Bob23", "Bob24"
]
old_stats = [
"STR", "DEX", "CON", "WIS", "WIS", "CHA", "STR", "DEX", "CON", "WIS",
"WIS", "CHA", "STR", "DEX", "CON", "WIS", "WIS", "CHA", "STR", "DEX",
"CON", "WIS", "WIS", "CHA"
]
s_stats = [
stats.STR, stats.DEX, stats.CON, stats.WIS, stats.WIS, stats.CHA,
stats.STR, stats.DEX, stats.CON, stats.WIS, stats.WIS, stats.CHA,
stats.STR, stats.DEX, stats.CON, stats.WIS, stats.WIS, stats.CHA,
stats.STR, stats.DEX, stats.CON, stats.WIS, stats.WIS, stats.CHA
]
# await ctx.send(s_stats)
class Player(object):
def __init__(self, name, constant_of_survival, strong_stat, npc):
self.is_busy = False
self.item_list = []
self.name = name
self.constant_of_survival = constant_of_survival
self.strong_stat = strong_stat
self.npc = npc
self.is_alive = True
self.has_crafted = False
def get_name(self):
return self.name
def get_busy(self):
return self.is_busy
def set_busy(self, new_busy):
self.busy = new_busy
return self.busy
def __str__(self):
return (self.name)
def get_const(self):
return self.constant_of_survival
def set_const(self, change):
# REMEMBER TO PUT SIGN WHEN CALLING
self.constant_of_survival = self.constant_of_survival + change
def get_stat(self):
return self.strong_stat
def set_stat(self, new_stat):
self.strong_stat = new_stat
return self.strong_stat
def is_npc(self):
# WORK ON THIS
return self.npc
# WORK ON THIS ^^
def give_item(self, item):
self.item_list.append(item)
return item
def get_items(self):
return self.item_list
def get_items_enums(self):
y = []
print(self.item_list)
for i in self.item_list:
y.append(i.value())
return y
def set_list(self, item):
self.item_list = item
def get_alive(self):
return self.is_alive
def set_alive(self, life):
# life should be a bool
self.is_alive = life
def get_crafted(self):
return self.has_crafted
def set_crafted(self, crafted):
self.has_crafted = crafted
# remember to put in teams later
class Team(object):
pass
# TODO: rewrite this
cornucopia_items = initialize_object_list([
item_directory.MEDKIT, item_directory.KNIFE, item_directory.SWORD,
item_directory.RATIONS, item_directory.AXE, item_directory.CORN,
item_directory.BOW
])
inner_cornucopia_items = initialize_object_list(
[item_directory.AWP, item_directory.GRENADES, item_directory.KATANA])
all_items = initialize_object_list([
item_directory.AWP, item_directory.GRENADES, item_directory.KATANA,
item_directory.MEDKIT, item_directory.KNIFE, item_directory.SWORD,
item_directory.RATIONS, item_directory.AXE, item_directory.CORN,
item_directory.BOW
])
sponsor_items = initialize_object_list([
item_directory.AWP, item_directory.GRENADES, item_directory.KATANA,
item_directory.MEDKIT, item_directory.KNIFE, item_directory.SWORD,
item_directory.RATIONS, item_directory.AXE, item_directory.CORN,
item_directory.BOW, item_directory.MEDKIT, item_directory.KNIFE,
item_directory.SWORD, item_directory.RATIONS, item_directory.AXE,
item_directory.CORN, item_directory.BOW
])
craftableItems = initialize_object_list([
item_directory.WOOD_SPEAR, item_directory.HANDAXE,
item_directory.STONE_SPEAR, item_directory.BOW
])
num_inner_cornucopia_items = 3
player_options = []
at_corn = []
by_corn = []
dead = []
players = []
is_running = []
docket = []
is_goingToFeast = []
async def game_initialize(ctx):
for index, i in enumerate(Names):
player = Player(i, 1, s_stats[index], False)
# appending player name to players
players.append(player)
if not player.get_busy():
if r.choice([True, False, False, False
]) or player.get_stat() == stats.WIS:
await ctx.send(
f'{player.get_name()} runs away into the arena to avoid the cornucopia.'
)
is_running.append(player)
# Smart Enough to ignore the cornocopia
else:
randItem = r.choice(cornucopia_items)
if r.choice([True, False]):
if player.get_stat() == stats.DEX:
is_running.append(player)
player.give_item(randItem)
await ctx.send(
f'{player.get_name()} speeds into the cornucopia, randomly grabs {randItem}, and quickly runs away'
)
# gets an item and runs away
else:
# forced to fight
by_corn.append(player)
else:
at_corn.append(player)
# forced to fight in cornucopia
async def died(player: Player, deathReason, ctx):
players.remove(player)
dead.append(player)
await ctx.send(f"{player.get_name()} died from {deathReason}.")
async def fight(player1: Player, player2: Player, ctx):
# fight function. It just runs based on d20 rolls
player1.set_busy(True)
player2.set_busy(True)
fight_const_x = await gen_fight_const(player1, ctx)
fight_const_y = await gen_fight_const(player2, ctx)
if fight_const_x > fight_const_y:
if player2.get_stat() == stats.CHA:
player2.set_const(-0.7)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia, but spared {player2.get_name()}'s life. {player2.get_name()} escapes the cornucopia into the arena."
)
is_running.append(player2)
elif player2.get_stat() == stats.CON:
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia, but {player2.get_name()} managed to survive the attack due to their high constitution. {player2.get_name()} escapes the cornucopia into the arena."
)
is_running.append(player2)
player2.set_const(-0.7)
else:
dead.append(player2)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia and killed {player2.get_name()} in the fight"
)
# player one wins
return player1
if fight_const_y > fight_const_x:
if player1.get_stat() != stats.CHA:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia, but spared {player1.get_name()}'s life. {player1.get_name()} escapes the cornucopia into the arena."
)
is_running.append(player1)
player1.set_const(-0.7)
elif player1.get_stat == stats.CON:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia, but {player1.get_name()} managed to survive the attack due to their high constitution. {player1.get_name()} escapes the cornucopia into the arena."
)
is_running.append(player1)
player1.set_const(-0.7)
else:
players.remove(player1)
dead.append(player1)
# player 2 wins
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia and killed {player1.get_name()} in the fight"
)
return player2
if fight_const_x == fight_const_y:
await ctx.send(
f"{player1.get_name()} fought {player2.get_name()} inside the cornucopia. Both tributes emerged from the battle relatively unscathed."
)
if player1.get_stat() == stats.CON:
player1.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player1.set_const(-0.7)
if player2.get_stat() == stats.CON:
player2.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player2.set_const(-0.7)
# nobody wins
return None
async def feastFight(player1: Player, player2: Player, ctx):
# fight function. It just runs based on d20 rolls
# await ctx.send(player1)
fight_const_x = await gen_fight_const(player1, ctx)
fight_const_y = await gen_fight_const(player2, ctx)
if fight_const_x > fight_const_y:
if player2.get_stat() == stats.CHA:
player2.set_const(-0.7)
if player2.get_const() <= 0:
is_goingToFeast.remove(player2)
await died(player2, f"their wounds after fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia, but spared {player2.get_name()}'s life. {player2.get_name()} escapes the cornucopia into the arena."
)
is_goingToFeast.remove(player2)
elif player2.get_stat() == stats.CON:
player2.set_const(-0.7)
if player2.get_const() <= 0:
return died(player2, f"fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia, but {player2.get_name()} managed to survive the attack due to their high constitution. {player2.get_name()} escapes the cornucopia into the arena."
)
is_goingToFeast.remove(player2)
else:
players.remove(player2)
dead.append(player2)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} inside the cornucopia and killed {player2.get_name()} in the fight"
)
is_goingToFeast.remove(player2)
# player one wins
return player1
if fight_const_y > fight_const_x:
if player1.get_stat() != stats.CHA:
player1.set_const(-0.7)
if player1.get_const() <= 0:
is_goingToFeast.remove(player1)
await died(player1, f"their wounds after fighting {player2}", ctx)
else:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia, but spared {player1.get_name()}'s life. {player1.get_name()} escapes the cornucopia into the arena."
)
is_goingToFeast.remove(player1)
elif player1.get_stat == stats.CON:
player1.set_const(-0.7)
if player1.get_const() <= 0:
return died(player1, f"fighting {player2}", ctx)
else:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia, but {player1.get_name()} managed to survive the attack due to their high constitution. {player1.get_name()} escapes the cornucopia into the arena."
)
is_goingToFeast.remove(player1)
else:
players.remove(player1)
dead.append(player1)
# player 2 wins
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} inside the cornucopia and killed {player1.get_name()}."
)
is_goingToFeast.remove(player1)
return player2
if fight_const_x == fight_const_y:
if player1.get_stat() == stats.CON:
player1.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player1.set_const(-0.7)
if player2.get_stat() == stats.CON:
player2.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player2.set_const(-0.7)
# NOTE THIS FOLLOWING STATEMENT HAS NOT BEEN TESTED AND COULD JUST KILL ONE WHILE THE OTHER LIVES EVEN WITH THE 0 CONSTANT
if player1.get_const() <= 0 or player2.get_const() <= 0:
if player1.get_const() <= 0:
is_goingToFeast.remove(player1)
await died(player1, f"their wounds after fighting {player2}", ctx)
if player2.get_const() <= 0:
is_goingToFeast.remove(player2)
await died(player2, f"their wounds after fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} fought {player2.get_name()} inside the cornucopia. Both tributes emerged from the battle relatively unscathed. Both remain at the feast."
)
# nobody wins
return None
async def randFight(player1: Player, player2: Player, ctx):
global docket
# fight function. It just runs based on d20 rolls
# await ctx.send(player1)
fight_const_x = await gen_fight_const(player1, ctx)
fight_const_y = await gen_fight_const(player2, ctx)
if fight_const_x > fight_const_y:
if player2.get_stat() == stats.CHA:
player2.set_const(-0.7)
if player2.get_const() <= 0:
await died(player2, f"their wounds after fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()}, but spared {player2.get_name()}'s life. {player2.get_name()} runs away."
)
elif player2.get_stat() == stats.CON:
player2.set_const(-0.7)
if player2.get_const() <= 0:
return died(player2, f"fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()}, but {player2.get_name()} managed to survive the attack due to their high constitution. {player2.get_name()} runs away."
)
else:
players.remove(player2)
dead.append(player2)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} and killed them in the fight."
)
# player one wins
return player1
if fight_const_y > fight_const_x:
if player1.get_stat() != stats.CHA:
player1.set_const(-0.5)
if player1.get_const() <= 0:
await died(player1, f"their wounds after fighting {player2}", ctx)
else:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()}, but spared {player1.get_name()}'s life. {player1.get_name()} runs away."
)
elif player1.get_stat == stats.CON:
player1.set_const(-0.5)
if player1.get_const() <= 0:
return died(player1, f"their wounds after fighting {player2}", ctx)
else:
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()}, but {player1.get_name()} managed to survive the attack due to their high constitution. {player1.get_name()} runs away."
)
else:
players.remove(player1)
dead.append(player1)
# player 2 wins
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} and killed them."
)
return player2
if fight_const_x == fight_const_y:
if player1.get_stat() == stats.CON:
player1.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player1.set_const(-0.7)
if player2.get_stat() == stats.CON:
player2.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player2.set_const(-0.7)
# NOTE THIS FOLLOWING STATEMENT HAS NOT BEEN TESTED AND COULD JUST KILL ONE WHILE THE OTHER LIVES EVEN WITH THE 0 CONSTANT
if player1.get_const() <= 0 or player2.get_const() <= 0:
if player1.get_const() <= 0:
await died(player1, f"their wounds after fighting {player2}", ctx)
if player2.get_const() <= 0:
await died(player2, f"their wounds after fighting {player1}", ctx)
else:
await ctx.send(
f"{player1.get_name()} fought {player2.get_name()}. Both tributes emerged from the battle relatively unscathed. Both leave the scene."
)
# nobody wins
return None
# THIS FUNCTIONS IS FOR FIGHTS OVER AN OBJECT
async def item_fight(player1: Player, player2: Player, item, ctx):
# fight function. It just runs based on d20 rolls
player1.set_busy(True)
player2.set_busy(True)
fight_const_x = await gen_fight_const(player1, ctx)
fight_const_y = await gen_fight_const(player2, ctx)
if fight_const_x > fight_const_y:
if player2.get_stat() == stats.CHA:
player2.set_const(-0.7)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} over {item}, but spared {player2.get_name()}'s life. {player1.get_name()} Then runs away into the arena."
)
is_running.append(player1)
elif player2.get_stat() == stats.CON:
player2.set_const(-0.7)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} over {item}, but {player2.get_name()} managed to survive the attack due to their high constitution. {player1.get_name()} Then runs away into the arena."
)
is_running.append(player1)
else:
players.remove(player2)
dead.append(player2)
await ctx.send(
f"{player1.get_name()} won a fight with {player2.get_name()} over {item} and killed {player2.get_name()} in the fight. {player1.get_name()} Then runs away into the arena."
)
is_running.append(player1)
# player one wins
player1.give_item(item)
return player1
if fight_const_y > fight_const_x:
if player1.get_stat() != stats.CHA:
player1.set_const(-0.5)
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} over {item}, but spared {player1.get_name()}'s life. {player2.get_name()} Then runs away into the arena."
)
is_running.append(player2)
is_running.append(player2)
elif player1.get_stat == stats.CON:
player1.set_const(-0.5)
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} over {item}, but {player1.get_name()} managed to survive the attack due to their high constitution.{player2.get_name()} Then runs away into the arena."
)
is_running.append(player2)
else:
players.remove(player1)
dead.append(player1)
await ctx.send(
f"{player2.get_name()} won a fight with {player1.get_name()} over {item} and killed {player1.get_name()} in the fight. {player2.get_name()} Then runs away into the arena."
)
is_running.append(player2)
# player 2 wins
player2.give_item(item)
return player2
if fight_const_x == fight_const_y:
if r.choice([True, False]):
player1.give_item(item)
await ctx.send(
f"{player1.get_name()} fought {player2.get_name()} over {item} and won it. Both tributes emerged from the battle relatively unscathed. Both tributes then run away into the arena."
)
else:
player2.give_item(item)
await ctx.send(
f"{player2.get_name()} fought {player1.get_name()} over {item} and won it. Both tributes emerged from the battle relatively unscathed. Both tributes then run away into the arena."
)
is_running.append(player2)
is_running.append(player1)
if player1.get_stat() == stats.CON:
player1.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player1.set_const(-0.7)
if player2.get_stat() == stats.CON:
player2.set_const(-0.5)
elif player2.get_stat() == stats.CHA:
player2.set_const(-0.5)
else:
player2.set_const(-0.7)
# nobody wins
return None
async def gen_fight_const(playe: Player, ctx):
# roll with advantage if str
if playe.get_stat() == stats.STR:
return max(r.randint(0, 20), r.randint(0, 20))
else:
return r.randint(0, 20)
async def corn_fights(ctx):
# runs corn functions while someone exists
while at_corn:
if len(at_corn) == 1:
x = at_corn[0]
# last one standing is the winner
await ctx.send(
f"{x.get_name()} is the last remaining tribute at the cornucopia! They gather their loot."
)
for i in all_items:
x.give_item(i)
at_corn.remove(x)
is_running.append(x)
return
# await ctx.send(len(at_corn))
p1 = r.choice(at_corn)
at_corn.remove(p1)
p2 = r.choice(at_corn)
at_corn.remove(p2)
p_winner = await fight(p1, p2, ctx)
# XD you thought you were fighting? hell naw!
if p_winner != None:
at_corn.append(p_winner)
else:
at_corn.append(p1)
at_corn.append(p2)
async def corn_fights2(ctx):
# runs corn functions while someone exists
while by_corn:
if len(by_corn) == 1:
x = by_corn[0]
by_corn.remove(x)
is_running.append(x)
return
# await ctx.send(len(by_corn))
p1 = r.choice(by_corn)
by_corn.remove(p1)
p2 = r.choice(by_corn)
by_corn.remove(p2)
p_winner = await item_fight(p1, p2, r.choice(cornucopia_items), ctx)
# XD you thought you were fighting? hell naw!
if p_winner != None:
pass
async def sponsorChance(player: Player, activityCoolness, ctx):
# rolls a D20 at advantege if charisma, and adds coolness mod to the roll
x = 0
if player.get_stat() == stats.CHA:
x = max(r.randint(0, 20), r.randint(0, 20))
else:
x = r.randint(0, 20)
x += activityCoolness
if x >= 20:
# ITEMS REFERENCING EARLIER LIST AND NOT ENUM LIST
await ctx.send(
f"{player.get_name()} was sent {r.choice(sponsor_items)} by a mysterious sponsor."
)
else:
pass
async def checkEqual(p1: Player, p2: Player, playerList, isp1, ctx):
if len(playerList) >= 2 and isp1 == True:
if p1 not in players:
np1 = r.choice(playerList)
return await checkEqual(np1, p2, playerList, True, ctx)
elif p1 in players:
return p1
elif len(playerList) > 2 and isp1 == False:
if p1 == p2 or p2 not in players:
np2 = r.choice(playerList)
return await checkEqual(p1, np2, playerList, False, ctx)
elif p1 != p2 and p2 in players:
return p2
elif len(playerList) == 2 and isp1 == False:
playerList.remove(p1)
np2 = playerList[0]
playerList.append(p1)
return np2
else:
return
async def cuts_tree(player: Player, ctx):
tool = "e"
if item_directory.SWORD in player.get_items_enums():
tool = "sword"
if item_directory.KATANA in player.get_items_enums():
tool = "katana"
if item_directory.AXE in player.get_items_enums():
tool = "axe"
await ctx.send(
f"{player.get_name()} cuts down a tree wth their {tool} and builds a fire with the lumber."
)
player.set_const(0.3)
await sponsorChance(player, 1, ctx)
##############SAVING FOR LATER###################
async def hunts_enemy(p1: Player, p2: Player, ctx):
# find which weapon triggered the call, and pass it as an argument in randFight Will have to edit prints in randFight.
# if r.choice([True, False]):
await ctx.send(f"{p1.get_name()} hunts down {p2.get_name()}.")
docket.remove(p2)
winner = await randFight(p1, p2, ctx)
if winner == p1:
await sponsorChance(p1, 5, ctx)
elif winner == p2:
await sponsorChance(p2, 3, ctx)
else:
if p1 in players:
await sponsorChance(p1, 1, ctx)
if p2 in players:
await sponsorChance(p2, 1, ctx)
# else:
##############SAVING FOR LATER###################
async def hunts_food(player: Player, ctx):
weapon = ""
p = player.get_items_enums()
if item_directory.GRENADES in p:
weapon = "belt of grenades"
if item_directory.KNIFE in p:
weapon = "knife"
if item_directory.SWORD in p:
weapon = "sword"
if item_directory.AXE in p:
weapon = "axe"
if item_directory.KATANA in p:
weapon = "katana"
if item_directory.BOW in p:
weapon = "bow and arrows"
# GIVE THE PLAYER A MEAT ITEM IF THEY SUCCEED
if player.get_stat() == stats.DEX:
if r.choice([True, True, True, False]):
await ctx.send(
f"{player.get_name()} hunts down a deer wth their {weapon} and eats the meat."
)
await sponsorChance(player, 3, ctx)
else:
await ctx.send(
f"{player.get_name()} attempts to hunt down a deer wth their {weapon}, however is unable to catch it."
)
await sponsorChance(player, 0, ctx)
else:
if r.choice([True, False]):
await ctx.send(
f"{player.get_name()} hunts down a deer wth their {weapon} and eats the meat."
)
if weapon == "belt of grenades":
""" TENATIVE, NOT YET BEEN TESTED
player.get_items_enums().remove(item_directory.GRENADES)
"""
pass
await sponsorChance(player, 3, ctx)
else:
await ctx.send(
f"{player.get_name()} attempts to hunt down a deer wth their {weapon}, however is unable to catch it."
)
await sponsorChance(player, 0, ctx)
async def craft_item(player: Player, ctx):
# did not give player an item
item = r.choice(craftableItems)
await ctx.send(
f"{player.get_name()} uses their supreme intellect to craft {item.__str__()}"
)
player.set_crafted(True)
await sponsorChance(player, 2, ctx)
async def cactus_juice(player: Player, ctx):
await ctx.send(
f"{player.get_name()} finds a cactus and drinks the juice. They then say 'Drink cactus juice! it'll quench ya! nothing's quenchier! It's the quenchiest!'"
)
player.set_const(-.1)
if player.get_const() <= 0:
await died(player, "drinking cactus juice", ctx)
else:
await sponsorChance(player, 3, ctx)
async def snipe(p1: Player, p2: Player, ctx):
global docket
weapon = ""
p = p1.get_items_enums()
if item_directory.BOW in p:
weapon = "bow and arrows"
if item_directory.AWP in p:
weapon = "AWP"
if p1.get_stat() == stats.DEX:
if r.choice([True, True, True, False]):
await ctx.send(
f"{p1.get_name()} snipes {p2.get_name()} with their {weapon}."
)
if weapon == "AWP":
for i, item in enumerate(p2.get_items_enums()):
p1.give_item(item)
await died(p2, f"being sniped by {p1.get_name()}", ctx)
docket.remove(p2)
else:
p2.set_const(-0.7)
if p2.get_const() <= 0:
await died(
p2,
f"their wounds after being sniped by {p1.get_name()}", ctx)
docket.remove(p2)
await sponsorChance(p1, 4, ctx)
else:
await ctx.send(
f"{p1.get_name()} attempts to snipe {p2.get_name()} wth their {weapon}, however misses."
)
await sponsorChance(p1, 1, ctx)
else:
if r.choice([True, False]):
await ctx.send(
f"{p1.get_name()} snipes {p2.get_name()} with their {weapon}."
)
if weapon == "AWP":
for i, item in enumerate(p2.get_items_enums()):
p1.give_item(item)
await died(p2, f"being sniped by {p1.get_name()}", ctx)
docket.remove(p2)
else:
p2.set_const(-0.7)
if p2.get_const() <= 0:
await died(
p2,
f"their wounds after being sniped by {p1.get_name()}", ctx)
docket.remove(p2)
await sponsorChance(p1, 4, ctx)
else:
await ctx.send(
f"{p1.get_name()} attempts to snipe {p2.get_name()} wth their {weapon}, however misses."
)
await sponsorChance(p1, 1, ctx)
async def grenade_trap(p1: Player, p2: Player, ctx):
num = r.randint(1, 20)
await ctx.send(f"{p1.get_name()} sets a trap with their grenade belt.")
if num > 17:
await ctx.send(
f"{p2.get_name()} walked directly into {p1.get_name()}'s trap.")
docket.remove(p2)
await died(p2, "blowing up", ctx)
for i, item in enumerate(p2.get_items()):
# half of p2's items were destroyed
if i % 2 == 0:
p1.give_item(item)
"""
lst = p1.get_items()
await ctx.send(lst)
lst = lst.remove(item_directory.GRENADES)
p1.set_list(lst)
"""
await sponsorChance(p1, 4, ctx)
if num > 1 and num <= 17:
await ctx.send(
f"Nothing happens and {p1.get_name()} packs up their grenade belt and leaves."
)
else:
await ctx.send(f"{p1.get_name()} accidentally triggers their own trap.")
await died(p1, "their own trap", ctx)
async def water(player: Player, ctx):
if r.choice([True, False]):
await ctx.send(
f"{player.get_name()} searches for a water source and is successful."
)
player.set_const(0.3)
await sponsorChance(player, 2, ctx)
else:
await ctx.send(
f"{player.get_name()} searches for a water source, however is unable to find one."
)
await sponsorChance(player, -1, ctx)
async def bear_trap(player: Player, ctx):
if player.get_stat() == stats.DEX:
if r.choice([True, True, True, False]):
await ctx.send(
f"{player.get_name()} almost falls into a bear trap, however manages to dodge out of the way before falling in"
)
await sponsorChance(player, 2, ctx)
else:
await ctx.send(
f"{player.get_name()} falls into a bear trap and is badly injured"
)
player.set_const(-0.7)
if player.get_const() <= 0:
await died(player, "a bear trap", ctx)
else:
await sponsorChance(player, 2, ctx)
else:
if r.choice([True, False]):
await ctx.send(
f"{player.get_name()} almost falls into a bear trap, however manages to dodge out of the way before falling in"
)
await sponsorChance(player, 2, ctx)
else:
await ctx.send(
f"{player.get_name()} falls into a bear trap and is badly injured"
)
player.set_const(-0.7)
if player.get_const() <= 0:
await died(player, "a bear trap", ctx)
else:
await sponsorChance(player, 2, ctx)
async def randomEventManager(ctx):
global docket
# for random events, the function will first check what resources the player has and based upon those will create a custom list of possible events for them. then it will r.choice an event from that list and run a different function based on the choice.
# docket is all remaining players for this round
docket = []
for i in players:
docket.append(i)
for index, player in enumerate(players):
# await ctx.send(f"** **\nRunning {player.get_name()} now of")
# ps = []
# for i in docket:
# ps.append(i.get_name())
# await ctx.send(f"{ps}\n ** **")
# player = i
pItems = player.get_items_enums()
try:
docket.remove(player)
except ValueError:
pass
# checks for healing items and uses them by async default.
# COMMENTED OUT TEMPORARILY, CODE GIVING ERRORS
# for i in pItems:
# if item.get_type() == i.types.ASSIST:
# player.set_const(i.get_ass())
# pItems.remove(i)
# checks for bladed items
# for i in pItems:await ctx.send(type(i))
# for i in player.get_items_enums():await ctx.send(type(i))
if item_directory.SWORD in pItems or item_directory.AXE in pItems or item_directory.KATANA in pItems:
# CUTS TREE
player_options.append("cuts tree")
# checks for weapons
if (
item_directory.SWORD in pItems or item_directory.AXE in pItems or item_directory.KATANA in pItems or item_directory.KNIFE in pItems or item_directory.GRENADES in pItems or item_directory.BOW in pItems):
# HUNTS FOOD
player_options.append("hunts food")
if (
item_directory.SWORD in pItems or item_directory.AXE in pItems or item_directory.KATANA in pItems or item_directory.KNIFE in pItems or item_directory.GRENADES in pItems or item_directory.BOW in pItems) and (
len(docket) >= 1):
# HUNTS ENEMY, TEMPORARILY COMMENTED FOR TESTING
player_options.append("hunts enemy")
# checks for wisdom
if player.get_stat() == stats.WIS and player.get_crafted() is False:
# craft item
player_options.append("craft item")
if player.get_stat() != stats.WIS:
# DRINK CACTUS JUICE
player_options.append("cactus juice")
if (item_directory.AWP in pItems or item_directory.BOW in pItems) and (len(docket) >= 1):
# snoipe
player_options.append("snipe")
if (item_directory.GRENADES in pItems) and (len(docket) >= 1):
# trap
player_options.append("grenade trap")
# universal
player_options.append("water")
player_options.append("bear trap")
# await ctx.send(player_options)
rActivity = r.choice(player_options)
# await ctx.send(f"{player}- {rActivity}")
# HEYO IM SKIPPING THE ONES THAT REFERENCE OTHER PLAYERS COS IDK EXACTLY HOW TO DO THAT. ACTIVITIES LABELED 'DO LATER' OR 'SAVING FOR LATER' INCLUDE A REFERENCE TO ANOTHER CHARACTER
if rActivity == "cuts tree":
await cuts_tree(player, ctx)
elif rActivity == "hunts enemy":
p2 = 0
p1 = await checkEqual(player, p2, players, True, ctx)
p2 = await checkEqual(p1, r.choice(docket), players, False, ctx)
await hunts_enemy(p1, p2, ctx)
elif rActivity == "hunts food":
await hunts_food(player, ctx)
elif rActivity == "craft item":
await craft_item(player, ctx)