forked from MG8mer/avalon_index
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpick_move.py
524 lines (489 loc) · 19.1 KB
/
pick_move.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
import os
import nextcord
from nextcord.embeds import Embed
from nextcord import Interaction
import asyncio
import asyncpg
from battle_embeds import archer_battle
from battle_embeds import mage_battle
from battle_embeds import knight_battle
from nextcord.ext import commands
import random
from random import randint
import math
client = commands.Bot(command_prefix=".", intents = nextcord.Intents.all()) # Define client.
#start_value of 1 is the starter
#start_value of 2 is the reciever
# Move function that returns what turn it is, taking the arguments interaction for who used battle, member for who recieved battle, start_rand for who starts in the battle, the class of the starter, and the class of the reciever.
async def move(interaction: Interaction, member: nextcord.Member, start_rand, startrand_mage, recieverand_mage, class_value_starter, class_value_reciever, starter_hp_value, reciever_hp_value, class_evaluation_starter, class_evaluation_reciever, switch, turn, battle_screen, db_pool, starter_crit_num, reciever_crit_num, starter_av_blessing_hits, reciever_av_blessing_hits):
if startrand_mage == 7 or recieverand_mage == 7:
# Dicts to store class info:
# Class health
health = {
1: 150,
2: 100,
3: 125
}
# Battle evaluation:
# Ex: 12; if a knight fights an archer it's weak for the knight.
# Ex 2: 32: if a mage fights an archer, it's strong for the mage.
evaluation = {
"11": "Normal",
"22": "Normal",
"33": "Normal",
"12": "Weak",
"13": "Strong",
"21": "Strong",
"23": "Weak",
"31": "Weak",
"32": "Strong",
}
# Dict order:
# Class
# Attacks:
# Damage dependent on evaluation.
attacks = {
1: {
"Sword Jab": {
"Weak": -10,
"Normal": -15,
"Strong": -20
},
"Sword Slash": {
"Weak": -15,
"Normal": -25,
"Strong": -35
},
"Dual Sword Attack": {
"Weak": -30,
"Normal": -45,
"Strong": -60
},
"Sliced and Diced": {
"Weak": -50,
"Normal": -75,
"Strong": -100
}
},
2: {
"Weak Arrow": {
"Weak": -15,
"Normal": -20,
"Strong": -25
},
"Piercing Shot": {
"Weak": -25,
"Normal": -35,
"Strong": -45
},
"Triple Shot": {
"Weak": -50,
"Normal": -70,
"Strong": -90
},
"Make it Rain": {
"Weak": -85,
"Normal": -125,
"Strong": -150
}
},
3: {
"Zap": {
"Weak": -12,
"Normal": -18,
"Strong": -22
},
"Fireball": {
"Weak": -22,
"Normal": -32,
"Strong": -42
},
"Arcane Mania": {
"Weak": -45,
"Normal": -65,
"Strong": -80
},
"Biden Blast": {
"Weak": -75,
"Normal": -100,
"Strong": -125
}
},
4: {
"THUNDERBOLT": {
"Weak": -15,
"Normal": -20,
"Strong": -25
},
"SUPER FIREBALL": {
"Weak": -25,
"Normal": -35,
"Strong": -45
},
"THE SORCERER'S WRATH": {
"Weak": -50,
"Normal": -70,
"Strong": -90
},
"TRUE BIDEN BLAST!!!": {
"Weak": -999,
"Normal": -999,
"Strong": -999
}
}
}
else:
# Dicts to store class info:
# Class health
health = {
1: 150,
2: 100,
3: 125
}
# Battle evaluation:
# Ex: 12; if a knight fights an archer it's weak for the knight.
# Ex 2: 32: if a mage fights an archer, it's strong for the mage.
evaluation = {
"11": "Normal",
"22": "Normal",
"33": "Normal",
"12": "Weak",
"13": "Strong",
"21": "Strong",
"23": "Weak",
"31": "Weak",
"32": "Strong",
}
# Dict order:
# Class
# Attacks:
# Damage dependent on evaluation.
attacks = {
1: {
"Sword Jab": {
"Weak": -10,
"Normal": -15,
"Strong": -20
},
"Sword Slash": {
"Weak": -15,
"Normal": -25,
"Strong": -35
},
"Dual Sword Attack": {
"Weak": -30,
"Normal": -45,
"Strong": -60
},
"Sliced and Diced": {
"Weak": -50,
"Normal": -75,
"Strong": -100
}
},
2: {
"Weak Arrow": {
"Weak": -15,
"Normal": -20,
"Strong": -25
},
"Piercing Shot": {
"Weak": -25,
"Normal": -35,
"Strong": -45
},
"Triple Shot": {
"Weak": -50,
"Normal": -70,
"Strong": -90,
},
"Make it Rain": {
"Weak": -85,
"Normal": -125,
"Strong": -150,
}
},
3: {
"Zap": {
"Weak": -12,
"Normal": -18,
"Strong": -22
},
"Fireball": {
"Weak": -22,
"Normal": -32,
"Strong": -42
},
"Arcane Mania": {
"Weak": -45,
"Normal": -65,
"Strong": -80,
},
"Biden Blast": {
"Weak": -75,
"Normal": -100,
"Strong": -125,
}
}
}
crit_hit = randint(1, 5)
if switch == None:
if start_rand == 1:
switch = False
elif start_rand == 2:
switch = True
# There is alot of repitition, so the code below will be explained with the first example as a sample.
if switch == False: # If it's the starter's turn.
if class_value_starter == 1: # If the class of the starter is the knight.
move = await knight_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, battle_screen, db_pool) # Send respective embed depending on class and whosever turn it is.
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE starter_id = $1', interaction.user.id) # If it times out after 120 seconds and /ff was not used, send a message saying the request timed out, delete the row for the starter and reciever in the battles table, ending the battle.
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
dmg = attacks[class_value_starter][move][evaluation[class_evaluation_starter]]
if move == 'Sword Jab':
miss = randint(1, 800)
if miss == 69:
dmg = 0
elif move == 'Sword Slash':
miss = randint(1, 4)
if miss == 2:
dmg = 0
elif move == 'Dual Sword Attack':
miss = randint(1, 10)
if miss == 1 or miss == 3 or miss == 5 or miss == 7 or miss == 9 or miss == 10:
dmg = 0
elif move == 'Sliced and Diced':
miss = randint(1, 10)
if miss == 1 or miss == 2 or miss == 3 or miss == 5 or miss == 6 or miss == 8 or miss == 9 or miss == 10:
dmg = 0
else:
starter_av_blessing_hits += 1
elif class_value_starter == 2: # If the class of the starter is the archer.
move = await archer_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, battle_screen, db_pool)
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE starter_id = $1', interaction.user.id) # If it times out after 120 seconds and /ff was not used, send a message saying the request timed out, delete the row for the starter and reciever in the battles table, ending the battle.
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
dmg = attacks[class_value_starter][move][evaluation[class_evaluation_starter]]
if move == 'Weak Arrow':
miss = randint(1, 1000)
if miss == 69:
dmg = 0
elif move == 'Piercing Shot':
miss = randint(1, 5)
if miss == 2:
dmg = 0
elif move == 'Triple Shot':
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == 'Make it Rain':
miss = randint(1, 4)
if miss == 1 or miss == 3 or miss == 4:
dmg = 0
else:
starter_av_blessing_hits += 1
elif class_value_starter == 3: # If the class of the starter is the mage.
move = await mage_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, startrand_mage, recieverand_mage, battle_screen, db_pool)
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE starter_id = $1', interaction.user.id) # If it times out after 120 seconds and /ff was not used, send a message saying the request timed out, delete the row for the starter and reciever in the battles table, ending the battle.
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
if startrand_mage == 7:
dmg = attacks[4][move][evaluation[class_evaluation_starter]]
if startrand_mage == 7:
if move == "THUNDERBOLT":
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == "SUPER FIREBALL":
miss = randint(1, 10)
if miss == 2 or miss == 4 or miss == 6 or miss == 8 or miss == 9 or miss == 10:
dmg = 0
elif move == "THE SORCERER'S WRATH":
miss = randint(1, 4)
if miss == 2 or miss == 3 or miss == 4:
dmg = 0
elif move == "TRUE BIDEN BLAST!!!":
miss = randint(1, 100)
if miss != 69:
dmg = 0
else:
starter_av_blessing_hits += 1
else:
dmg = (attacks[class_value_starter][move][evaluation[class_evaluation_starter]])
if move == 'Zap':
miss = randint(1, 1000)
if miss == 69:
dmg = 0
elif move == 'Fireball':
miss = randint(1, 5)
if miss == 2:
dmg = 0
elif move == 'Arcane Mania':
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == 'Biden Blast':
miss = randint(1, 4)
if miss == 1 or miss == 3 or miss == 4:
dmg = 0
else:
starter_av_blessing_hits += 1
switch = True
elif switch == True: # Else if it's the reciever's turn.
if class_value_reciever == 1: # If the class of the reciever is the knight.
move = await knight_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, battle_screen, db_pool)
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE reciever_id = $1', member.id)
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
dmg = attacks[class_value_reciever][move][evaluation[class_evaluation_reciever]]
if move == 'Sword Jab':
miss = randint(1, 800)
if miss == 69:
dmg = 0
elif move == 'Sword Slash':
miss = randint(1, 4)
if miss == 2:
dmg = 0
elif move == 'Dual Sword Attack':
miss = randint(1, 10)
if miss == 1 or miss == 3 or miss == 5 or miss == 7 or miss == 9 or miss == 10:
dmg = 0
elif move == 'Sliced and Diced':
miss = randint(1, 10)
if miss == 1 or miss == 2 or miss == 3 or miss == 5 or miss == 6 or miss == 8 or miss == 9 or miss == 10:
dmg = 0
else:
reciever_av_blessing_hits += 1
elif class_value_reciever == 2: # If the class of the reciever is the archer.
move = await archer_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, battle_screen, db_pool)
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE reciever_id = $1', member.id)
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
dmg = attacks[class_value_reciever][move][evaluation[class_evaluation_reciever]]
if move == 'Weak Arrow':
miss = randint(1, 1000)
if miss == 69:
dmg = 0
elif move == 'Piercing Shot':
miss = randint(1, 5)
if miss == 2:
dmg = 0
elif move == 'Triple Shot':
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == 'Make it Rain':
miss = randint(1, 4)
if miss == 1 or miss == 3 or miss == 4:
dmg = 0
else:
reciever_av_blessing_hits += 1
elif class_value_reciever == 3:
# If the class of the reciever is the mage.
move = await mage_battle.battle_embd(interaction, member, switch, turn, starter_hp_value, reciever_hp_value, startrand_mage, recieverand_mage, battle_screen, db_pool)
if move == False:
return
elif move is None:
await interaction.followup.send("Request timed out...Ending battle.")
async with db_pool.acquire() as cursor:
await cursor.execute('DELETE FROM battles WHERE reciever_id = $1', member.id)
await cursor.execute(f"DELETE FROM moves WHERE user_id = {interaction.user.id} AND opponent_id = {member.id}")
await cursor.execute(f"DELETE FROM moves WHERE user_id = {member.id} AND opponent_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {interaction.user.id}")
await cursor.execute(f"DELETE FROM cooldowns WHERE user_id = {member.id}")
return
else:
if recieverand_mage == 7:
dmg = attacks[4][move][evaluation[class_evaluation_reciever]]
if move == "THUNDERBOLT":
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == "SUPER FIREBALL":
miss = randint(1, 10)
if miss == 2 or miss == 4 or miss == 6 or miss == 8 or miss == 9 or miss == 10:
dmg = 0
elif move == "THE SORCERER'S WRATH":
miss = randint(1, 4)
if miss == 2 or miss == 3 or miss == 4:
dmg = 0
elif move == "TRUE BIDEN BLAST!!!":
miss = randint(1, 100)
if miss != 69:
dmg = 0
else:
reciever_av_blessing_hits += 1
else:
dmg = attacks[class_value_reciever][move][evaluation[class_evaluation_reciever]]
if move == 'Zap':
miss = randint(1, 1000)
if miss == 69:
dmg = 0
elif move == 'Fireball':
miss = randint(1, 5)
if miss == 2:
dmg = 0
elif move == 'Arcane Mania':
miss = randint(1, 2)
if miss == 1:
dmg = 0
elif move == 'Biden Blast':
miss = randint(1, 4)
if miss == 1 or miss == 3 or miss == 4:
dmg = 0
else:
reciever_av_blessing_hits += 1
switch = False
if crit_hit == 3:
dmg *= 1.2
if switch == False:
reciever_crit_num += 1
elif switch == True:
starter_crit_num += 1
dmg = math.floor(dmg)
return switch, dmg, move, crit_hit, starter_crit_num, reciever_crit_num, starter_av_blessing_hits, reciever_av_blessing_hits