Browse Source

Add top 300 power mode

Add a mode to grab only power from the top 300 players. Run with --top
to use this mode, or --power for full power rankings. Flag names should
be changed.
main
Ashton Charbonneau 2 years ago
parent
commit
bfd00db181
2 changed files with 54 additions and 3 deletions
  1. 2
    0
      .gitignore
  2. 52
    3
      rok-stat-grabber.py

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
1
+output/
2
+debug/

+ 52
- 3
rok-stat-grabber.py View File

@@ -30,11 +30,14 @@ PROGRAM_DESCRIPTION = "This program controls devices via ADB to take screenshots
30 30
 # ----
31 31
 
32 32
 parser = argparse.ArgumentParser(description = PROGRAM_DESCRIPTION)
33
+parser.add_argument("--power", help = "get full power rankings", default = False, action = "store_true")
34
+parser.add_argument("--top", help = "get stats on the top 300", default = False, action = "store_true")
33 35
 parser.add_argument("-p", "--project", help = "project name", required = True)
34 36
 parser.add_argument("-s", "--serial", help = "device serial", required = True)
35 37
 parser.add_argument("-v", "--verbose", help = "be verbose", default = False, action = "store_true")
36
-parser.add_argument("-c", "--count", help = "how many to scrape", required = True, type = int)
38
+parser.add_argument("-c", "--count", help = "how many to scrape", default = 0, type = int)
37 39
 parser.add_argument("-n", "--start", help = "what number to start scraping at", default = 1, type = int)
40
+parser.add_argument("-k", "--skipped", help = "how many have been skipped", type = int)
38 41
 parser.add_argument("--debug", help = "debug", default = False, action = "store_true")
39 42
 arguments = parser.parse_args()
40 43
 
@@ -42,7 +45,7 @@ arguments = parser.parse_args()
42 45
 # Coordinates
43 46
 # ----
44 47
 
45
-ROTATE = 0 # TODO: fix this; shouldn't be needed
48
+ROTATE = 90 # TODO: fix this; shouldn't be needed
46 49
 
47 50
 TAP_LOCATIONS = {
48 51
     "1": (460, 460),
@@ -178,6 +181,51 @@ def read_from_power_rankings(count, start, device, folder):
178 181
         if i%25 == 0: time.sleep(10)
179 182
     return
180 183
 
184
+def read_top_300_stats(start, skipped, device, folder):
185
+    if arguments.verbose: print("Reading the top 300 power rankings.")
186
+    if skipped > 0: print("Adding", skipped, "already skipped rankings.")
187
+    time.sleep(1)
188
+
189
+    count = 300 + 5 + skipped
190
+    i = start
191
+    while i < (count + 1):
192
+        if arguments.verbose: print(str(i) + "/" + str(count) + ": ", end = "", flush = True)
193
+
194
+        # Scrape
195
+        tap_modifier = tap_profile(i, folder)
196
+        i = i + tap_modifier
197
+        count = count + tap_modifier - 1
198
+        grab_profile_simple(device, folder)
199
+
200
+        # Rest
201
+        time.sleep(1)
202
+        if i%10 == 0: time.sleep(5)
203
+        if i%25 == 0: time.sleep(10)
204
+    return
205
+
206
+def grab_profile_simple(device, folder):
207
+    datetime = get_datetime_string()
208
+
209
+    # Screenshot profile
210
+    # ID, Username, Power, Kill Points
211
+    time.sleep(2)
212
+    take_screenshot(device, folder + datetime + "_profile")
213
+
214
+    # Copy and save username
215
+    device.shell("input tap 1055 455")
216
+    time.sleep(1)
217
+    username = get_clipboard(device)
218
+    with open(projectFolder + "usernames.txt", 'a+', newline='', encoding='utf-8') as output_file:
219
+        output_file.write(datetime + "\t")
220
+        output_file.write(username)
221
+        output_file.write("\n")
222
+    if arguments.verbose: print(username, end = "", flush = True)
223
+
224
+    # Exit
225
+    if arguments.verbose: print("") # TODO: say "done" or something here if successful
226
+    device.shell("input tap 2185 160")
227
+    return
228
+
181 229
 # ----
182 230
 # Main
183 231
 # ----
@@ -197,4 +245,5 @@ if __name__ == '__main__':
197 245
     if arguments.debug: take_screenshot(device, projectFolder + get_datetime_string() + "_debug")
198 246
 
199 247
     # Scrape
200
-    read_from_power_rankings(arguments.count, arguments.start, device, projectFolder)
248
+    if arguments.power: read_from_power_rankings(arguments.count, arguments.start, device, projectFolder)
249
+    if arguments.top: read_top_300_stats(arguments.start, arguments.skipped, device, projectFolder)

Loading…
Cancel
Save