move things into aux file
This commit is contained in:
parent
ced50b363c
commit
d8a5542abc
4 changed files with 118 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,4 +2,5 @@
|
|||
*.sqlite
|
||||
*.sqlite-shm
|
||||
*.sqlite-wal
|
||||
.env
|
||||
.env
|
||||
aux/**.json
|
76
aux/filter_raw_character_data
Executable file
76
aux/filter_raw_character_data
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
raw_json = json.load(sys.stdin)
|
||||
|
||||
tags = {
|
||||
1: "Guard",
|
||||
2: "Sniper",
|
||||
3: "Defender",
|
||||
4: "Medic",
|
||||
5: "Supporter",
|
||||
6: "Caster",
|
||||
7: "Specialist",
|
||||
8: "Vanguard",
|
||||
9: "Melee",
|
||||
10: "Ranged",
|
||||
11: "Top Operator",
|
||||
12: "Crowd-Control",
|
||||
13: "Nuker",
|
||||
14: "Senior Operator",
|
||||
15: "Healing",
|
||||
16: "Support",
|
||||
17: "Starter",
|
||||
18: "DP-Recovery",
|
||||
19: "DPS",
|
||||
20: "Survival",
|
||||
21: "AoE",
|
||||
22: "Defense",
|
||||
23: "Slow",
|
||||
24: "Debuff",
|
||||
25: "Fast-Redeploy",
|
||||
26: "Shift",
|
||||
27: "Summon",
|
||||
28: "Robot"
|
||||
}
|
||||
|
||||
char_data = {}
|
||||
en_recruitable = {}
|
||||
cn_recruitable = {}
|
||||
for key, entry in raw_json.items():
|
||||
parsed_data = {
|
||||
"stars": entry["star"],
|
||||
"tags": entry["tags"],
|
||||
# 0 = headhunt only, 1 = china only, 2 = global
|
||||
"recruitment": min(len(entry["recruitment"]), 2)
|
||||
}
|
||||
op_name = entry["appellation"]
|
||||
char_data[op_name] = parsed_data
|
||||
|
||||
if parsed_data["recruitment"] == 2:
|
||||
for tag in entry["tags"]:
|
||||
if tags[tag] not in en_recruitable:
|
||||
en_recruitable[tags[tag]] = []
|
||||
if tags[tag] not in cn_recruitable:
|
||||
cn_recruitable[tags[tag]] = []
|
||||
|
||||
en_recruitable[tags[tag]].append(op_name)
|
||||
cn_recruitable[tags[tag]].append(op_name)
|
||||
elif parsed_data["recruitment"] == 1:
|
||||
for tag in entry["tags"]:
|
||||
if tags[tag] not in cn_recruitable:
|
||||
cn_recruitable[tags[tag]] = []
|
||||
cn_recruitable[tags[tag]].append(op_name)
|
||||
|
||||
project_root = sys.argv[1]
|
||||
|
||||
with open(project_root + "/aux/char_data.json", "w") as f:
|
||||
f.write(json.dumps(char_data))
|
||||
|
||||
with open(project_root + "/aux/en_recruitable.json", "w") as f:
|
||||
f.write(json.dumps(en_recruitable))
|
||||
|
||||
with open(project_root + "/aux/cn_recruitable.json", "w") as f:
|
||||
f.write(json.dumps(cn_recruitable))
|
8
aux/get_recruit_data
Executable file
8
aux/get_recruit_data
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_ROOT=$(cargo locate-project | sed -E 's#.*"(/.*)/Cargo.toml"}#\1#')
|
||||
DATASET="https://raw.githubusercontent.com/Tsuk1ko/arknights-toolbox/master/src/data/character.json"
|
||||
|
||||
curl "$DATASET" | cat | "$PROJECT_ROOT"/aux/filter_raw_character_data "$PROJECT_ROOT"
|
32
aux/init_db
Executable file
32
aux/init_db
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DB_NAME="data.sqlite"
|
||||
PROJECT_ROOT=$(cargo locate-project | sed -E 's#.*"(/.*)/Cargo.toml"}#\1#')
|
||||
|
||||
if [ ! -f "$PROJECT_ROOT/$DB_NAME" ]; then
|
||||
sqlite3 "$PROJECT_ROOT/$DB_NAME" <<EOF
|
||||
CREATE TABLE IF NOT EXISTS Heck (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,
|
||||
count INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS RollCount (
|
||||
user_id TEXT PRIMARY KEY UNIQUE NOT NULL,
|
||||
count INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS OperatorCount (
|
||||
user_id TEXT NOT NULL,
|
||||
operator TEXT NOT NULL,
|
||||
count INTEGER NOT NULL,
|
||||
UNIQUE(user_id, operator)
|
||||
);
|
||||
|
||||
INSERT INTO Heck (id, count) VALUES (1, 0)
|
||||
ON CONFLICT(id) DO NOTHING;
|
||||
EOF
|
||||
else
|
||||
echo "$DB_NAME exists, exiting."
|
||||
fi
|
Loading…
Reference in a new issue