-
Notifications
You must be signed in to change notification settings - Fork 10
/
botActions.py
1868 lines (1561 loc) · 55.6 KB
/
botActions.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
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 17 07:59:35 2020
@author: janusz
"""
"""
Need bugfix:
class and origins counters update inside Champion recordtypes.
add shuffle champions
"""
import itertools
import logging
import os
import time
from operator import itemgetter
from pathlib import Path
import cv2 as cv
import easyocr
import mouseinfo
import numpy as np
import pandas as pd
import pyautogui
from recordtype import recordtype
from win32gui import GetForegroundWindow, GetWindowText
import dss
from windowcapture import WindowCapture
# import pydirectinput
logging.basicConfig(level=logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)
LOAD_IMAGE = 0
VARIABLE_PRINT_MODE = 0
IMAGE_DEBUG_MODE = 0
IMAGE_DEBUG_MODE_FULLSCREEN = 0
CROPPING_X_CHAMPIONS = 450
CROPPING_Y_CHAMPIONS = 1000
CROPPING_WIDTH_CHAMPIONS = 1000
CROPPING_HEIGHT_CHAMPIONS = 30
CROPPING_X_ROUND = 760
CROPPING_X_ROUND_FIRST = 820
CROPPING_Y_ROUND = 30
CROPPING_WIDTH_ROUND = 60
CROPPING_HEIGHT_ROUND = 40
CROPPING_X_GOLD = 820
CROPPING_Y_GOLD = 850
CROPPING_WIDTH_GOLD = 100
CROPPING_HEIGHT_GOLD = 40
screenshot = cv.imread("examples/windowed_pyauto_ss.jpg", cv.IMREAD_UNCHANGED)
def start_tft_match(templates_list, delay=3):
"""
Clicking buttons to start TFT match.
Parameters
----------
templates_list : TYPE
DESCRIPTION.
delay : Delay after click on button. The default is 3.
Returns
-------
None.
"""
dss.activate_window("client")
for i, templ in enumerate(templates_list):
if i < len(templates_list) - 1:
point = client_match_template(templ)
if point is not None:
# to avoid click
pyautogui.click(point)
pyautogui.moveTo(900, 400)
# to avoid mouse on templates position
time.sleep(delay)
else:
while client_match_template(finding_match_text) is not None:
logging.info("Already in queue waiting for match accept")
# if match will be accepted this loop will break
# bcs active window would change
# if match will be declined by someone then bot will try to accept again
point = client_match_template(templ)
if point is not None:
pyautogui.click(point)
pyautogui.moveTo(900, 400)
logging.info("Match accepted")
# to avoid mouse on templates position
else:
time.sleep(0.3)
# little bit pause for pc
return False
def client_match_template(template_img_location, conf=0.8, region_=(0, 0, 1920, 1080)):
"""
Using pyautogui.locateCenterOnScreen() to check where are buttons to click.
Parameters
----------
template_img_location : template img path
conf : confidence The default is 0.8.
Returns
-------
point : XY coords at the center of template found on screen.
"""
logging.debug(
"Funtion client_match_template() with %s passed called", template_img_location
)
point = pyautogui.locateCenterOnScreen(
template_img_location, confidence=conf, region=region_
)
logging.info("Center of template found on screenshot(return): %s", point)
logging.debug("Funtion client_match_template() end")
return point
def click_button_in_game(mode="xp"):
logging.debug("Function click_button_in_game called with passed: %s", mode)
if mode == "xp":
template_button = "examples/bot/game/buy_xp_button.jpg"
regio = (300, 850, 530, 1080)
elif mode == "refresh":
template_button = "examples/bot/game/refresh_button.jpg"
regio = (300, 850, 530, 1080)
elif mode == "exit":
template_button = "examples/bot/game/exit_now_button.jpg"
regio = (680, 440, 960, 600)
elif mode == "continue":
template_button = "examples/bot/game/continue_button.jpg"
regio = (850, 550, 990, 700)
EXIT_FLAG = False
dss.activate_window("game")
point = client_match_template(template_button, conf=0.95, region_=regio)
logging.info("point is: %s", point)
if point is not None:
logging.info("point is not None, clicking: %s", point)
# to avoid mouse on buttons or cards
pyautogui.moveTo(300, 300)
pyautogui.moveTo(point)
pyautogui.mouseDown()
# time.sleep(0.1)
pyautogui.mouseUp()
# to avoid mouse on buttons
pyautogui.moveTo(300, 300)
if point == (838, 543) or point == (960, 626): # exit or continue center
EXIT_FLAG = True
logging.info("Clicked exit button return: %s", EXIT_FLAG)
elif point is None:
logging.info("Button isnt available, couldnt find button or not enough gold.")
logging.debug("Function click_button_in_game end.")
return EXIT_FLAG
def choose_item(item_position=2):
# starts from 0
x_cord = 500 + (item_position * 250)
y_cord = 960
point = (x_cord, y_cord)
dss.activate_window("game")
pyautogui.moveTo(300, 300)
pyautogui.moveTo(point)
pyautogui.mouseDown()
pyautogui.mouseUp()
pyautogui.moveTo(300, 300)
time.sleep(0.5)
def unique_file(basename, ext):
actualname = "%s.%s" % (basename, ext)
c = itertools.count()
while os.path.exists(actualname):
actualname = "%s%d.%s" % (basename, next(c), ext)
return actualname
def update_origins():
"""Checks nonzero counters for champions in pool and updates origins by
setting origin counters."""
logging.debug("Function update_origins() called")
origin_counters_value_list = [0] * len(origin_list)
for i, origin_ in enumerate(origin_list): # looping over counters for every origin
logging.info("Current origin: %s", origin_)
for (
champ
) in (
champions_list
): # for loop to assign how much champions are nonzero in origin
if champ.ChampCounter >= 1:
logging.info("Current champ with counter >=1: %s", champ.name)
if origin_ in (champ.origin_prim, champ.origin_sec):
logging.info(
"Current champ with counter >=1 match origin Prim or Sec \
: %s or %s",
champ.origin_prim,
champ.origin_sec,
)
origin_counters_value_list[i] = origin_counters_value_list[i] + 1
logging.info(
"Number of nonzero champions in this origin: %s",
origin_counters_value_list[i],
)
origin_counters[i] = origin_counters_value_list[i]
logging.debug("Function update_origins() end")
def update_classes():
"""Checks nonzero counters for champions in pool and updates classes by
setting class counters."""
logging.debug("Function update_classes() called")
class_counters_value_list = [0] * len(class_list)
for i, class_ in enumerate(class_list): # looping over counters for every class
logging.info("Current class: %s", class_)
for (
champ
) in (
champions_list
): # for loop to assign how much champions are nonzero in class
if champ.ChampCounter >= 1:
logging.info("Current champ with counter >=1: %s", champ.name)
if class_ in (champ.class_prim, champ.class_sec):
logging.info(
"Current champ with counter >=1 match class Prim or Sec \
: %s or %s",
champ.class_prim,
champ.class_sec,
)
class_counters_value_list[i] = class_counters_value_list[i] + 1
logging.info(
"Number of nonzero champions in this class = %s",
class_counters_value_list[i],
)
class_counters[i] = class_counters_value_list[i]
logging.debug("Function update_classes() end")
def update_classes_and_origins():
"""Checks nonzero counters for champions in pool and updates classes and origins."""
logging.debug("Function update_classes_and_origins() called")
update_origins()
update_classes()
logging.debug("Function update_classes_and_origins() end")
def additional_points_from_origin_combo(champion_position):
"""Part of sum points, bonus from origin for specific champion.
In: champion_position its just position of champion in list by primal
champions to buy list.
Out: Bonus points from origin."""
logging.debug("Function additional_points_from_origin_combo() called")
logging.info(
"Calculating origin points for champ named: %s",
champions_list[champion_position].name,
)
bonus_points_from_origin = 0.2
total_count = champions_list[champion_position].OriginPrimCounter
logging.info("Origin primary counter = %d", total_count)
if champions_list[champion_position].origin_sec != "None":
total_count = champions_list[champion_position].OriginSecCounter + total_count
logging.info("Origin primary + secondary counter = %f", total_count)
origin_bonus = total_count * bonus_points_from_origin
logging.info("Bonus(return) = %f", origin_bonus)
logging.debug("Function additional_points_from_origin_combo() end")
return origin_bonus
def additional_points_from_class_combo(champion_position):
"""Part of sum points, bonus from class for specific champion.
In: champion_position its just position of champion in list by primal
champions to buy list.
Out: Bonus points from class."""
logging.debug("Function additional_points_from_class_combo() called")
logging.info(
"Calculating class points for champ named: %s ",
champions_list[champion_position].name,
)
bonus_points_from_class = 0.2
total_count = champions_list[champion_position].ClassPrimCounter
if champions_list[champion_position].class_sec != "None":
total_count = champions_list[champion_position].ClassSecCounter + total_count
logging.info("Class primary + secondary counter = %f", total_count)
class_bonus = total_count * bonus_points_from_class
logging.info("Bonus(return) = %f", class_bonus)
logging.debug("Function additional_points_from_class_combo() end")
return class_bonus
def additional_points_from_champions_in_pool(champion_position):
"""Part of sum points, bonus from champion in pool.
In: champion_position its just position of champion in list by primal
champions to buy list.
Out: Bonus points from champions that are already in pool."""
logging.debug("Function additional_points_from_champions_in_pool() called")
champion_pool_bonus = (champions_list[champion_position].ChampCounter - 1) * 0.2
logging.info(
"champion_pool_bonus = %f for champ named: %s ",
champion_pool_bonus,
champions_list[champion_position].name,
)
logging.debug("Function additional_points_from_champions_in_pool() end")
return champion_pool_bonus
def show_points_for_nonzero_counters(row_offset=2, show_mode=1):
"""It shows up champions POINTS to buy that counters are nonzero, as a text.
Doesnt disappear currently, should be fixed.
In: row_offset by default = 0 for buttons row placement."""
logging.debug("Function show_points_for_nonzero_counters() called")
position_on_screen = [0, 1, 2, 3, 4]
points_for_champion_to_buy = [0] * 5
champion_position_in_list_ordered_by_origin = (
dss.update_champions_to_buy_from_ocr_detection(
sorted_champions_to_buy_=dss.sorted_champions_to_buy,
champions_list_for_ocr__=champions_list_for_ocr,
origin_champs_counters_to_buy_=None,
reader_=reader,
DSS_ON_=0,
)[1]
)
for i in range(0, len(champion_position_in_list_ordered_by_origin), 1):
points_for_champion_to_buy[i] = (
df.points[champion_position_in_list_ordered_by_origin[i]]
+ additional_points_from_origin_combo(
champion_position_in_list_ordered_by_origin[i]
)
+ additional_points_from_class_combo(
champion_position_in_list_ordered_by_origin[i]
)
+ additional_points_from_champions_in_pool(
champion_position_in_list_ordered_by_origin[i]
)
)
points_for_champion_to_buy[i] = round(points_for_champion_to_buy[i], 3)
logging.info(
"Points and champion_position_in_list_ordered_by_origin: %s",
list(
zip(
points_for_champion_to_buy,
champion_position_in_list_ordered_by_origin,
)
),
)
human_readable_champions = []
logging.info("Should be empty list: %s", human_readable_champions)
for champ_index in champion_position_in_list_ordered_by_origin:
human_readable_champions.append(champions_list[champ_index].name)
logging.info(
"Should be filled with nonzero champions to buy: %s", human_readable_champions
)
logging.info(
"Champions availbable to buy with calculated points and position on screen list readable: %s",
list(
zip(
points_for_champion_to_buy, human_readable_champions, position_on_screen
)
),
)
logging.debug("Function show_points_for_nonzero_counters() end")
return list(
zip(
points_for_champion_to_buy,
champion_position_in_list_ordered_by_origin,
position_on_screen,
)
)
def create_list_sorted_champions_to_buy_points_then_indexes_then_position_on_screen(
points_for_nonzero_to_buy_zip,
):
sorted_items = sorted(points_for_nonzero_to_buy_zip, reverse=True)
return sorted_items
def update_champion_counter(index_tuple):
index = index_tuple[1]
logging.info("Bought champion: %s", champions_list[index].name)
logging.info("Counter before: %s", champions_list[index].ChampCounter)
champions_list[index].ChampCounter = champions_list[index].ChampCounter + 1
logging.info("Counter after +1: %s", champions_list[index].ChampCounter)
def buy_best_available_champions_by_points_threshold(
threshold=2.6,
mousePathDelay=0.05,
):
dss.activate_window(mode="game")
points_zip = (
create_list_sorted_champions_to_buy_points_then_indexes_then_position_on_screen(
show_points_for_nonzero_counters()
)
)
howMuchChampions = sum(i[0] >= threshold for i in points_zip)
logging.info(
"Threshold = %s, number of champions with points above: %s",
threshold,
howMuchChampions,
)
for i in range(0, howMuchChampions, 1):
pyautogui.moveTo(
x=championToBuyPositionOnGame[points_zip[i][2]][0],
y=championToBuyPositionOnGame[points_zip[i][2]][1],
duration=mousePathDelay,
)
pyautogui.mouseDown()
time.sleep(0.1)
pyautogui.mouseUp()
# to avoid mouse on buttons
pyautogui.moveTo(300, 300)
update_champion_counter(points_zip[i])
ss_to_save = dss.make_ss(DSS_ON=0)
cv.imwrite(
unique_file((current_bot_images_directory / "ssIlony"), "jpg"), ss_to_save
)
def boost_up_points_for_class(clas='"Brawler"'):
quer = "class_prim == {}".format(clas)
for indexi in df.query(quer).index:
print(indexi)
df.at[indexi, "points"] = 5.0
def check_round_change(roundCurr):
dss.full_state_update_rounds_ocr(DSS_ON_=0, reader_=reader, round_counter=None)
roundLocal = dss.ocr_results_round
if roundLocal:
try:
roundCapturedNow = int(roundLocal)
except (TypeError, ValueError):
roundLocal = None
if roundCurr == roundCapturedNow:
print("roundSaved, roundCapturedNow:", roundCurr, roundCapturedNow)
print("Round is the same! From check_round_change()")
return roundCurr, 0
else:
print("roundSaved, roundCapturedNow:", roundCurr, roundCapturedNow)
print("Round changed")
return roundCapturedNow, 1
else:
return None, 2
# list of window names
WindowCapture.list_window_names()
# game things
play_button_first = "examples/bot/play_button_first.jpg"
tft_mode_button = "examples/bot/tft_mode_button.jpg"
confrimation_game_mode_button = "examples/bot/confrimation_game_mode_button.jpg"
find_match_button = "examples/bot/find_match_button.jpg"
accept_match_button = "examples/bot/accept_match_button.jpg"
finding_match_text = "examples/bot/in_queue_finding_match_text.jpg"
ok_button = "examples/bot/ok_button.jpg"
play_again_button = "examples/bot/play_again_button.jpg"
# play again is first to find next match after finished one
templates_to_start_match_list = [
ok_button,
play_again_button,
play_button_first,
tft_mode_button,
confrimation_game_mode_button,
find_match_button,
accept_match_button,
]
while not ("League of Legends (TM) Client" in WindowCapture.list_window_names()):
logging.info("League of Legends (TM) Client not found in list window names.")
start_tft_match(templates_to_start_match_list)
# wait for client to start
time.sleep(5)
buy_xp_button = "examples/bot/game/buy_xp_button.jpg"
refresh_button = "examples/bot/game/refresh_button.jpg"
exit_now_button = "examples/bot/game/exit_now_button.jpg"
continue_button = "examples/bot/game/continue_button.jpg"
# for i in range(0,5):
# click_button_in_game(mode="xp")
# create directories to save images if doesnt exist
CWD = Path().cwd()
parent_directory = CWD / "gathered_images"
parent_directory.mkdir(parents=True, exist_ok=True)
print("Main directory for screens in this game")
bot_directory_name = "bot1" # input()
print("Your input for bot directory is: ", bot_directory_name)
current_bot_images_directory = Path.joinpath(parent_directory, bot_directory_name)
current_bot_images_directory.mkdir(parents=True, exist_ok=True)
df = pd.read_csv("champions_data_scaled.csv")
df.drop("Unnamed: 0", axis=1, inplace=True)
df.points = df["points"].round(3)
# order as in GUI
df.sort_values(by=["origin_prim", "champion"], inplace=True)
df.reset_index(drop=True, inplace=True)
if VARIABLE_PRINT_MODE:
print("champions_list_for_ocr = [", end=" ")
for champ in df.champion:
print("'" + champ + "'", end=", ")
print("]")
champions_list_for_ocr = [
"Brand",
"Fiddlesticks",
"Kalista",
"Nunu & Willump",
"Garen",
"Gragas",
"Karma",
"Kha zix",
"Nidalee",
"Riven",
"Soraka",
"Ashe",
"Galio",
"Heimerdinger",
"Sett",
"Udyr",
"Zyra",
"Draven",
"Hecarim",
"Miss Fortune",
"Thresh",
"Vayne",
"Viego",
"Kennen",
"Kled",
"Lulu",
"Poppy",
"Teemo",
"Tristana",
"Ziggs",
"Gwen",
"Jax",
"Nautilus",
"Aphelios",
"Diana",
"Lee Sin",
"Sejuani",
"Vladimir",
"Yasuo",
"Aatrox",
"Kayle",
"Leona",
"Lux",
"Rell",
"Syndra",
"Varus",
"Vel'Koz",
"Ivern",
"Nocturne",
"Volibear",
"Akshan",
"Irelia",
"Lucian",
"Olaf",
"Pyke",
"Rakan",
"Senna",
]
reader = easyocr.Reader(["en"])
###################################################################################
############################## POINTS END ######################################
####################################################################################
###################################################################################
############################## POINTS START ######################################
####################################################################################
df.champion = df.champion.str.replace(" ", "")
origin_list = list(set(df.origin_prim)) + list(set(df.origin_sec))
origin_list = list(set(origin_list))
origin_list.remove("None")
origin_list.sort()
if VARIABLE_PRINT_MODE:
for origin in origin_list:
print(
origin.lower()
+ "_champs = list(df.query("
+ "'origin_prim == "
+ '"'
+ "%s" % origin
+ '"'
+ "').champion)"
)
if VARIABLE_PRINT_MODE:
print("origin_champs_from_df_list = [", end=" ")
for origin in origin_list:
print(origin.lower() + "_champs", end=", ")
print("]")
abomination_champs = list(df.query('origin_prim == "Abomination"').champion)
dawnbringer_champs = list(df.query('origin_prim == "Dawnbringer"').champion)
draconic_champs = list(df.query('origin_prim == "Draconic"').champion)
forgotten_champs = list(df.query('origin_prim == "Forgotten"').champion)
hellion_champs = list(df.query('origin_prim == "Hellion"').champion)
inanimate_champs = list(df.query('origin_prim == "Inanimate"').champion)
ironclad_champs = list(df.query('origin_prim == "Ironclad"').champion)
nightbringer_champs = list(df.query('origin_prim == "Nightbringer"').champion)
redeemed_champs = list(df.query('origin_prim == "Redeemed"').champion)
revenant_champs = list(df.query('origin_prim == "Revenant"').champion)
sentinel_champs = list(df.query('origin_prim == "Sentinel"').champion)
origin_champs_from_df_list = [
abomination_champs,
dawnbringer_champs,
draconic_champs,
forgotten_champs,
hellion_champs,
inanimate_champs,
ironclad_champs,
nightbringer_champs,
redeemed_champs,
revenant_champs,
sentinel_champs,
]
class_list = list(set(df.class_prim)) + list(set(df.class_sec))
class_list = list(set(class_list))
class_list.remove("None")
class_list.sort()
if VARIABLE_PRINT_MODE:
for champ in df.champion:
print("Counter" + champ + " = 0")
# champions counters
CounterBrand = 0
CounterFiddlesticks = 0
CounterKalista = 0
CounterNunu = 0
CounterGaren = 0
CounterGragas = 0
CounterKarma = 0
CounterKhazix = 0
CounterNidalee = 0
CounterRiven = 0
CounterSoraka = 0
CounterAshe = 0
CounterGalio = 0
CounterHeimerdinger = 0
CounterSett = 0
CounterUdyr = 0
CounterZyra = 0
CounterDraven = 0
CounterHecarim = 0
CounterMissFortune = 0
CounterThresh = 0
CounterVayne = 0
CounterViego = 0
CounterKennen = 0
CounterKled = 0
CounterLulu = 0
CounterPoppy = 0
CounterTeemo = 0
CounterTristana = 0
CounterZiggs = 0
CounterGwen = 0
CounterJax = 0
CounterNautilus = 0
CounterAphelios = 0
CounterDiana = 0
CounterLeeSin = 0
CounterSejuani = 0
CounterVladimir = 0
CounterYasuo = 0
CounterAatrox = 0
CounterKayle = 0
CounterLeona = 0
CounterLux = 0
CounterRell = 0
CounterSyndra = 0
CounterVarus = 0
CounterVelkoz = 0
CounterIvern = 0
CounterNocturne = 0
CounterVolibear = 0
CounterAkshan = 0
CounterIrelia = 0
CounterLucian = 0
CounterOlaf = 0
CounterPyke = 0
CounterRakan = 0
CounterSenna = 0
if VARIABLE_PRINT_MODE:
print("origin_champs_counters = [")
for champ in df.champion:
print("Counter" + champ, end=", ")
print("]")
print()
origin_champs_counters = [
CounterBrand,
CounterFiddlesticks,
CounterKalista,
CounterNunu,
CounterGaren,
CounterGragas,
CounterKarma,
CounterKhazix,
CounterNidalee,
CounterRiven,
CounterSoraka,
CounterAshe,
CounterGalio,
CounterHeimerdinger,
CounterSett,
CounterUdyr,
CounterZyra,
CounterDraven,
CounterHecarim,
CounterMissFortune,
CounterThresh,
CounterVayne,
CounterViego,
CounterKennen,
CounterKled,
CounterLulu,
CounterPoppy,
CounterTeemo,
CounterTristana,
CounterZiggs,
CounterGwen,
CounterJax,
CounterNautilus,
CounterAphelios,
CounterDiana,
CounterLeeSin,
CounterSejuani,
CounterVladimir,
CounterYasuo,
CounterAatrox,
CounterKayle,
CounterLeona,
CounterLux,
CounterRell,
CounterSyndra,
CounterVarus,
CounterVelkoz,
CounterIvern,
CounterNocturne,
CounterVolibear,
CounterAkshan,
CounterIrelia,
CounterLucian,
CounterOlaf,
CounterPyke,
CounterRakan,
CounterSenna,
]
# counters for origins
if VARIABLE_PRINT_MODE:
for origin in origin_list:
print("Counter" + origin + " = 0")
CounterAbomination = 0
CounterDawnbringer = 0
CounterDraconic = 0
CounterForgotten = 0
CounterHellion = 0
CounterInanimate = 0
CounterIronclad = 0
CounterNightbringer = 0
CounterRedeemed = 0
CounterRevenant = 0
CounterSentinel = 0
if VARIABLE_PRINT_MODE:
print("origin_counters = [")
for origin in origin_list:
print("Counter" + origin, end=", ")
print("]")
origin_counters = [
CounterAbomination,
CounterDawnbringer,
CounterDraconic,
CounterForgotten,
CounterHellion,
CounterInanimate,
CounterIronclad,
CounterNightbringer,
CounterRedeemed,
CounterRevenant,
CounterSentinel,
]
# counters for classes
if VARIABLE_PRINT_MODE:
for clas in class_list:
print("Counter" + clas + " = 0")
CounterAssassin = 0
CounterBrawler = 0
CounterCannoneer = 0
CounterCaretaker = 0
CounterCavalier = 0
CounterCruel = 0
CounterInvoker = 0
CounterKnight = 0
CounterLegionnaire = 0
CounterMystic = 0
CounterRanger = 0
CounterRenewer = 0
CounterSkirmisher = 0
CounterSpellweaver = 0
CounterVictorious = 0
if VARIABLE_PRINT_MODE:
print("class_counters = [")
for clas in class_list:
print("Counter" + clas, end=", ")
print("]")
class_counters = [
CounterAssassin,
CounterBrawler,
CounterCannoneer,
CounterCaretaker,
CounterCavalier,
CounterCruel,
CounterInvoker,
CounterKnight,
CounterLegionnaire,
CounterMystic,
CounterRanger,
CounterRenewer,
CounterSkirmisher,
CounterSpellweaver,
CounterVictorious,
]
# Champion namedtuple things
champion_info = []
logging.debug("Filling champion_info in purpose of creating namedtuple")
for i, champ in enumerate(df.champion):
champion_info.append(
[
champ,
champions_list_for_ocr[i],
i,
origin_champs_counters[i],
df.origin_prim[i],
df.origin_sec[i],
df.class_prim[i],
df.class_sec[i],
]
)
logging.debug("First filling champion_info has ended.")
dss.append_counters_to_input_list(
input_list=champion_info,
origin_list_=origin_list,
class_list_=class_list,
origin_counters_=origin_counters,
class_counters_=class_counters,
df_=df,
)
Champion = recordtype(
"Champion",
[
"name",
"name_ocr",
"index_ocr",
"ChampCounter",
"origin_prim",
"origin_sec",
"class_prim",
"class_sec",
"OriginPrimCounter",
"OriginSecCounter",
"ClassPrimCounter",
"ClassSecCounter",
],
)
if VARIABLE_PRINT_MODE:
for i, champ in enumerate(champion_info):
print(champ[0] + " = Champion(*champion_info[%d])" % i)
Brand = Champion(*champion_info[0])
Fiddlesticks = Champion(*champion_info[1])
Kalista = Champion(*champion_info[2])
Nunu = Champion(*champion_info[3])
Garen = Champion(*champion_info[4])
Gragas = Champion(*champion_info[5])
Karma = Champion(*champion_info[6])
Khazix = Champion(*champion_info[7])
Nidalee = Champion(*champion_info[8])
Riven = Champion(*champion_info[9])
Soraka = Champion(*champion_info[10])
Ashe = Champion(*champion_info[11])
Galio = Champion(*champion_info[12])
Heimerdinger = Champion(*champion_info[13])
Sett = Champion(*champion_info[14])
Udyr = Champion(*champion_info[15])
Zyra = Champion(*champion_info[16])
Draven = Champion(*champion_info[17])
Hecarim = Champion(*champion_info[18])
MissFortune = Champion(*champion_info[19])
Thresh = Champion(*champion_info[20])
Vayne = Champion(*champion_info[21])
Viego = Champion(*champion_info[22])
Kennen = Champion(*champion_info[23])
Kled = Champion(*champion_info[24])
Lulu = Champion(*champion_info[25])
Poppy = Champion(*champion_info[26])
Teemo = Champion(*champion_info[27])
Tristana = Champion(*champion_info[28])
Ziggs = Champion(*champion_info[29])
Gwen = Champion(*champion_info[30])
Jax = Champion(*champion_info[31])
Nautilus = Champion(*champion_info[32])
Aphelios = Champion(*champion_info[33])
Diana = Champion(*champion_info[34])
LeeSin = Champion(*champion_info[35])
Sejuani = Champion(*champion_info[36])
Vladimir = Champion(*champion_info[37])
Yasuo = Champion(*champion_info[38])
Aatrox = Champion(*champion_info[39])
Kayle = Champion(*champion_info[40])
Leona = Champion(*champion_info[41])
Lux = Champion(*champion_info[42])
Rell = Champion(*champion_info[43])
Syndra = Champion(*champion_info[44])
Varus = Champion(*champion_info[45])
Velkoz = Champion(*champion_info[46])