-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDraftClassEdit.py
More file actions
652 lines (579 loc) · 31.5 KB
/
DraftClassEdit.py
File metadata and controls
652 lines (579 loc) · 31.5 KB
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
# Imports
import pandas as pd
import random
import numpy as np
# Your File Path
file_path = 'Files/Madden26/IE/Season1/Player.xlsx'
df = pd.read_excel(file_path)
# Set the draftclass phase
draftclass_phase = "Traits" ### Change this to "No_Traits"" or "Traits" ###
def update_traits(row):
# Check the player's position and apply changes to specific columns
contract_status = row['ContractStatus']
if draftclass_phase == "Traits" and contract_status in ['Draft']:
# Assign out-of-position attributes initially (so they can be changed later)
# Initially set all traits to FALSE
for col in row.index:
if col.startswith('PT_'):
row[col] = False
# DISCIPLINED vs UNDISCIPLINED
if row['Position'] not in ['X']:
if random.random() < 0.10:
row['PT_UNDISCIPLINED'] = True
if not row['PT_UNDISCIPLINED'] and random.random() < 0.10:
row['PT_DISCIPLINED'] = True
# HB/WR/TE general traits
if row['Position'] in ['RB', 'HB', 'WR', 'TE', 'FB']:
if row['JukeMoveRating'] >= 90 and random.random() < 0.66:
row['PT_ELUSIVEINSTINCT'] = True
elif 80 <= row['JukeMoveRating'] <= 89 and random.random() < 0.33:
row['PT_ELUSIVEINSTINCT'] = True
elif row['JukeMoveRating'] <= 79 and random.random() < 0.1:
row['PT_ELUSIVEINSTINCT'] = True
if row['SpinMoveRating'] >= 90 and random.random() < 0.66:
row['PT_SPINCYCLE'] = True
elif 80 <= row['SpinMoveRating'] <= 89 and random.random() < 0.25:
row['PT_SPINCYCLE'] = True
elif row['SpinMoveRating'] <= 79 and random.random() < 0.05:
row['PT_SPINCYCLE'] = True
if row['TruckingRating'] >= 90 and random.random() < 0.66:
row['PT_RUNOVER'] = True
elif 80 <= row['TruckingRating'] <= 89 and random.random() < 0.33:
row['PT_RUNOVER'] = True
elif row['TruckingRating'] <= 79 and random.random() < 0.1:
row['PT_RUNOVER'] = True
if row['StiffArmRating'] >= 90 and random.random() < 0.66:
row['PT_STRONGARM'] = True
elif 80 <= row['StiffArmRating'] <= 89 and random.random() < 0.33:
row['PT_STRONGARM'] = True
elif row['StiffArmRating'] <= 79 and random.random() < 0.1:
row['PT_STRONGARM'] = True
# QB Edits
if row['Position'] == 'QB':
# QB Generic Trait Chances
qb_trait_chances = {
'PT_LOOKFORSTARS': 0.50,
'PT_EYESUP': 0.15,
'PT_TRIGGERHAPPY': 0.10,
'PT_QUICKCLOCK': 0.15,
'PT_QUICKTRIGGER': 0.15,
'PT_SEEINGGHOSTS': 0.10,
'PT_SETUPTIME': 0.10,
'PT_THROWAWAY': 0.25,
'PT_UNUSEDTRAIT1': 0.10, #Throw It Up
'PT_COVERBALL': 0.15,
'PT_HAPPYFEET': 0.075
}
for trait, chance in qb_trait_chances.items():
if random.random() < chance:
row[trait] = True
# QB attribute dependent traits
if row['ThrowPowerRating'] >= 96 and random.random() < 0.15:
row['PT_CANNON'] = True
elif 95 >= row['ThrowPowerRating'] >= 92 and random.random() < 0.1:
row['PT_CANNON'] = True
elif 88 <= row['ThrowPowerRating'] <= 91 and random.random() < 0.05:
row['PT_CANNON'] = True
if row['PT_CANNON'] == False and random.random() < 0.1:
row['PT_UPANDOVER'] = True
if row['SpeedRating'] <= 74:
row['PT_SEDENTARY'] = True
elif 75 <= row['SpeedRating'] <= 79:
row['PT_SEDENTARY'] = random.choice([True, False])
elif row['SpeedRating'] >= 85:
row['PT_HEROBALL'] = True
elif 80 <= row['SpeedRating'] <= 84:
row['PT_HEROBALL'] = random.choice([True, False])
if random.random() < 0.15:
row['PT_RISKTAKER'] = True
if random.random() < 0.15 and row['PT_RISKTAKER'] == False:
row['PT_CONSERVATIVE'] = True
if row['ThrowOnTheRunRating'] >= 85 and random.random() < 0.75:
row['PT_DOUBLEBACK'] = True
elif 80 <= row['ThrowOnTheRunRating'] <= 84 and random.random() < 0.2:
row['PT_DOUBLEBACK'] = True
elif row['ThrowOnTheRunRating'] <= 79 and random.random() < 0.05:
row['PT_DOUBLEBACK'] = True
if random.random() < 0.1:
row['PT_OBLIVIOUS'] = True
elif row['PT_OBLIVIOUS'] == False and random.random() < 0.07:
row['PT_PARANOID'] = True
if row['SpeedRating'] >= 85 and random.random() < 0.5:
row['PT_ELUSIVEINSTINCT'] = True
elif 84 >= row['SpeedRating'] >= 80 and random.random() < 0.25:
row['PT_ELUSIVEINSTINCT'] = True
elif row['SpeedRating'] <= 79 and random.random() < 0.075:
row['PT_ELUSIVEINSTINCT'] = True
if row['SpeedRating'] >= 85 and random.random() < 0.1:
row['PT_SPINCYCLE'] = True
elif 84 >= row['SpeedRating'] >= 80 and random.random() < 0.05:
row['PT_SPINCYCLE'] = True
elif row['SpeedRating'] <= 79 and random.random() < 0.01:
row['PT_SPINCYCLE'] = True
if row['SpeedRating'] >= 85 and random.random() < 0.2:
row['PT_RUNOVER'] = True
elif 84 >= row['SpeedRating'] >= 80 and random.random() < 0.1:
row['PT_RUNOVER'] = True
elif row['SpeedRating'] <= 79 and random.random() < 0.05:
row['PT_RUNOVER'] = True
if row['SpeedRating'] >= 85 and random.random() < 0.1:
row['PT_STRONGARM'] = True
elif 84 >= row['SpeedRating'] >= 80 and random.random() < 0.05:
row['PT_STRONGARM'] = True
elif row['SpeedRating'] <= 79 and random.random() < 0.01:
row['PT_STRONGARM'] = True
if not row['PT_ELUSIVEINSTINCT'] and not row['PT_STRONGARM'] and not row['PT_SPINCYCLE'] and not row['PT_RUNOVER']:
row['PT_STEERINGCLEAR'] = True
# HB Edits
if row['Position'] == 'HB':
# HB Generic Trait Chances
hb_trait_chances = {
'PT_AGGRESSIVE': 0.10,
'PT_COVERBALL': 0.15,
'PT_HIGHLIGHTREEL': 0.05,
'PT_POSSESSION': 0.15,
'PT_RAC': 0.20,
'PT_EARLYCELEBRATION': 0.15
}
for trait, chance in hb_trait_chances.items():
if random.random() < chance:
row[trait] = True
if not row['PT_ELUSIVEINSTINCT'] and not row['PT_STRONGARM'] and not row['PT_SPINCYCLE'] and not row['PT_RUNOVER'] and random.random() < 0.05:
row['PT_STEERINGCLEAR'] = True
# OFF Edits
if row['Position'] in ['WR', 'TE']:
# WR/TE Generic Trait Chances
rec_trait_chances = {
'PT_COVERBALL': 0.15,
'PT_POSSESSION': 0.15,
'PT_RAC': 0.25,
'PT_EARLYCELEBRATION': 0.20
}
for trait, chance in rec_trait_chances.items():
if random.random() < chance:
row[trait] = True
if not row['PT_ELUSIVEINSTINCT'] and not row['PT_STRONGARM'] and not row['PT_SPINCYCLE'] and not row['PT_RUNOVER'] and random.random() < 0.25:
row['PT_STEERINGCLEAR'] = True
if row['SpectacularCatchRating'] >= 90 and random.random() < 0.66:
row['PT_HIGHLIGHTREEL'] = True
elif 80 <= row['SpectacularCatchRating'] <= 89 and random.random() < 0.25:
row['PT_HIGHLIGHTREEL'] = True
elif row['SpectacularCatchRating'] <= 79 and random.random() < 0.075:
row['PT_HIGHLIGHTREEL'] = True
if row['CatchInTrafficRating'] >= 90 and random.random() < 0.75:
row['PT_AGGRESSIVE'] = True
elif 80 <= row['CatchInTrafficRating'] <= 89 and random.random() < 0.33:
row['PT_AGGRESSIVE'] = True
elif row['CatchInTrafficRating'] <= 79 and random.random() < 0.10:
row['PT_AGGRESSIVE'] = True
# DEF General Trait Edits
if row['Position'] in ['LE', 'RE', 'DT', 'LOLB', 'MLB', 'ROLB', 'CB', 'FS', 'SS']:
if row['HitPowerRating'] >= 90 and random.random() < 0.66:
row['PT_HEADHUNTER'] = True
elif 80 <= row['HitPowerRating'] <= 89 and random.random() < 0.15:
row['PT_HEADHUNTER'] = True
elif row['HitPowerRating'] <= 79 and random.random() < 0.05:
row['PT_HEADHUNTER'] = True
if random.random() < 0.05:
row['PT_PUNCHITOUT'] = True
if not row['PT_HEADHUNTER'] and not row['PT_PUNCHITOUT'] and random.random() < 0.10:
row['PT_SAFETACKLER'] = True
# DEF Front Edits
if row['Position'] in ['LE', 'RE', 'DT']:
if (row['BlockSheddingRating'] + row['PowerMovesRating'])/2 >= 85 and random.random() < 0.75:
row['PT_BOUNCER'] = True
elif 75 <= (row['BlockSheddingRating'] + row['PowerMovesRating'])/2 <= 84 and random.random() < 0.25:
row['PT_BOUNCER'] = True
elif (row['BlockSheddingRating'] + row['PowerMovesRating'])/2 <= 74 and random.random() < 0.05:
row['PT_BOUNCER'] = True
if row['StrengthRating'] >= 85 and random.random() < 0.75:
row['PT_BULL'] = True
elif 75 <= row['StrengthRating'] <= 84 and random.random() < 0.25:
row['PT_BULL'] = True
elif row['StrengthRating'] <= 74 and random.random() < 0.05:
row['PT_BULL'] = True
if row['FinesseMovesRating'] >= 85 and random.random() < 0.75:
row['PT_FINESSERUSHER'] = True
elif 75 <= row['FinesseMovesRating'] <= 84 and random.random() < 0.25:
row['PT_FINESSERUSHER'] = True
elif row['FinesseMovesRating'] <= 74 and random.random() < 0.05:
row['PT_FINESSERUSHER'] = True
if (row['PowerMovesRating'] + row['FinesseMovesRating'])/2 >= 85 and random.random() < 0.75:
row['PT_OLE'] = True
elif 75 <= (row['PowerMovesRating'] + row['FinesseMovesRating'])/2 <= 84 and random.random() < 0.25:
row['PT_OLE'] = True
elif (row['PowerMovesRating'] + row['FinesseMovesRating'])/2 <= 74 and random.random() < 0.05:
row['PT_OLE'] = True
if row['PowerMovesRating'] >= 85 and random.random() < 0.75:
row['PT_POWERRUSHER'] = True
elif 75 <= row['PowerMovesRating'] <= 84 and random.random() < 0.25:
row['PT_POWERRUSHER'] = True
elif row['PowerMovesRating'] <= 74 and random.random() < 0.05:
row['PT_POWERRUSHER'] = True
if (row['AgilityRating'] + row['FinesseMovesRating'])/2 >= 85 and random.random() < 0.75:
row['PT_SPINRUSHER'] = True
elif 75 <= (row['AgilityRating'] + row['FinesseMovesRating'])/2 <= 84 and random.random() < 0.25:
row['PT_SPINRUSHER'] = True
elif (row['AgilityRating'] + row['FinesseMovesRating'])/2 <= 74 and random.random() < 0.05:
row['PT_SPINRUSHER'] = True
if (row['StrengthRating'] + row['PowerMovesRating'])/2 >= 85 and random.random() < 0.75:
row['PT_HAMMERHEAD'] = True
elif 75 <= (row['StrengthRating'] + row['PowerMovesRating'])/2 <= 84 and random.random() < 0.25:
row['PT_HAMMERHEAD'] = True
elif (row['StrengthRating'] + row['PowerMovesRating'])/2 <= 74 and random.random() < 0.05:
row['PT_HAMMERHEAD'] = True
if random.random() < 0.075:
row['PT_FLYSWATTER'] = True
if random.random() < 0.075:
row['PT_GASGUZZLER'] = True
# Nose Tackle Logic #
if row['Position'] in ['DT']:
overall_rating = row['OverallRating']
dt_true_weight = row['Weight'] + 160
if dt_true_weight >= 325:
row['ThrowAccuracyDeepRating'] = min(overall_rating + 5, 99)
elif 310 <= dt_true_weight < 325:
row['ThrowAccuracyDeepRating'] = max(overall_rating - 5, 1)
elif 300 <= dt_true_weight < 310:
row['ThrowAccuracyDeepRating'] = max(overall_rating - 15, 1)
elif 290 <= dt_true_weight < 300:
row['ThrowAccuracyDeepRating'] = max(overall_rating - 25, 1)
else:
row['ThrowAccuracyDeepRating'] = 25
# DB Edits
if row['Position'] in ['CB', 'FS', 'SS']:
if row['PressRating'] >= 85 and random.random() < 0.75:
row['PT_JAMMER'] = True
elif 75 <= row['PressRating'] <= 84 and random.random() < 0.15:
row['PT_JAMMER'] = True
elif row['PressRating'] <= 74 and random.random() < 0.05:
row['PT_JAMMER'] = True
if random.random() < 0.10:
row['PT_PLAYBALL'] = True
if not row['PT_PLAYBALL'] and random.random() < 0.10:
row['PT_PLAYRECEIVER'] = True
# Add more conditions and changes for other columns and positions as needed
return row
def update_attributes(row):
# Check the player's position and apply changes to specific columns
contract_status = row['ContractStatus']
if draftclass_phase == "No_Traits" and contract_status in ['Draft']:
# Assign out-of-position attributes initially (so they can be changed later)
# Non-Specialists
if row['Position'] not in ['K', 'P', 'QB', 'LS']:
row['AwarenessRating'] = row['OverallRating']
row['KickPowerRating'] = max(row['KickPowerRating'] - 5, 15)
row['KickAccuracyRating'] = max(row['KickAccuracyRating'] - 10, 10)
# Non-LongSnappers
if row['Position'] not in ['LS']:
row['LongSnapRating'] = 5
# Kick-Returning
if row['Position'] not in ['X']:
row['KickReturnRating'] = max(row['KickReturnRating'] - 5, 5)
# Non-QBs throwing Edits
if row['Position'] not in ['QB']:
row['ThrowPowerRating'] = min(row['ThrowPowerRating'] + 5, 90)
# QB Edits
if row['Position'] == 'QB':
# For QBs, set a minimum of 70 and a maximum of 90 for InjuryRating
new_injury_rating = row['InjuryRating'] - 10
# Ensure the new value is within the specified range
if new_injury_rating < 70:
new_injury_rating = 70
if new_injury_rating > 90:
new_injury_rating = 90
row['InjuryRating'] = new_injury_rating
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['ThrowAccuracyShortRating'] = min(row['ThrowAccuracyShortRating'] + 1, 99)
row['ThrowAccuracyMidRating'] = min(row['ThrowAccuracyMidRating'] + 1, 99)
row['ThrowAccuracyDeepRating'] = min(row['ThrowAccuracyDeepRating'] + 1, 99)
# HB Edits
if row['Position'] == 'HB':
# For HBs, set a minimum of 70 and a maximum of 90 for InjuryRating
new_injury_rating = row['InjuryRating'] - 10
# Ensure the new value is within the specified range
if new_injury_rating < 70:
new_injury_rating = 70
if new_injury_rating > 90:
new_injury_rating = 90
row['InjuryRating'] = new_injury_rating
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['BCVisionRating'] = min(row['BCVisionRating'] + 1, 99)
row['BreakTackleRating'] = min(row['BreakTackleRating'] + 1, 99)
row['CarryingRating'] = min(row['CarryingRating'] + 1, 99)
# OFF Edits
if row['Position'] in ['WR', 'TE']:
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['CatchingRating'] = min(row['CatchingRating'] + 1, 99)
row['ShortRouteRunningRating'] = min(row['ShortRouteRunningRating'] + 1, 99)
row['MediumRouteRunningRating'] = min(row['MediumRouteRunningRating'] + 1, 99)
row['DeepRouteRunningRating'] = min(row['DeepRouteRunningRating'] + 1, 99)
if row['KickReturnRating'] >= 90:
row['BCVisionRating'] = min(98, max(row['BCVisionRating'] + 2, 68))
row['JukeMoveRating'] = min(98, max(row['JukeMoveRating'] + 3, 72))
row['SpinMoveRating'] = min(98, max(row['SpinMoveRating'] + 3, 70))
row['CarryingRating'] = min(98, max(row['CarryingRating'] + 3, 65))
row['BreakTackleRating'] = min(98, max(row['BreakTackleRating'] + 2, 60))
long_snap_te_chances = [
(20, 0.005),
(30, 0.005),
(40, 0.005),
(50, 0.005),
(60, 0.005),
]
if row['Position'] == 'TE':
for value, chance in long_snap_te_chances:
if random.random() <= chance:
row['LongSnapRating'] = value
break
# OL LS Edits
if row['Position'] in ['LT', 'LG', 'C', 'RG', 'RT']:
long_snap_ol_chances = [
(20, 0.003),
(30, 0.002),
(40, 0.001),
(50, 0.001),
(60, 0.001),
]
for value, chance in long_snap_ol_chances:
if random.random() <= chance:
row['LongSnapRating'] = value
break
# DT Nose Tackle logic
if row['Position'] in ['DT']:
dt_true_weight = row['Weight'] + 160
overall_rating = row['OverallRating']
if dt_true_weight >= 325:
row['ThrowAccuracyDeepRating'] = 99 if overall_rating >= 80 else min(overall_rating + 15, 90)
elif 310 <= dt_true_weight < 325:
row['ThrowAccuracyDeepRating'] = min(overall_rating, 85) if overall_rating >= 80 else overall_rating
elif 300 <= dt_true_weight < 310:
row['ThrowAccuracyDeepRating'] = 35 if overall_rating >= 80 else 30
elif 290 <= dt_true_weight < 300:
row['ThrowAccuracyDeepRating'] = 20 if overall_rating >= 80 else 10
else:
row['ThrowAccuracyDeepRating'] = 1
# DEF Front Edits
if row['Position'] in ['LE', 'RE', 'DT']:
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['FinesseMovesRating'] = min(row['FinesseMovesRating'] + 1, 99)
row['PowerMovesRating'] = min(row['PowerMovesRating'] + 1, 99)
row['PursuitRating'] = min(row['PursuitRating'] + 1, 99)
row['TackleRating'] = min(row['TackleRating'] + 1, 99)
row['BlockSheddingRating'] = min(row['BlockSheddingRating'] + 1, 99)
# LB Edits
if row['Position'] in ['LOLB', 'ROLB', 'MLB']:
if row['ManCoverageRating'] < 50:
row['ManCoverageRating'] = 48 + random.randint(0, 5)
if row['ZoneCoverageRating'] < 50:
row['ZoneCoverageRating'] = 48 + random.randint(0, 5)
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['PlayRecognitionRating'] = min(row['PlayRecognitionRating'] + 1, 99)
row['HitPowerRating'] = min(row['HitPowerRating'] + 1, 99)
row['PursuitRating'] = min(row['PursuitRating'] + 1, 99)
row['TackleRating'] = min(row['TackleRating'] + 1, 99)
row['BlockSheddingRating'] = min(row['BlockSheddingRating'] + 1, 99)
# CB Edits
if row['Position'] in ['CB']:
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['PlayRecognitionRating'] = min(row['PlayRecognitionRating'] + 1, 99)
row['ZoneCoverageRating'] = min(row['ZoneCoverageRating'] + 1, 99)
row['ManCoverageRating'] = min(row['ManCoverageRating'] + 1, 99)
row['PressRating'] = min(row['PressRating'] + 1, 99)
if row['KickReturnRating'] >= 90:
row['BCVisionRating'] = min(99, max(row['BCVisionRating'] + 6, 68))
row['JukeMoveRating'] = min(99, max(row['JukeMoveRating'] + 6, 72))
row['SpinMoveRating'] = min(99, max(row['SpinMoveRating'] + 6, 70))
row['CarryingRating'] = min(99, max(row['CarryingRating'] + 6, 65))
row['BreakTackleRating'] = min(99, max(row['BreakTackleRating'] + 20, 60))
if 89 >= row['KickReturnRating'] >= 85:
row['BCVisionRating'] = min(99, max(row['BCVisionRating'] + 3, 65))
row['JukeMoveRating'] = min(99, max(row['JukeMoveRating'] + 3, 70))
row['SpinMoveRating'] = min(99, max(row['SpinMoveRating'] + 3, 68))
row['CarryingRating'] = min(99, max(row['CarryingRating'] + 3, 62))
row['BreakTackleRating'] = min(99, max(row['BreakTackleRating'] + 15, 55))
# S Edits
if row['Position'] in ['FS', 'SS']:
if row['OverallRating'] <= 60:
row['AwarenessRating'] = min(row['AwarenessRating'] + 1, 99)
row['PlayRecognitionRating'] = min(row['PlayRecognitionRating'] + 1, 99)
row['ZoneCoverageRating'] = min(row['ZoneCoverageRating'] + 1, 99)
row['PursuitRating'] = min(row['PursuitRating'] + 1, 99)
row['TackleRating'] = min(row['TackleRating'] + 1, 99)
row['ManCoverageRating'] = min(row['ManCoverageRating'] + 1, 99)
if row['KickReturnRating'] >= 90:
row['BCVisionRating'] = min(99, max(row['BCVisionRating'] + 6, 68))
row['JukeMoveRating'] = min(99, max(row['JukeMoveRating'] + 6, 72))
row['SpinMoveRating'] = min(99, max(row['SpinMoveRating'] + 6, 70))
row['CarryingRating'] = min(99, max(row['CarryingRating'] + 6, 65))
row['BreakTackleRating'] = min(99, max(row['BreakTackleRating'] + 20, 60))
if 89 >= row['KickReturnRating'] >= 85:
row['BCVisionRating'] = min(99, max(row['BCVisionRating'] + 3, 65))
row['JukeMoveRating'] = min(99, max(row['JukeMoveRating'] + 3, 70))
row['SpinMoveRating'] = min(99, max(row['SpinMoveRating'] + 3, 68))
row['CarryingRating'] = min(99, max(row['CarryingRating'] + 3, 62))
row['BreakTackleRating'] = min(99, max(row['BreakTackleRating'] + 15, 55))
# K/P Edits
if row['Position'] in ['K', 'P']:
row['TackleRating'] = max(min(row['TackleRating'] - 5, 99), 5)
# Non-Kicker/Punter Kicking Edits
if row['Position'] in ['WR', 'SS', 'FS']:
# Example list of tuples: (KickAccuracyRating value, KickPowerRating value, chance)
kick_rating_changes = [
(50, 55, 0.002),
(55, 65, 0.001),
(60, 75, 0.002),
(65, 85, 0.001),
]
for acc_value, power_value, chance in kick_rating_changes:
if random.random() <= chance:
row['KickAccuracyRating'] = acc_value
row['KickPowerRating'] = power_value
break
# WR Coverage Edits
if row['Position'] in ['WR'] and row['Height'] <= 74:
# Example list of tuples: (ManCoverageRating value, ZoneCoverageRating value, PressRating value, chance)
wr_cover_changes = [
(50, 50, 50, 0.003), # 0.3% chance to set Man=50 and Zone=55
(55, 60, 50, 0.003),
(60, 55, 55, 0.003),
(60, 65, 55, 0.003),
(65, 60, 60, 0.003),
(65, 70, 60, 0.002),
(70, 65, 65, 0.002),
(75, 75, 70, 0.001),
]
for mancov_value, zonecove_value, presscov_value, chance in wr_cover_changes:
if random.random() <= chance:
row['ManCoverageRating'] = mancov_value
row['ZoneCoverageRating'] = zonecove_value
row['PressRating'] = presscov_value
break
# CB Route-Running Edits
if row['Position'] in ['CB'] and row['JukeMoveRating'] >= 75:
# Example list of tuples: (ShortRouteRunningRating value, MediumRouteRunningRating value, DeepRouteRunningRating value, chance)
cb_route_changes = [
(50, 50, 50, 0.01),
(60, 60, 60, 0.007),
(60, 55, 50, 0.007),
(65, 60, 55, 0.007),
(70, 65, 60, 0.005),
(75, 65, 60, 0.005),
(55, 50, 60, 0.003),
(60, 55, 65, 0.003),
(65, 60, 70, 0.003),
]
for shortroutecb_value, medroutecb_value, deeproutecb_Value , chance in cb_route_changes:
if random.random() <= chance:
row['ShortRouteRunningRating'] = shortroutecb_value
row['MediumRouteRunningRating'] = medroutecb_value
row['DeepRouteRunningRating'] = deeproutecb_Value
break
# Off Weapons Passing Edits
if row['Position'] in ['WR', 'TE']:
# List of tuples: (ThrowPower, ThrowUnderPressure, ThrowOnTheRun, ThrowAccuracy, ThrowAccuracyShort, ThrowAccuracyMedium, ThrowAccuracyDeep, chance)
throw_rating_changes = [
(65, 50, 55, 60, 65, 60, 55, 0.007),
(75, 55, 60, 65, 70, 65, 60, 0.005),
(80, 60, 70, 70, 75, 70, 65, 0.003),
]
for power, under_pressure, on_run, accuracy, acc_short, acc_med, acc_deep, chance in throw_rating_changes:
if random.random() <= chance:
row['ThrowPowerRating'] = power
row['ThrowUnderPressureRating'] = under_pressure
row['ThrowOnTheRunRating'] = on_run
row['ThrowAccuracyRating'] = accuracy
row['ThrowAccuracyShortRating'] = acc_short
row['ThrowAccuracyMidRating'] = acc_med
row['ThrowAccuracyDeepRating'] = acc_deep
break
# For all other positions, set a minimum of 70 and a minimum of 90 for InjuryRating
if row['Position'] not in ['HB', 'QB']:
new_injury_rating = row['InjuryRating'] - 10
# Ensure the new value is within the specified range
if new_injury_rating < 70:
new_injury_rating = 70
if new_injury_rating > 90:
new_injury_rating = 90
row['InjuryRating'] = new_injury_rating
# Set TraitDevelopment to "Normal" for all positions
row['TraitDevelopment'] = 'Normal'
# Add more conditions and changes for other columns and positions as needed
return row
def assign_home_states(row):
if draftclass_phase == "Traits" and row['ContractStatus'] == 'Draft' and row['Position'] not in ['K', 'P']:
states = [
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "CanadaAlberta",
"Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii",
"Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
"Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota",
"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "NewHampshire",
"NewJersey", "NewMexico", "NewYork", "NorthCarolina", "NorthDakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania", "RhodeIsland", "SouthCarolina", "SouthDakota",
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington",
"WestVirginia", "Wisconsin", "Wyoming"
]
chances = np.array([
3.27, 0.03, 1.34, 0.32, 9.39, 0.04,
0.98, 0.67, 0.28, 9.90, 8.79, 0.79,
0.32, 2.97, 1.58, 1.06, 0.63, 0.75,
3.72, 0.04, 2.99, 0.71, 3.19, 0.98,
2.09, 1.65, 0.20, 0.35, 0.87, 0.04,
2.99, 0.04, 1.58, 4.02, 0.20, 3.90,
0.95, 0.75, 2.99, 0.12, 2.21, 0.20,
2.13, 11.37, 1.18, 0.03, 2.21, 1.34,
0.32, 1.43, 0.12
])
# Normalize to probabilities
probabilities = chances / chances.sum()
# Randomly select a state based on the probabilities
row['PLYR_HOME_STATE'] = np.random.choice(states, p=probabilities)
return row
def update_sleevetemp(row):
if draftclass_phase == "Traits" and row['ContractStatus'] in ['Draft']:
if row['Position'] in ['QB', 'K', 'P']: # Avg 30
chances = [0, 10, 20, 30, 40, 50, 60]
probabilities = [0.05, 0.10, 0.20, 0.30, 0.20, 0.10, 0.05]
row['PLYR_SLEEVETEMPERATURE'] = random.choices(chances, probabilities)[0]
elif row['Position'] in ['RB', 'HB', 'FB']: # Avg 20
chances = [0, 10, 20, 30, 40, 50, 60]
probabilities = [0.30, 0.10, 0.25, 0.15, 0.10, 0.05, 0.05]
row['PLYR_SLEEVETEMPERATURE'] = random.choices(chances, probabilities)[0]
elif row['Position'] in ['WR', 'TE', 'CB', 'FS', 'SS']: # Avg 25
chances = [0, 10, 20, 30, 40, 50, 60]
probabilities = [0.15, 0.10, 0.25, 0.25, 0.15, 0.05, 0.05]
row['PLYR_SLEEVETEMPERATURE'] = random.choices(chances, probabilities)[0]
elif row['Position'] in ['LT', 'LG', 'C', 'RG', 'RT', 'LE', 'RE', 'DT']: # Avg 16.25
chances = [0, 10, 20, 30, 40, 50, 60]
probabilities = [0.40, 0.10, 0.20, 0.15, 0.10, 0.025, 0.025]
row['PLYR_SLEEVETEMPERATURE'] = random.choices(chances, probabilities)[0]
elif row['Position'] in ['LOLB', 'MLB', 'ROLB']: # Avg 12.25
chances = [0, 10, 20, 30, 40, 50, 60]
probabilities = [0.50, 0.20, 0.05, 0.15, 0.05, 0.025, 0.025]
row['PLYR_SLEEVETEMPERATURE'] = random.choices(chances, probabilities)[0]
return row
# Track the original DataFrame before applying updates
original_df = df.copy()
# Apply the new function to update the DataFrame
df = df.apply(update_traits, axis=1)
df = df.apply(update_attributes, axis=1)
df = df.apply(assign_home_states, axis=1)
df = df.apply(update_sleevetemp, axis=1)
#df['PLYR_SLEEVETEMPERATURE'] = df.apply(lambda row: update_sleevetemp(row), axis=1)
###
columns_to_remove = []
for column in df.columns:
# Check if the column values are equal, considering data type differences
if df[column].equals(original_df[column]):
columns_to_remove.append(column)
# Drop columns with no edits
df.drop(columns=columns_to_remove, inplace=True)
###
output_filename = 'DraftClassEdit.xlsx'
df.to_excel('Files/Madden26/IE/Season1/DraftClassEdit.xlsx', index=False)