mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 07:37:55 -05:00
move to old
This commit is contained in:
1
old/scripts/GearInfo_Clothes.json
Normal file
1
old/scripts/GearInfo_Clothes.json
Normal file
File diff suppressed because one or more lines are too long
1
old/scripts/GearInfo_Head.json
Normal file
1
old/scripts/GearInfo_Head.json
Normal file
File diff suppressed because one or more lines are too long
1
old/scripts/GearInfo_Shoes.json
Normal file
1
old/scripts/GearInfo_Shoes.json
Normal file
File diff suppressed because one or more lines are too long
1
old/scripts/WeaponInfo_Main_5_0.json
Normal file
1
old/scripts/WeaponInfo_Main_5_0.json
Normal file
File diff suppressed because one or more lines are too long
162
old/scripts/ability_jsons.py
Normal file
162
old/scripts/ability_jsons.py
Normal file
@@ -0,0 +1,162 @@
|
||||
# this script parses data from pulled version of https://github.com/Leanny/leanny.github.io to jsons that fit our use case
|
||||
|
||||
import urllib.request, json
|
||||
import os
|
||||
import glob
|
||||
|
||||
with open("lang_dict_EUen.json") as f:
|
||||
lang_dict = json.load(f)
|
||||
lang_dict["BombPointSensor"] = "Point Sensor"
|
||||
lang_dict["BombPoisonFog"] = "Toxic Mist"
|
||||
lang_dict["Gachihoko"] = "Rainmaker"
|
||||
lang_dict["JumpBeacon"] = "Squid Beakon"
|
||||
|
||||
inverted_dict = {v: k for k, v in lang_dict.items()} # english -> internal
|
||||
|
||||
ability_jsons = [
|
||||
"BombDamage_Reduction",
|
||||
"BombDistance_Up",
|
||||
"HumanMove_Up",
|
||||
"InkRecovery_Up",
|
||||
"JumpTime_Save",
|
||||
"MainInk_Save",
|
||||
"MarkingTime_Reduction",
|
||||
"OpInkEffect_Reduction",
|
||||
"RespawnSpecialGauge_Save",
|
||||
"RespawnTime_Save",
|
||||
"SpecialIncrease_Up",
|
||||
"SpecialTime_Up",
|
||||
"SquidMove_Up",
|
||||
"SubInk_Save",
|
||||
]
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
ability_dict = {}
|
||||
|
||||
for code in ability_jsons:
|
||||
rel_path = f"leanny.github.io/data/Parameter/latest/Player/Player_Spec_{code}.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
with open(abs_file_path) as f:
|
||||
data = json.loads(f.read())
|
||||
ability_dict[lang_dict[code]] = data[code]
|
||||
|
||||
weapon_dict = {}
|
||||
|
||||
rel_path = f"leanny.github.io/data/Mush/latest/WeaponInfo_Main.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
with open(abs_file_path) as f:
|
||||
data = json.loads(f.read())
|
||||
for weapon_obj in data:
|
||||
weapon_obj["Sub"] = lang_dict[weapon_obj["Sub"]]
|
||||
weapon_obj["Special"] = lang_dict[weapon_obj["Special"]]
|
||||
weapon_dict[lang_dict[weapon_obj["Name"]].strip()] = weapon_obj
|
||||
|
||||
rel_path = f"leanny.github.io/data/Mush/latest/WeaponInfo_Sub.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
with open(abs_file_path) as f:
|
||||
data = json.loads(f.read())
|
||||
for weapon_obj in data:
|
||||
name = weapon_obj["Name"]
|
||||
if (
|
||||
name in lang_dict
|
||||
and "Rival" not in name
|
||||
and "LastBoss" not in name
|
||||
and "VictoryClam" != name
|
||||
and "Mission" not in name
|
||||
):
|
||||
normalized_name = name.replace("_", "")
|
||||
if normalized_name == "TimerTrap":
|
||||
normalized_name = "Trap"
|
||||
elif normalized_name == "PoisonFog":
|
||||
normalized_name = "BombPoisonFog"
|
||||
elif normalized_name == "PointSensor":
|
||||
normalized_name = "BombPointSensor"
|
||||
elif normalized_name == "Flag":
|
||||
normalized_name = "JumpBeacon"
|
||||
with urllib.request.urlopen(
|
||||
f"https://raw.githubusercontent.com/Leanny/leanny.github.io/master/data/Parameter/latest/WeaponBullet/{normalized_name}.json"
|
||||
) as url2:
|
||||
data2 = json.loads(url2.read().decode())
|
||||
mInkConsume = data2["param"]["mInkConsume"]
|
||||
weapon_obj["mInkConsume"] = mInkConsume
|
||||
weapon_dict[lang_dict[weapon_obj["Name"]]] = weapon_obj
|
||||
|
||||
|
||||
def what_to_append(weapon_internal):
|
||||
if "_Stand" in weapon_internal:
|
||||
return "_Stand"
|
||||
|
||||
if "_Jump" in weapon_internal:
|
||||
return "_Jump"
|
||||
|
||||
if "_2" in weapon_internal:
|
||||
return "_2"
|
||||
|
||||
if "Repeat" in weapon_internal:
|
||||
return "_Repeat"
|
||||
|
||||
if "_Burst" in weapon_internal:
|
||||
return "_Burst"
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
rel_path = "leanny.github.io/data/Parameter/latest/WeaponBullet/*.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
for filepath in glob.iglob(abs_file_path): # iterate through .json files
|
||||
with open(filepath) as f:
|
||||
weapon_internal = (
|
||||
filepath.replace(
|
||||
"leanny.github.io/data/Parameter/latest/WeaponBullet\\", ""
|
||||
).replace(".json", "")
|
||||
# .replace("_2", "")
|
||||
)
|
||||
toAppend = what_to_append(weapon_internal)
|
||||
|
||||
weapon_internal = (
|
||||
weapon_internal.replace("_2", "")
|
||||
.replace("Repeat", "")
|
||||
.replace("_Stand", "")
|
||||
.replace("_Jump", "")
|
||||
.replace("_Burst", "")
|
||||
)
|
||||
|
||||
if "Launcher" in weapon_internal and "Bomb" in weapon_internal:
|
||||
weapon_internal = "Launcher" + weapon_internal.replace(
|
||||
"Launcher", ""
|
||||
).replace("Bomb", "")
|
||||
|
||||
data = json.loads(f.read())
|
||||
data = data["param"]
|
||||
|
||||
if toAppend != "":
|
||||
new_data = {}
|
||||
for key, value in data.items():
|
||||
new_data[f"{key}{toAppend}"] = value
|
||||
|
||||
data = new_data
|
||||
|
||||
did_thing = False
|
||||
for english_weapon, wDict in weapon_dict.items():
|
||||
if weapon_internal in wDict["Name"].replace("_", ""):
|
||||
weapon_dict[english_weapon] = {**wDict, **data}
|
||||
did_thing = True
|
||||
|
||||
if not did_thing:
|
||||
english = lang_dict.get(weapon_internal, None)
|
||||
if english:
|
||||
weapon_dict[english] = {**wDict, **data, "Name": english}
|
||||
did_thing = True
|
||||
|
||||
values_to_skip = ["BombChase", "ShooterQuickLong", "SuperLaser"]
|
||||
if not did_thing:
|
||||
if weapon_internal not in values_to_skip:
|
||||
raise ValueError(weapon_internal)
|
||||
|
||||
|
||||
with open("ability_jsons_output/ability_data.json", "w") as fp:
|
||||
json.dump(ability_dict, fp)
|
||||
|
||||
with open("ability_jsons_output/weapon_data.json", "w") as fp:
|
||||
json.dump(weapon_dict, fp)
|
||||
3
old/scripts/decode-utf8.py
Executable file
3
old/scripts/decode-utf8.py
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
print(*[arg.encode().decode('unicode-escape') for arg in sys.argv[1:]])
|
||||
3
old/scripts/encode-utf8.py
Executable file
3
old/scripts/encode-utf8.py
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
print(*[arg.encode('unicode-escape').decode() for arg in sys.argv[1:]])
|
||||
14
old/scripts/file_names_to_list.py
Normal file
14
old/scripts/file_names_to_list.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import glob
|
||||
import os
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
rel_path = "memCakes/*.png"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
|
||||
file_names = []
|
||||
|
||||
|
||||
for filepath in glob.iglob(abs_file_path):
|
||||
file_names.append(filepath.split("\\")[-1])
|
||||
|
||||
print(file_names)
|
||||
52
old/scripts/flip_wpn_dict.py
Normal file
52
old/scripts/flip_wpn_dict.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
weapons = ["Sploosh-o-matic", "Neo Sploosh-o-matic", "Sploosh-o-matic 7",
|
||||
"Splattershot Jr.", "Custom Splattershot Jr.", "Kensa Splattershot Jr.",
|
||||
"Splash-o-matic", "Neo Splash-o-matic", "Aerospray MG", "Aerospray RG",
|
||||
"Aerospray PG", "Splattershot", "Tentatek Splattershot", "Kensa Splattershot",
|
||||
".52 Gal", ".52 Gal Deco", "Kensa .52 Gal", "N-ZAP '85", "N-ZAP '89",
|
||||
"N-ZAP '83", "Splattershot Pro", "Forge Splattershot Pro", "Kensa Splattershot Pro",
|
||||
".96 Gal", ".96 Gal Deco", "Jet Squelcher", "Custom Jet Squelcher",
|
||||
"L-3 Nozzlenose", "L-3 Nozzlenose D", "Kensa L-3 Nozzlenose",
|
||||
"H-3 Nozzlenose", "H-3 Nozzlenose D", "Cherry H-3 Nozzlenose", "Squeezer",
|
||||
"Foil Squeezer",
|
||||
"Luna Blaster", "Luna Blaster Neo", "Kensa Luna Blaster",
|
||||
"Blaster", "Custom Blaster", "Range Blaster", "Custom Range Blaster",
|
||||
"Grim Range Blaster", "Rapid Blaster", "Rapid Blaster Deco", "Kensa Rapid Blaster",
|
||||
"Rapid Blaster Pro", "Rapid Blaster Pro Deco", "Clash Blaster", "Clash Blaster Neo",
|
||||
"Carbon Roller", "Carbon Roller Deco", "Splat Roller", "Krak-On Splat Roller",
|
||||
"Kensa Splat Roller", "Dynamo Roller", "Gold Dynamo Roller", "Kensa Dynamo Roller",
|
||||
"Flingza Roller", "Foil Flingza Roller", "Inkbrush", "Inkbrush Nouveau",
|
||||
"Permanent Inkbrush", "Octobrush", "Octobrush Nouveau", "Kensa Octobrush",
|
||||
"Classic Squiffer", "New Squiffer", "Fresh Squiffer", "Splat Charger",
|
||||
"Firefin Splat Charger", "Kensa Charger", "Splatterscope", "Firefin Splatterscope",
|
||||
"Kensa Splatterscope", "E-liter 4K", "Custom E-liter 4K", "E-liter 4K Scope",
|
||||
"Custom E-liter 4K Scope", "Bamboozler 14 Mk I", "Bamboozler 14 Mk II",
|
||||
"Bamboozler 14 Mk III", "Goo Tuber", "Custom Goo Tuber", "Slosher", "Slosher Deco", "Soda Slosher", "Tri-Slosher",
|
||||
"Tri-Slosher Nouveau", "Sloshing Machine", "Sloshing Machine Neo",
|
||||
"Kensa Sloshing Machine", "Bloblobber", "Bloblobber Deco", "Explosher",
|
||||
"Custom Explosher", "Mini Splatling", "Zink Mini Splatling", "Kensa Mini Splatling",
|
||||
"Heavy Splatling", "Heavy Splatling Deco", "Heavy Splatling Remix",
|
||||
"Hydra Splatling", "Custom Hydra Splatling", "Ballpoint Splatling",
|
||||
"Ballpoint Splatling Nouveau", "Nautilus 47", "Nautilus 79",
|
||||
"Dapple Dualies", "Dapple Dualies Nouveau", "Clear Dapple Dualies",
|
||||
"Splat Dualies", "Enperry Splat Dualies", "Kensa Splat Dualies", "Glooga Dualies",
|
||||
"Glooga Dualies Deco", "Kensa Glooga Dualies", "Dualie Squelchers",
|
||||
"Custom Dualie Squelchers", "Dark Tetra Dualies", "Light Tetra Dualies",
|
||||
"Splat Brella", "Sorella Brella", "Tenta Brella", "Tenta Sorella Brella",
|
||||
"Tenta Camo Brella", "Undercover Brella", "Undercover Sorella Brella", "Kensa Undercover Brella"]
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
rel_path = "xrank_data/internal_english.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
new_dict = {}
|
||||
|
||||
with open(abs_file_path) as f:
|
||||
data = json.load(f)
|
||||
for item in data:
|
||||
value = data[item]
|
||||
new_dict[value] = item
|
||||
|
||||
with open('english_internal.json', 'w') as fp:
|
||||
json.dump(new_dict, fp)
|
||||
54
old/scripts/generate_gear_json.py
Normal file
54
old/scripts/generate_gear_json.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import json
|
||||
from pprint import pprint
|
||||
|
||||
head = {}
|
||||
clothes = {}
|
||||
shoes = {}
|
||||
|
||||
with open("lang_dict_EUen.json") as f:
|
||||
lang_dict = json.load(f)
|
||||
|
||||
with open("GearInfo_Head.json") as f:
|
||||
data = json.load(f)
|
||||
for obj in data:
|
||||
if obj["ModelName"] in lang_dict:
|
||||
brand = lang_dict[obj["Brand"]]
|
||||
lista = head.get(brand, [])
|
||||
lista.append(lang_dict[obj["ModelName"]])
|
||||
head[brand] = lista
|
||||
|
||||
with open("GearInfo_Shoes.json") as f:
|
||||
data = json.load(f)
|
||||
for obj in data:
|
||||
if obj["ModelName"] in lang_dict:
|
||||
brand = lang_dict[obj["Brand"]]
|
||||
lista = shoes.get(brand, [])
|
||||
lista.append(lang_dict[obj["ModelName"]])
|
||||
shoes[brand] = lista
|
||||
|
||||
with open("GearInfo_Clothes.json") as f:
|
||||
data = json.load(f)
|
||||
for obj in data:
|
||||
if obj["ModelName"] in lang_dict:
|
||||
brand = lang_dict[obj["Brand"]]
|
||||
lista = clothes.get(brand, [])
|
||||
lista.append(lang_dict[obj["ModelName"]])
|
||||
clothes[brand] = lista
|
||||
|
||||
to_file = []
|
||||
brands = sorted(
|
||||
list(set(list(head.keys()) + list(clothes.keys()) + list(shoes.keys()))),
|
||||
key=str.casefold,
|
||||
)
|
||||
|
||||
for b in brands:
|
||||
to_file.append(
|
||||
{
|
||||
"brand": b,
|
||||
"head": sorted(head.get(b, []), key=str.casefold),
|
||||
"clothes": sorted(clothes.get(b, []), key=str.casefold),
|
||||
"shoes": sorted(shoes.get(b, []), key=str.casefold),
|
||||
}
|
||||
)
|
||||
|
||||
pprint(to_file)
|
||||
22
old/scripts/generate_language_jsons.py
Normal file
22
old/scripts/generate_language_jsons.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os, json
|
||||
|
||||
codes = ["EUde", "EUes", "EUfr", "EUit", "EUnl", "EUru", "JPja", "EUen", "USes"]
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
with open("lang_dict_EUen.json") as f:
|
||||
lang_dict = json.load(f)
|
||||
|
||||
for code in codes:
|
||||
rel_path = f"leanny.github.io/data/Languages/lang_dict_{code}.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
with open(abs_file_path) as f:
|
||||
data: dict = json.load(f)
|
||||
result = {}
|
||||
for key, value in data.items():
|
||||
if lang_dict.get(key, None) is None:
|
||||
print(f"{key}={value}")
|
||||
continue
|
||||
result[lang_dict[key]] = value
|
||||
|
||||
with open(f"translations_{code}.json", "w") as out:
|
||||
json.dump({"game": result}, out)
|
||||
57
old/scripts/generate_weapon_info.py
Normal file
57
old/scripts/generate_weapon_info.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import json
|
||||
|
||||
weapons = ["Sploosh-o-matic", "Neo Sploosh-o-matic", "Sploosh-o-matic 7",
|
||||
"Splattershot Jr.", "Custom Splattershot Jr.", "Kensa Splattershot Jr.",
|
||||
"Splash-o-matic", "Neo Splash-o-matic", "Aerospray MG", "Aerospray RG",
|
||||
"Aerospray PG", "Splattershot", "Tentatek Splattershot", "Kensa Splattershot",
|
||||
".52 Gal", ".52 Gal Deco", "Kensa .52 Gal", "N-ZAP '85", "N-ZAP '89",
|
||||
"N-ZAP '83", "Splattershot Pro", "Forge Splattershot Pro", "Kensa Splattershot Pro",
|
||||
".96 Gal", ".96 Gal Deco", "Jet Squelcher", "Custom Jet Squelcher",
|
||||
"L-3 Nozzlenose", "L-3 Nozzlenose D", "Kensa L-3 Nozzlenose",
|
||||
"H-3 Nozzlenose", "H-3 Nozzlenose D", "Cherry H-3 Nozzlenose", "Squeezer",
|
||||
"Foil Squeezer",
|
||||
"Luna Blaster", "Luna Blaster Neo", "Kensa Luna Blaster",
|
||||
"Blaster", "Custom Blaster", "Range Blaster", "Custom Range Blaster",
|
||||
"Grim Range Blaster", "Rapid Blaster", "Rapid Blaster Deco", "Kensa Rapid Blaster",
|
||||
"Rapid Blaster Pro", "Rapid Blaster Pro Deco", "Clash Blaster", "Clash Blaster Neo",
|
||||
"Carbon Roller", "Carbon Roller Deco", "Splat Roller", "Krak-On Splat Roller",
|
||||
"Kensa Splat Roller", "Dynamo Roller", "Gold Dynamo Roller", "Kensa Dynamo Roller",
|
||||
"Flingza Roller", "Foil Flingza Roller", "Inkbrush", "Inkbrush Nouveau",
|
||||
"Permanent Inkbrush", "Octobrush", "Octobrush Nouveau", "Kensa Octobrush",
|
||||
"Classic Squiffer", "New Squiffer", "Fresh Squiffer", "Splat Charger",
|
||||
"Firefin Splat Charger", "Kensa Charger", "Splatterscope", "Firefin Splatterscope",
|
||||
"Kensa Splatterscope", "E-liter 4K", "Custom E-liter 4K", "E-liter 4K Scope",
|
||||
"Custom E-liter 4K Scope", "Bamboozler 14 Mk I", "Bamboozler 14 Mk II",
|
||||
"Bamboozler 14 Mk III", "Goo Tuber", "Custom Goo Tuber", "Slosher", "Slosher Deco", "Soda Slosher", "Tri-Slosher",
|
||||
"Tri-Slosher Nouveau", "Sloshing Machine", "Sloshing Machine Neo",
|
||||
"Kensa Sloshing Machine", "Bloblobber", "Bloblobber Deco", "Explosher",
|
||||
"Custom Explosher", "Mini Splatling", "Zink Mini Splatling", "Kensa Mini Splatling",
|
||||
"Heavy Splatling", "Heavy Splatling Deco", "Heavy Splatling Remix",
|
||||
"Hydra Splatling", "Custom Hydra Splatling", "Ballpoint Splatling",
|
||||
"Ballpoint Splatling Nouveau", "Nautilus 47", "Nautilus 79",
|
||||
"Dapple Dualies", "Dapple Dualies Nouveau", "Clear Dapple Dualies",
|
||||
"Splat Dualies", "Enperry Splat Dualies", "Kensa Splat Dualies", "Glooga Dualies",
|
||||
"Glooga Dualies Deco", "Kensa Glooga Dualies", "Dualie Squelchers",
|
||||
"Custom Dualie Squelchers", "Dark Tetra Dualies", "Light Tetra Dualies",
|
||||
"Splat Brella", "Sorella Brella", "Tenta Brella", "Tenta Sorella Brella",
|
||||
"Tenta Camo Brella", "Undercover Brella", "Undercover Sorella Brella", "Kensa Undercover Brella"]
|
||||
|
||||
weapon_info = {}
|
||||
|
||||
lang_dict = json.loads(open('lang_dict_EUen.json').read())
|
||||
wpn_list = json.loads(open('WeaponInfo_Main_5_0.json').read())
|
||||
|
||||
for wpn_obj in wpn_list:
|
||||
Name = lang_dict[wpn_obj['Name']].strip()
|
||||
if Name not in weapons:
|
||||
print(Name)
|
||||
continue
|
||||
Sub = lang_dict[wpn_obj['Sub']]
|
||||
Special = lang_dict[wpn_obj['Special']]
|
||||
Range = wpn_obj['Range']
|
||||
SpecialCost = wpn_obj['SpecialCost']
|
||||
weapon_info[Name] = {"Sub": Sub, "Special": Special, "Range": Range, "SpecialCost": SpecialCost}
|
||||
|
||||
with open('weapon_info.json', 'w') as fp:
|
||||
json.dump(weapon_info, fp)
|
||||
|
||||
1
old/scripts/lang_dict_EUen.json
Normal file
1
old/scripts/lang_dict_EUen.json
Normal file
File diff suppressed because one or more lines are too long
88
old/scripts/maps.py
Normal file
88
old/scripts/maps.py
Normal file
@@ -0,0 +1,88 @@
|
||||
import glob
|
||||
import os
|
||||
import pymongo
|
||||
from config import uri
|
||||
|
||||
# I know you could do a lot of the stuff below more efficiently but I don't think it matters in this case :)
|
||||
|
||||
maps = ["The Reef",
|
||||
"Musselforge Fitness",
|
||||
"Starfish Mainstage",
|
||||
"Humpback Pump Track",
|
||||
"Inkblot Art Academy",
|
||||
"Sturgeon Shipyard",
|
||||
"Moray Towers",
|
||||
"Port Mackerel",
|
||||
"Manta Maria",
|
||||
"Kelp Dome",
|
||||
"Snapper Canal",
|
||||
"Blackbelly Skatepark",
|
||||
"MakoMart",
|
||||
"Walleye Warehouse",
|
||||
"Shellendorf Institute",
|
||||
"Arowana Mall",
|
||||
"Goby Arena",
|
||||
"Piranha Pit",
|
||||
"Camp Triggerfish",
|
||||
"Wahoo World",
|
||||
"New Albacore Hotel",
|
||||
"Ancho-V Games",
|
||||
"Skipper Pavilion"]
|
||||
|
||||
client = pymongo.MongoClient(uri)
|
||||
db = client.production
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
file_name = input('Enter the file name without extension: ')
|
||||
rel_path = f"tourney_maps/{file_name}.txt"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
|
||||
with open(abs_file_path) as f:
|
||||
content = f.read().split("\n")
|
||||
|
||||
for index, line in enumerate(content[:]):
|
||||
if line != "":
|
||||
content[index] = content[index].strip()
|
||||
content[index] = ' '.join(content[index].split())
|
||||
|
||||
counter = 0
|
||||
for line in content[1:]: # validate data
|
||||
if line not in maps and line != "":
|
||||
raise ValueError(f'{line} is not a valid map name.')
|
||||
if line == "" and "ranked" in content[0].lower():
|
||||
if counter != 0 and counter != 8:
|
||||
raise ValueError(f'For ranked rotations there should be 8 maps per got. Got: {counter}')
|
||||
counter = 0
|
||||
|
||||
if line != "":
|
||||
counter += 1
|
||||
|
||||
map_list_name = content[0]
|
||||
sz = []
|
||||
tc = []
|
||||
rm = []
|
||||
cb = []
|
||||
index = 0
|
||||
modes = [sz, tc, rm, cb]
|
||||
modes_sorted = [[], [], [], []]
|
||||
|
||||
for line in content[2:]:
|
||||
if line == "":
|
||||
index += 1
|
||||
continue
|
||||
modes[index].append(line)
|
||||
|
||||
for mode in modes:
|
||||
if len(mode) != len(set(mode)):
|
||||
raise ValueError(f'Duplicate map in mode {mode}.')
|
||||
|
||||
for m in maps:
|
||||
for i in range(0, 4):
|
||||
if m in modes[i]:
|
||||
modes_sorted[i].append(m)
|
||||
|
||||
map_object = {"name": map_list_name, "sz": modes_sorted[0], "tc": modes_sorted[1], "rm": modes_sorted[2], "cb": modes_sorted[3]}
|
||||
db.maplists.insert_one(map_object)
|
||||
|
||||
print('Success! Entered the following map list to the database:')
|
||||
print(map_object)
|
||||
426
old/scripts/matches.py
Normal file
426
old/scripts/matches.py
Normal file
@@ -0,0 +1,426 @@
|
||||
import os
|
||||
import gspread
|
||||
import datetime
|
||||
from oauth2client.service_account import ServiceAccountCredentials
|
||||
import pymongo
|
||||
from config import uri
|
||||
|
||||
weapons = [
|
||||
"Sploosh-o-matic",
|
||||
"Neo Sploosh-o-matic",
|
||||
"Sploosh-o-matic 7",
|
||||
"Splattershot Jr.",
|
||||
"Custom Splattershot Jr.",
|
||||
"Kensa Splattershot Jr.",
|
||||
"Splash-o-matic",
|
||||
"Neo Splash-o-matic",
|
||||
"Aerospray MG",
|
||||
"Aerospray RG",
|
||||
"Aerospray PG",
|
||||
"Splattershot",
|
||||
"Tentatek Splattershot",
|
||||
"Kensa Splattershot",
|
||||
".52 Gal",
|
||||
".52 Gal Deco",
|
||||
"Kensa .52 Gal",
|
||||
"N-ZAP '85",
|
||||
"N-ZAP '89",
|
||||
"N-ZAP '83",
|
||||
"Splattershot Pro",
|
||||
"Forge Splattershot Pro",
|
||||
"Kensa Splattershot Pro",
|
||||
".96 Gal",
|
||||
".96 Gal Deco",
|
||||
"Jet Squelcher",
|
||||
"Custom Jet Squelcher",
|
||||
"L-3 Nozzlenose",
|
||||
"L-3 Nozzlenose D",
|
||||
"Kensa L-3 Nozzlenose",
|
||||
"H-3 Nozzlenose",
|
||||
"H-3 Nozzlenose D",
|
||||
"Cherry H-3 Nozzlenose",
|
||||
"Squeezer",
|
||||
"Foil Squeezer",
|
||||
"Luna Blaster",
|
||||
"Luna Blaster Neo",
|
||||
"Kensa Luna Blaster",
|
||||
"Blaster",
|
||||
"Custom Blaster",
|
||||
"Range Blaster",
|
||||
"Custom Range Blaster",
|
||||
"Grim Range Blaster",
|
||||
"Rapid Blaster",
|
||||
"Rapid Blaster Deco",
|
||||
"Kensa Rapid Blaster",
|
||||
"Rapid Blaster Pro",
|
||||
"Rapid Blaster Pro Deco",
|
||||
"Clash Blaster",
|
||||
"Clash Blaster Neo",
|
||||
"Carbon Roller",
|
||||
"Carbon Roller Deco",
|
||||
"Splat Roller",
|
||||
"Krak-On Splat Roller",
|
||||
"Kensa Splat Roller",
|
||||
"Dynamo Roller",
|
||||
"Gold Dynamo Roller",
|
||||
"Kensa Dynamo Roller",
|
||||
"Flingza Roller",
|
||||
"Foil Flingza Roller",
|
||||
"Inkbrush",
|
||||
"Inkbrush Nouveau",
|
||||
"Permanent Inkbrush",
|
||||
"Octobrush",
|
||||
"Octobrush Nouveau",
|
||||
"Kensa Octobrush",
|
||||
"Classic Squiffer",
|
||||
"New Squiffer",
|
||||
"Fresh Squiffer",
|
||||
"Splat Charger",
|
||||
"Firefin Splat Charger",
|
||||
"Kensa Charger",
|
||||
"Splatterscope",
|
||||
"Firefin Splatterscope",
|
||||
"Kensa Splatterscope",
|
||||
"E-liter 4K",
|
||||
"Custom E-liter 4K",
|
||||
"E-liter 4K Scope",
|
||||
"Custom E-liter 4K Scope",
|
||||
"Bamboozler 14 Mk I",
|
||||
"Bamboozler 14 Mk II",
|
||||
"Bamboozler 14 Mk III",
|
||||
"Goo Tuber",
|
||||
"Custom Goo Tuber",
|
||||
"Slosher",
|
||||
"Slosher Deco",
|
||||
"Soda Slosher",
|
||||
"Tri-Slosher",
|
||||
"Tri-Slosher Nouveau",
|
||||
"Sloshing Machine",
|
||||
"Sloshing Machine Neo",
|
||||
"Kensa Sloshing Machine",
|
||||
"Bloblobber",
|
||||
"Bloblobber Deco",
|
||||
"Explosher",
|
||||
"Custom Explosher",
|
||||
"Mini Splatling",
|
||||
"Zink Mini Splatling",
|
||||
"Kensa Mini Splatling",
|
||||
"Heavy Splatling",
|
||||
"Heavy Splatling Deco",
|
||||
"Heavy Splatling Remix",
|
||||
"Hydra Splatling",
|
||||
"Custom Hydra Splatling",
|
||||
"Ballpoint Splatling",
|
||||
"Ballpoint Splatling Nouveau",
|
||||
"Nautilus 47",
|
||||
"Nautilus 79",
|
||||
"Dapple Dualies",
|
||||
"Dapple Dualies Nouveau",
|
||||
"Clear Dapple Dualies",
|
||||
"Splat Dualies",
|
||||
"Enperry Splat Dualies",
|
||||
"Kensa Splat Dualies",
|
||||
"Glooga Dualies",
|
||||
"Glooga Dualies Deco",
|
||||
"Kensa Glooga Dualies",
|
||||
"Dualie Squelchers",
|
||||
"Custom Dualie Squelchers",
|
||||
"Dark Tetra Dualies",
|
||||
"Light Tetra Dualies",
|
||||
"Splat Brella",
|
||||
"Sorella Brella",
|
||||
"Tenta Brella",
|
||||
"Tenta Sorella Brella",
|
||||
"Tenta Camo Brella",
|
||||
"Undercover Brella",
|
||||
"Undercover Sorella Brella",
|
||||
"Kensa Undercover Brella",
|
||||
]
|
||||
|
||||
weapon_to_replace = {
|
||||
"N-ZAP 85": "N-ZAP '85",
|
||||
"N-ZAP 89": "N-ZAP '89",
|
||||
"N-ZAP 83": "N-ZAP '83",
|
||||
"Bamboozler 14 MK I": "Bamboozler 14 Mk I",
|
||||
"Bamboozler 14 MK II": "Bamboozler 14 Mk II",
|
||||
"Bamboozler 14 MK III": "Bamboozler 14 Mk III",
|
||||
"Kensa Splattershot PRo": "Kensa Splattershot Pro",
|
||||
"Rapid Blaster PRo Deco": "Rapid Blaster Pro Deco",
|
||||
"Tenta Camo brella": "Tenta Camo Brella",
|
||||
}
|
||||
|
||||
maps = [
|
||||
"The Reef",
|
||||
"Musselforge Fitness",
|
||||
"Starfish Mainstage",
|
||||
"Humpback Pump Track",
|
||||
"Inkblot Art Academy",
|
||||
"Sturgeon Shipyard",
|
||||
"Moray Towers",
|
||||
"Port Mackerel",
|
||||
"Manta Maria",
|
||||
"Kelp Dome",
|
||||
"Snapper Canal",
|
||||
"Blackbelly Skatepark",
|
||||
"MakoMart",
|
||||
"Walleye Warehouse",
|
||||
"Shellendorf Institute",
|
||||
"Arowana Mall",
|
||||
"Goby Arena",
|
||||
"Piranha Pit",
|
||||
"Camp Triggerfish",
|
||||
"Wahoo World",
|
||||
"New Albacore Hotel",
|
||||
"Ancho-V Games",
|
||||
"Skipper Pavilion",
|
||||
]
|
||||
|
||||
abilities = {
|
||||
"": None,
|
||||
"-": None,
|
||||
"Last-Ditch Effort": "LDE",
|
||||
"Last Ditch Effort": "LDE",
|
||||
"Ink Saver (Sub)": "ISS",
|
||||
"Ink Saver Sub": "ISS",
|
||||
"Thermal Ink": "TI",
|
||||
"Ninja Squid": "NS",
|
||||
"Bomb Defense Up DX": "BDU",
|
||||
"Stealth Jump": "SJ",
|
||||
"Drop Roller": "DR",
|
||||
"Ink Recovery Up": "REC",
|
||||
"Special Charge Up": "SCU",
|
||||
"Special Saver": "SS",
|
||||
"Run Speed Up": "RSU",
|
||||
"Run Speed up": "RSU",
|
||||
"Quick Super Jump": "QSJ",
|
||||
"Ink Resistance Up": "RES",
|
||||
"Sub Power Up": "BRU",
|
||||
"Object Shredder": "OS",
|
||||
"Haunt": "H",
|
||||
"Opening Gambit": "OG",
|
||||
"Respawn Punisher": "RP",
|
||||
"Special Power Up": "SPU",
|
||||
"Comeback": "CB",
|
||||
"Main Power Up": "MPU",
|
||||
"Ink Saver (Main)": "ISM",
|
||||
"Ink Saver Main": "ISM",
|
||||
"Tenacity": "T",
|
||||
"Quick Respawn": "QR",
|
||||
"Swim Speed Up": "SSU",
|
||||
"Swim Speed up": "SSU",
|
||||
"Ability Doubler": "AD",
|
||||
}
|
||||
|
||||
scope = [
|
||||
"https://spreadsheets.google.com/feeds",
|
||||
"https://www.googleapis.com/auth/drive",
|
||||
]
|
||||
script_dir = os.path.dirname(__file__)
|
||||
rel_path = "google_sheet_secret.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
sheets = gspread.authorize(
|
||||
ServiceAccountCredentials.from_json_keyfile_name(abs_file_path, scope)
|
||||
)
|
||||
url = input("Google Sheet URL?")
|
||||
sheet = sheets.open_by_url(url)
|
||||
|
||||
client = pymongo.MongoClient(uri)
|
||||
db = client.production
|
||||
|
||||
tournament = {
|
||||
"name": sheet.title.split("]")[2].split("[")[0].strip(),
|
||||
"jpn": "[JP]" in sheet.title,
|
||||
"google_sheet_url": url,
|
||||
"date": datetime.datetime.strptime(sheet.title.split("]")[0][1:], "%Y-%m-%d"),
|
||||
}
|
||||
tournament_id = db.tournaments.insert_one(tournament).inserted_id
|
||||
worksheet = sheet.worksheet("Summary")
|
||||
rows = worksheet.get_all_values()
|
||||
del rows[:2]
|
||||
weapon_count = {}
|
||||
round_count = {}
|
||||
teams = {}
|
||||
|
||||
# Necessary because there are columns where one cell takes over multiple cells
|
||||
# which is represented as emptry strings when gspread parses
|
||||
current_round = None
|
||||
current_game = None
|
||||
current_mode = None
|
||||
current_map = None
|
||||
current_winning_team = None
|
||||
current_losing_team = None
|
||||
round_number = 0
|
||||
|
||||
winner_team = None
|
||||
winner_team_players = None
|
||||
|
||||
game_to_enter = {
|
||||
"tournament_id": tournament_id,
|
||||
"stage": None,
|
||||
"mode": None,
|
||||
"game_number": None,
|
||||
"round_name": None,
|
||||
"round_number": None,
|
||||
"winning_team_name": None,
|
||||
"winning_team_players": [],
|
||||
"winning_team_weapons": [],
|
||||
"winning_team_main_abilities": [],
|
||||
"losing_team_name": None,
|
||||
"losing_team_players": [],
|
||||
"losing_team_weapons": [],
|
||||
"losing_team_main_abilities": [],
|
||||
}
|
||||
games_to_insertmany = []
|
||||
for count, row in enumerate(rows):
|
||||
round_name = row[0].replace("\n", " ").replace(" A", "").replace(" B", "")
|
||||
if "-" in round_name:
|
||||
round_name = round_name.replace("- ", "-")
|
||||
if round_name == "":
|
||||
round_name = current_round
|
||||
else:
|
||||
round_number += 1
|
||||
current_round = round_name
|
||||
round_count[round_name] = round_count.get(round_name, 0) + 1
|
||||
assert round_name != "", f"'{round_name}' is not a valid round name."
|
||||
game = row[1]
|
||||
if "Game" in game:
|
||||
game = int(game.split(" ")[1])
|
||||
mode = row[2]
|
||||
if mode == "":
|
||||
mode = current_mode
|
||||
else:
|
||||
current_mode = mode
|
||||
assert mode in ["SZ", "TC", "RM", "CB", "TW"], f"{mode} is not a valid mode name."
|
||||
stage = row[4]
|
||||
if stage == "":
|
||||
stage = current_map
|
||||
else:
|
||||
current_map = stage
|
||||
assert stage in maps
|
||||
winning_team_player = row[7]
|
||||
assert winning_team_player != ""
|
||||
winning_team_name = row[6]
|
||||
if game != "" and winning_team_name == "":
|
||||
if winning_team_player in teams:
|
||||
winning_team_name = teams[winning_team_player]
|
||||
else:
|
||||
winning_team_name = input(
|
||||
f"Winning team name for row {count+1}=? ({winning_team_player})"
|
||||
)
|
||||
teams[winning_team_player] = winning_team_name
|
||||
if winning_team_name == "":
|
||||
winning_team_name = current_winning_team
|
||||
else:
|
||||
current_winning_team = winning_team_name
|
||||
winning_team_player_weapon = row[8]
|
||||
if winning_team_player_weapon in weapon_to_replace:
|
||||
winning_team_player_weapon = weapon_to_replace[winning_team_player_weapon]
|
||||
assert (
|
||||
winning_team_player_weapon in weapons
|
||||
), f"'{winning_team_player_weapon}' not a valid weapon."
|
||||
weapon_count[winning_team_player_weapon] = (
|
||||
weapon_count.get(winning_team_player_weapon, 0) + 1
|
||||
)
|
||||
winning_team_player_main_abilities = [
|
||||
abilities[row[12]],
|
||||
abilities[row[13]],
|
||||
abilities[row[14]],
|
||||
]
|
||||
losing_team_player = row[19]
|
||||
assert losing_team_player != ""
|
||||
losing_team_name = row[18]
|
||||
if game != "" and losing_team_name == "":
|
||||
if losing_team_player in teams:
|
||||
losing_team_name = teams[losing_team_player]
|
||||
else:
|
||||
losing_team_name = input(
|
||||
f"Losing team name for row {count+1}=? ({losing_team_player})"
|
||||
)
|
||||
teams[losing_team_player] = losing_team_name
|
||||
if losing_team_name == "":
|
||||
losing_team_name = current_losing_team
|
||||
else:
|
||||
current_losing_team = losing_team_name
|
||||
losing_team_player_weapon = row[20]
|
||||
if losing_team_player_weapon in weapon_to_replace:
|
||||
losing_team_player_weapon = weapon_to_replace[losing_team_player_weapon]
|
||||
assert (
|
||||
losing_team_player_weapon in weapons
|
||||
), f"'{losing_team_player_weapon}' not a valid weapon."
|
||||
weapon_count[losing_team_player_weapon] = (
|
||||
weapon_count.get(losing_team_player_weapon, 0) + 1
|
||||
)
|
||||
losing_team_player_main_abitilies = [None, None, None]
|
||||
if len(row) > 26:
|
||||
losing_team_player_main_abitilies = [
|
||||
abilities[row[24]],
|
||||
abilities[row[25]],
|
||||
abilities[row[26]],
|
||||
]
|
||||
|
||||
# This is here so we can accurately check when there should be a new team
|
||||
if game == "":
|
||||
game = current_game
|
||||
else:
|
||||
current_game = game
|
||||
assert game > 0 and game < 10
|
||||
|
||||
round_bracket = (
|
||||
f" ({round_count[round_name]})"
|
||||
if round_name in round_count and round_count[round_name] > 1
|
||||
else ""
|
||||
)
|
||||
round_name = f"{round_name}{round_bracket}"
|
||||
|
||||
if (
|
||||
game_to_enter["game_number"] is not None
|
||||
and game != game_to_enter["game_number"]
|
||||
): # We have entered a new game so we insert the previous document
|
||||
games_to_insertmany.append(
|
||||
game_to_enter.copy()
|
||||
) # https://stackoverflow.com/questions/17529216/mongodb-insert-raises-duplicate-key-error
|
||||
game_to_enter["winning_team_players"] = []
|
||||
game_to_enter["winning_team_weapons"] = []
|
||||
game_to_enter["winning_team_main_abilities"] = []
|
||||
game_to_enter["losing_team_players"] = []
|
||||
game_to_enter["losing_team_weapons"] = []
|
||||
game_to_enter["losing_team_main_abilities"] = []
|
||||
|
||||
game_to_enter["stage"] = stage
|
||||
game_to_enter["mode"] = mode
|
||||
game_to_enter["game_number"] = game
|
||||
game_to_enter["round_number"] = round_number
|
||||
game_to_enter["round_name"] = round_name
|
||||
game_to_enter["winning_team_name"] = winning_team_name
|
||||
winner_team = game_to_enter["winning_team_name"]
|
||||
game_to_enter["winning_team_players"].append(winning_team_player)
|
||||
winner_team_players = game_to_enter["winning_team_players"]
|
||||
game_to_enter["winning_team_weapons"].append(winning_team_player_weapon)
|
||||
game_to_enter["winning_team_main_abilities"].append(
|
||||
winning_team_player_main_abilities
|
||||
)
|
||||
game_to_enter["losing_team_name"] = losing_team_name
|
||||
game_to_enter["losing_team_players"].append(losing_team_player)
|
||||
game_to_enter["losing_team_weapons"].append(losing_team_player_weapon)
|
||||
game_to_enter["losing_team_main_abilities"].append(
|
||||
losing_team_player_main_abitilies
|
||||
)
|
||||
|
||||
games_to_insertmany.append(game_to_enter)
|
||||
db.rounds.insert_many(games_to_insertmany)
|
||||
|
||||
tournament_updated_fields = {}
|
||||
weapon_count = sorted(weapon_count.items(), key=lambda kv: kv[1], reverse=True)
|
||||
popular_wpn = []
|
||||
|
||||
for x in range(5):
|
||||
popular_wpn.append(weapon_count[x][0])
|
||||
|
||||
tournament_updated_fields["popular_weapons"] = popular_wpn
|
||||
tournament_updated_fields["winning_team_name"] = winner_team
|
||||
tournament_updated_fields["winning_team_players"] = winner_team_players
|
||||
# TODO: Add winning_team_unique_ids here
|
||||
|
||||
db.tournaments.update_one({"_id": tournament_id}, {"$set": tournament_updated_fields})
|
||||
|
||||
print(f"Done! http://localhost:3000/tournaments/{tournament_id}")
|
||||
29
old/scripts/planner_maps.py
Normal file
29
old/scripts/planner_maps.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
highest_ver = {}
|
||||
|
||||
# images from https://mega.nz/folder/3QwygIBL#r9ghq3oeOYmEH0sUIYcMfg
|
||||
for filepath in glob.iglob("stageImgs/*.png"):
|
||||
name = filepath.replace("stageImgs\\", "").replace(".png", "").replace("v", "")
|
||||
|
||||
img_type, map_code, mode, version = name.split(" ")
|
||||
if mode in ["TW", "SF"]:
|
||||
continue
|
||||
|
||||
code = f"{img_type} {map_code} {mode}"
|
||||
|
||||
version_prev = highest_ver.get(code, "asd asd asd 0").split(" ")[3]
|
||||
|
||||
if int(version) > int(version_prev.replace("v", "").replace(".png", "")):
|
||||
highest_ver[code] = filepath
|
||||
|
||||
os.mkdir("stageImgs_result")
|
||||
for filepath in glob.iglob("stageImgs/*.png"):
|
||||
for value in highest_ver.values():
|
||||
if value == filepath:
|
||||
shutil.copy(filepath, "stageImgs_result")
|
||||
|
||||
for filepath in glob.iglob("stageImgs_result/*.png"):
|
||||
os.rename(filepath, filepath.split(" v")[0] + ".png")
|
||||
1
old/scripts/weapon_info.json
Normal file
1
old/scripts/weapon_info.json
Normal file
File diff suppressed because one or more lines are too long
421
old/scripts/xrank.py
Normal file
421
old/scripts/xrank.py
Normal file
@@ -0,0 +1,421 @@
|
||||
import glob
|
||||
import os
|
||||
import json
|
||||
import calendar
|
||||
import pymongo
|
||||
from config import uri
|
||||
|
||||
shooters = [
|
||||
"Sploosh-o-matic",
|
||||
"Neo Sploosh-o-matic",
|
||||
"Sploosh-o-matic 7",
|
||||
"Splattershot Jr.",
|
||||
"Custom Splattershot Jr.",
|
||||
"Kensa Splattershot Jr.",
|
||||
"Splash-o-matic",
|
||||
"Neo Splash-o-matic",
|
||||
"Aerospray MG",
|
||||
"Aerospray RG",
|
||||
"Aerospray PG",
|
||||
"Splattershot",
|
||||
"Tentatek Splattershot",
|
||||
"Kensa Splattershot",
|
||||
".52 Gal",
|
||||
".52 Gal Deco",
|
||||
"Kensa .52 Gal",
|
||||
"N-ZAP '85",
|
||||
"N-ZAP '89",
|
||||
"N-ZAP '83",
|
||||
"Splattershot Pro",
|
||||
"Forge Splattershot Pro",
|
||||
"Kensa Splattershot Pro",
|
||||
".96 Gal",
|
||||
".96 Gal Deco",
|
||||
"Jet Squelcher",
|
||||
"Custom Jet Squelcher",
|
||||
"L-3 Nozzlenose",
|
||||
"L-3 Nozzlenose D",
|
||||
"Kensa L-3 Nozzlenose",
|
||||
"H-3 Nozzlenose",
|
||||
"H-3 Nozzlenose D",
|
||||
"Cherry H-3 Nozzlenose",
|
||||
"Squeezer",
|
||||
"Foil Squeezer",
|
||||
]
|
||||
|
||||
blasters = [
|
||||
"Luna Blaster",
|
||||
"Luna Blaster Neo",
|
||||
"Kensa Luna Blaster",
|
||||
"Blaster",
|
||||
"Custom Blaster",
|
||||
"Range Blaster",
|
||||
"Custom Range Blaster",
|
||||
"Grim Range Blaster",
|
||||
"Rapid Blaster",
|
||||
"Rapid Blaster Deco",
|
||||
"Kensa Rapid Blaster",
|
||||
"Rapid Blaster Pro",
|
||||
"Rapid Blaster Pro Deco",
|
||||
"Clash Blaster",
|
||||
"Clash Blaster Neo",
|
||||
]
|
||||
|
||||
rollers = [
|
||||
"Carbon Roller",
|
||||
"Carbon Roller Deco",
|
||||
"Splat Roller",
|
||||
"Krak-On Splat Roller",
|
||||
"Kensa Splat Roller",
|
||||
"Dynamo Roller",
|
||||
"Gold Dynamo Roller",
|
||||
"Kensa Dynamo Roller",
|
||||
"Flingza Roller",
|
||||
"Foil Flingza Roller",
|
||||
"Inkbrush",
|
||||
"Inkbrush Nouveau",
|
||||
"Permanent Inkbrush",
|
||||
"Octobrush",
|
||||
"Octobrush Nouveau",
|
||||
"Kensa Octobrush",
|
||||
]
|
||||
|
||||
chargers = [
|
||||
"Classic Squiffer",
|
||||
"New Squiffer",
|
||||
"Fresh Squiffer",
|
||||
"Splat Charger",
|
||||
"Firefin Splat Charger",
|
||||
"Kensa Charger",
|
||||
"Splatterscope",
|
||||
"Firefin Splatterscope",
|
||||
"Kensa Splatterscope",
|
||||
"E-liter 4K",
|
||||
"Custom E-liter 4K",
|
||||
"E-liter 4K Scope",
|
||||
"Custom E-liter 4K Scope",
|
||||
"Bamboozler 14 Mk I",
|
||||
"Bamboozler 14 Mk II",
|
||||
"Bamboozler 14 Mk III",
|
||||
"Goo Tuber",
|
||||
"Custom Goo Tuber",
|
||||
]
|
||||
|
||||
sloshers = [
|
||||
"Slosher",
|
||||
"Slosher Deco",
|
||||
"Soda Slosher",
|
||||
"Tri-Slosher",
|
||||
"Tri-Slosher Nouveau",
|
||||
"Sloshing Machine",
|
||||
"Sloshing Machine Neo",
|
||||
"Kensa Sloshing Machine",
|
||||
"Bloblobber",
|
||||
"Bloblobber Deco",
|
||||
"Explosher",
|
||||
"Custom Explosher",
|
||||
]
|
||||
|
||||
splatlings = [
|
||||
"Mini Splatling",
|
||||
"Zink Mini Splatling",
|
||||
"Kensa Mini Splatling",
|
||||
"Heavy Splatling",
|
||||
"Heavy Splatling Deco",
|
||||
"Heavy Splatling Remix",
|
||||
"Hydra Splatling",
|
||||
"Custom Hydra Splatling",
|
||||
"Ballpoint Splatling",
|
||||
"Ballpoint Splatling Nouveau",
|
||||
"Nautilus 47",
|
||||
"Nautilus 79",
|
||||
]
|
||||
|
||||
dualies = [
|
||||
"Dapple Dualies",
|
||||
"Dapple Dualies Nouveau",
|
||||
"Clear Dapple Dualies",
|
||||
"Splat Dualies",
|
||||
"Enperry Splat Dualies",
|
||||
"Kensa Splat Dualies",
|
||||
"Glooga Dualies",
|
||||
"Glooga Dualies Deco",
|
||||
"Kensa Glooga Dualies",
|
||||
"Dualie Squelchers",
|
||||
"Custom Dualie Squelchers",
|
||||
"Dark Tetra Dualies",
|
||||
"Light Tetra Dualies",
|
||||
]
|
||||
|
||||
brellas = [
|
||||
"Splat Brella",
|
||||
"Sorella Brella",
|
||||
"Tenta Brella",
|
||||
"Tenta Sorella Brella",
|
||||
"Tenta Camo Brella",
|
||||
"Undercover Brella",
|
||||
"Undercover Sorella Brella",
|
||||
"Kensa Undercover Brella",
|
||||
]
|
||||
|
||||
client = pymongo.MongoClient(uri)
|
||||
db = client.production
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
rel_path = "xrank_data/*.json"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
|
||||
|
||||
def resolve_top_array(key_name, player, result, x_power):
|
||||
if key_name not in player:
|
||||
player[key_name] = [result.inserted_id]
|
||||
else:
|
||||
if len(player[key_name]) <= 3:
|
||||
player[key_name].append(result.inserted_id)
|
||||
else:
|
||||
lowest_power = 10000
|
||||
lowest_power_index = -1
|
||||
sum_of_powers = x_power
|
||||
for index, placement_id in enumerate(player[key_name]):
|
||||
high_placement = db.placements.find_one({"_id": placement_id})
|
||||
if high_placement is None:
|
||||
raise ValueError(
|
||||
f"Placement id {placement_id} not found in the database."
|
||||
)
|
||||
sum_of_powers += high_placement["x_power"]
|
||||
if high_placement["x_power"] < x_power:
|
||||
if high_placement["x_power"] < lowest_power:
|
||||
lowest_power = high_placement["x_power"]
|
||||
lowest_power_index = index
|
||||
|
||||
if lowest_power_index != -1:
|
||||
player[key_name][lowest_power_index] = result.inserted_id
|
||||
sum_of_powers -= lowest_power
|
||||
power_score = round((sum_of_powers / 4), 1)
|
||||
player[f"{key_name}Score"] = power_score
|
||||
return player
|
||||
|
||||
|
||||
for filepath in glob.iglob(
|
||||
abs_file_path
|
||||
): # iterate through .json files in the xrank_data folder
|
||||
if filepath.endswith(".json"):
|
||||
path_without_folder = filepath.replace("xrank_data\\", "")
|
||||
file_parts = path_without_folder.split("_")
|
||||
print(path_without_folder)
|
||||
month = list(calendar.month_name).index(file_parts[0].capitalize())
|
||||
|
||||
if "splat" in file_parts[1]:
|
||||
mode = 1
|
||||
elif "tower" in file_parts[1]:
|
||||
mode = 2
|
||||
elif "rainmaker" in file_parts[1]:
|
||||
mode = 3
|
||||
else:
|
||||
mode = 4
|
||||
year = int(file_parts[-1].replace(".json", ""))
|
||||
with open(filepath) as f:
|
||||
data = json.load(f)
|
||||
for placement in data:
|
||||
if placement["cheater"]:
|
||||
continue
|
||||
|
||||
rank = placement["rank"]
|
||||
if rank > 500:
|
||||
break
|
||||
|
||||
name = placement["name"]
|
||||
x_power = placement["x_power"]
|
||||
unique_id = placement["unique_id"]
|
||||
|
||||
weapon = placement["weapon"]["name"].strip()
|
||||
# If weapon is one of the reskins it gets converted to the regular version
|
||||
if weapon == "Hero Shot Replica":
|
||||
weapon = "Splattershot"
|
||||
elif weapon == "Octo Shot Replica":
|
||||
weapon = "Tentatek Splattershot"
|
||||
elif weapon == "Hero Blaster Replica":
|
||||
weapon = "Blaster"
|
||||
elif weapon == "Hero Roller Replica":
|
||||
weapon = "Splat Roller"
|
||||
elif weapon == "Herobrush Replica":
|
||||
weapon = "Octobrush"
|
||||
elif weapon == "Hero Charger Replica":
|
||||
weapon = "Splat Charger"
|
||||
elif weapon == "Hero Slosher Replica":
|
||||
weapon = "Slosher"
|
||||
elif weapon == "Hero Splatling Replica":
|
||||
weapon = "Heavy Splatling"
|
||||
elif weapon == "Hero Dualie Replicas":
|
||||
weapon = "Splat Dualies"
|
||||
elif weapon == "Hero Brella Replica":
|
||||
weapon = "Splat Brella"
|
||||
|
||||
print(
|
||||
f"{month} {year} - {mode} - {name} {unique_id} {rank} {x_power} {weapon}"
|
||||
)
|
||||
|
||||
placement_document = {
|
||||
"name": name,
|
||||
"weapon": weapon,
|
||||
"rank": rank,
|
||||
"mode": mode,
|
||||
"x_power": x_power,
|
||||
"unique_id": unique_id,
|
||||
"month": month,
|
||||
"year": year,
|
||||
}
|
||||
|
||||
result = db.placements.insert_one(placement_document)
|
||||
|
||||
player = db.players.find_one({"unique_id": unique_id})
|
||||
|
||||
if player is None:
|
||||
player = {"name": name, "unique_id": unique_id, "weapons": [weapon]}
|
||||
else:
|
||||
player["name"] = name
|
||||
playerWeapons = player["weapons"]
|
||||
playerWeapons.append(weapon)
|
||||
player["weapons"] = list(dict.fromkeys(playerWeapons))
|
||||
|
||||
player = resolve_top_array("topTotal", player, result, x_power)
|
||||
|
||||
if weapon in shooters:
|
||||
player = resolve_top_array("topShooter", player, result, x_power)
|
||||
elif weapon in blasters:
|
||||
player = resolve_top_array("topBlaster", player, result, x_power)
|
||||
elif weapon in rollers:
|
||||
player = resolve_top_array("topRoller", player, result, x_power)
|
||||
elif weapon in chargers:
|
||||
player = resolve_top_array("topCharger", player, result, x_power)
|
||||
elif weapon in sloshers:
|
||||
player = resolve_top_array("topSlosher", player, result, x_power)
|
||||
elif weapon in splatlings:
|
||||
player = resolve_top_array("topSplatling", player, result, x_power)
|
||||
elif weapon in dualies:
|
||||
player = resolve_top_array("topDualies", player, result, x_power)
|
||||
elif weapon in brellas:
|
||||
player = resolve_top_array("topBrella", player, result, x_power)
|
||||
else:
|
||||
raise ValueError(
|
||||
f'Weapon "{weapon}"doesn\'t belong in any category'
|
||||
)
|
||||
|
||||
if len(player["topTotal"]) == 1: # if player was just added
|
||||
db.players.insert_one(player)
|
||||
else:
|
||||
db.players.find_one_and_replace({"unique_id": unique_id}, player)
|
||||
|
||||
# Updating weaponsCount
|
||||
players = db.players.find({})
|
||||
for document in players:
|
||||
amount_of_weapons = len(document["weapons"])
|
||||
if "weaponsCount" not in document or amount_of_weapons != document["weaponsCount"]:
|
||||
db.players.update_one(
|
||||
{"unique_id": document["unique_id"]},
|
||||
{"$set": {"weaponsCount": amount_of_weapons}},
|
||||
)
|
||||
if "weaponsCount" in document:
|
||||
print(
|
||||
f"{document['name']} updated! {document['weaponsCount']} -> {amount_of_weapons}"
|
||||
)
|
||||
else:
|
||||
print(f"New player: {document['name']} with {amount_of_weapons} weapons!")
|
||||
|
||||
print("All done with updating the weaponsCount attributes.")
|
||||
|
||||
# Update X Rank trends
|
||||
placements = db.placements.find({})
|
||||
wpn_dict = json.loads(open("weapon_info.json").read())
|
||||
|
||||
trends = {}
|
||||
modes = {1: "SZ", 2: "TC", 3: "RM", 4: "CB"}
|
||||
for p in placements:
|
||||
year = p["year"]
|
||||
weapon = p["weapon"]
|
||||
mode = modes[p["mode"]]
|
||||
month = p["month"]
|
||||
weapon_obj = trends.get(weapon, {})
|
||||
year_obj = weapon_obj.get(
|
||||
year,
|
||||
{
|
||||
"SZ": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"TC": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"RM": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"CB": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
},
|
||||
)
|
||||
year_obj[mode][month] = year_obj[mode][month] + 1
|
||||
weapon_obj[year] = year_obj
|
||||
trends[weapon] = weapon_obj
|
||||
|
||||
sub = wpn_dict[weapon]["Sub"]
|
||||
special = wpn_dict[weapon]["Special"]
|
||||
|
||||
weapon_obj = trends.get(sub, {})
|
||||
year_obj = weapon_obj.get(
|
||||
year,
|
||||
{
|
||||
"SZ": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"TC": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"RM": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"CB": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
},
|
||||
)
|
||||
year_obj[mode][month] = year_obj[mode][month] + 1
|
||||
weapon_obj[year] = year_obj
|
||||
trends[sub] = weapon_obj
|
||||
|
||||
weapon_obj = trends.get(special, {})
|
||||
year_obj = weapon_obj.get(
|
||||
year,
|
||||
{
|
||||
"SZ": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"TC": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"RM": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"CB": [None, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
},
|
||||
)
|
||||
year_obj[mode][month] = year_obj[mode][month] + 1
|
||||
weapon_obj[year] = year_obj
|
||||
trends[special] = weapon_obj
|
||||
|
||||
to_bulk_add = []
|
||||
|
||||
for key in trends:
|
||||
trend_obj = {"weapon": key, "counts": []}
|
||||
for i in range(2018, 2024):
|
||||
if i in trends[key]:
|
||||
modes_obj = trends[key][i]
|
||||
modes_obj["year"] = i
|
||||
trend_obj["counts"].append(modes_obj)
|
||||
to_bulk_add.append(trend_obj)
|
||||
db.trends.delete_many({})
|
||||
db.trends.insert_many(to_bulk_add)
|
||||
|
||||
print("All done with updating X Trends!")
|
||||
|
||||
# Update Top 500 status of builds
|
||||
builds = db.builds.find({"top": False})
|
||||
|
||||
for document in builds:
|
||||
weapon = document["weapon"]
|
||||
user_doc = db.users.find_one({"discord_id": document["discord_id"]})
|
||||
if "twitter_name" not in user_doc:
|
||||
continue
|
||||
player_doc = db.players.find_one({"twitter": user_doc["twitter_name"].lower()})
|
||||
if player_doc is None:
|
||||
continue
|
||||
|
||||
if weapon in player_doc["weapons"]:
|
||||
db.builds.update_one({"_id": document["_id"]}, {"$set": {"top": True}})
|
||||
print(f"{weapon} build by {player_doc['name']} updated!")
|
||||
|
||||
print("All done with updatin Top 500 status of builds.")
|
||||
|
||||
# Update top 500 status of users
|
||||
users = db.users.update_many({"top500": False}, {"$set": {"top500": None}})
|
||||
|
||||
print("Set all top500 attributes of users to null where they previously were false.")
|
||||
|
||||
print("All done with everything!")
|
||||
Reference in New Issue
Block a user