Compare commits
6 Commits
a07f37a2a3
...
7cb17aeb3a
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cb17aeb3a | |||
| aab93dad02 | |||
| e7f30ecea4 | |||
| af487ff9f5 | |||
| f6ccf8d807 | |||
| 4ae964c90f |
1829
agents.json
Normal file
1829
agents.json
Normal file
File diff suppressed because it is too large
Load Diff
57
agents.py
Normal file
57
agents.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import psycopg2, json
|
||||
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS agents (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
rarity uuid REFERENCES rarity(id) NOT NULL,
|
||||
name varchar NOT NULL,
|
||||
display varchar NOT NULL,
|
||||
def_index integer NOT NULL,
|
||||
team integer NOT NULL, -- 0 = CT, 1 = T, 2 = BOTH
|
||||
model_player varchar NOT NULl
|
||||
);
|
||||
"""
|
||||
|
||||
conn = psycopg2.connect("dbname=porning user=aindustries")
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("SELECT * FROM rarity")
|
||||
raw_rarity = cur.fetchall()
|
||||
rarity = {rarity[1]: rarity[0] for rarity in raw_rarity}
|
||||
|
||||
with open("agents.json", "r") as f:
|
||||
content = json.load(f)
|
||||
|
||||
agents = {}
|
||||
|
||||
for raw in content:
|
||||
if raw["id"] in agents:
|
||||
continue
|
||||
|
||||
team = raw["team"]["id"]
|
||||
|
||||
if team == "counter-terrorists":
|
||||
team = 0
|
||||
elif team == "terrorists":
|
||||
team = 1
|
||||
else:
|
||||
team = 2
|
||||
|
||||
agent = {
|
||||
"name": raw["id"],
|
||||
"display": raw["name"],
|
||||
"def_index": raw["def_index"],
|
||||
"team": team,
|
||||
"model_player": raw["model_player"],
|
||||
"rarity": rarity[raw["rarity"]["name"]]
|
||||
}
|
||||
|
||||
agents[agent["name"]] = agent
|
||||
|
||||
for agent in agents.values():
|
||||
cur.execute("INSERT INTO agents (name, display, def_index, team, model_player, rarity) VALUES (%s, %s, %s, %s, %s, %s)", (agent["name"], agent["display"], agent["def_index"], agent["team"], agent["model_player"], agent["rarity"]))
|
||||
|
||||
conn.commit()
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
46
images.py
Normal file
46
images.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import json, requests, os
|
||||
|
||||
os.mkdir("skins")
|
||||
|
||||
with open("skins.json", "r") as f:
|
||||
content = json.load(f)
|
||||
|
||||
for skin in content:
|
||||
url = skin["image"]
|
||||
weapon = skin["weapon"]["id"]
|
||||
paint_index = skin["paint_index"]
|
||||
|
||||
if "sfui_wpnhud" in weapon:
|
||||
continue
|
||||
|
||||
content = requests.get(url).content
|
||||
|
||||
with open(f"skins/{weapon}_{paint_index}.png", "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
with open("base_weapons.json", "r") as f:
|
||||
content = json.load(f)
|
||||
|
||||
for skin in content:
|
||||
url = skin["image"]
|
||||
weapon = skin["id"].replace("base_weapon-", "")
|
||||
|
||||
if "sfui_wpnhud" in weapon:
|
||||
continue
|
||||
|
||||
content = requests.get(url).content
|
||||
|
||||
with open(f"skins/{weapon}_0.png", "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
with open("agents.json", "r") as f:
|
||||
content = json.load(f)
|
||||
|
||||
for skin in content:
|
||||
url = skin["image"]
|
||||
weapon = skin["id"]
|
||||
|
||||
content = requests.get(url).content
|
||||
|
||||
with open(f"skins/{weapon}_0.png", "wb") as f:
|
||||
f.write(content)
|
||||
6
import_all.sh
Executable file
6
import_all.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
source .venv/bin/activate
|
||||
|
||||
python weapons.py
|
||||
python rarity.py
|
||||
python skins.py
|
||||
python agents.py
|
||||
20
rarity.py
20
rarity.py
@@ -27,6 +27,26 @@ for raw in content:
|
||||
|
||||
rarities[rarity["display"]] = rarity
|
||||
|
||||
with open("agents.json", "r") as f:
|
||||
content = json.load(f)
|
||||
|
||||
for raw in content:
|
||||
if raw["rarity"]["name"] in rarities:
|
||||
continue
|
||||
|
||||
rarity = {
|
||||
"display": raw["rarity"]["name"],
|
||||
"color": raw["rarity"]["color"]
|
||||
}
|
||||
|
||||
rarities[rarity["display"]] = rarity
|
||||
|
||||
# Missing rarity for default skins
|
||||
rarities["Stock"] = {
|
||||
"display": "Stock",
|
||||
"color": "#ded6cc"
|
||||
}
|
||||
|
||||
for rarity in rarities.values():
|
||||
cur.execute("INSERT INTO rarity (display, color) VALUES (%s, %s)", (rarity["display"], rarity["color"]))
|
||||
|
||||
|
||||
8
skins.py
8
skins.py
@@ -3,8 +3,8 @@ import psycopg2, json
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS skins (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
weapon uuid REFERENCES weapons(id),
|
||||
rarity uuid REFERENCES rarity(id),
|
||||
weapon uuid REFERENCES weapons(id) NOT NULL,
|
||||
rarity uuid REFERENCES rarity(id) NOT NULL,
|
||||
paint_index integer NOT NULL,
|
||||
display varchar NOT NULL,
|
||||
min_float float NOT NULL,
|
||||
@@ -47,9 +47,9 @@ for raw in content:
|
||||
for weapon in weapons.keys():
|
||||
skin = {
|
||||
"weapon": weapons[weapon],
|
||||
"rarity": rarity["Covert"],
|
||||
"rarity": rarity["Stock"],
|
||||
"paint_index": 0,
|
||||
"display": "Default",
|
||||
"display": "",
|
||||
"min_float": 0,
|
||||
"max_float": 0,
|
||||
"legacy": True
|
||||
|
||||
33
weapons.py
33
weapons.py
@@ -42,6 +42,39 @@ for raw in content:
|
||||
|
||||
weapons[weapon["name"]] = weapon
|
||||
|
||||
# Default knives and gloves that are not in the json
|
||||
weapons["weapon_knife_t"] = {
|
||||
"name": "weapon_knife_t",
|
||||
"display": "Knife",
|
||||
"def_index" : 59,
|
||||
"category": "Knives",
|
||||
"team": 1
|
||||
}
|
||||
|
||||
weapons["weapon_knife"] = {
|
||||
"name": "weapon_knife",
|
||||
"display": "Knife",
|
||||
"def_index" : 42,
|
||||
"category": "Knives",
|
||||
"team": 0
|
||||
}
|
||||
|
||||
weapons["t_gloves"] = {
|
||||
"name": "t_gloves",
|
||||
"display": "Default T Gloves",
|
||||
"def_index" : 5028,
|
||||
"category": "Gloves",
|
||||
"team": 1
|
||||
}
|
||||
|
||||
weapons["ct_gloves"] = {
|
||||
"name": "ct_gloves",
|
||||
"display": "Default CT Gloves",
|
||||
"def_index" : 5029,
|
||||
"category": "Gloves",
|
||||
"team": 0
|
||||
}
|
||||
|
||||
for weapon in weapons.values():
|
||||
cur.execute("INSERT INTO weapons (name, display, def_index, category, team) VALUES (%s, %s, %s, %s, %s)", (weapon["name"], weapon["display"], weapon["def_index"], weapon["category"], weapon["team"]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user