File size: 1,925 Bytes
c2dd0f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from src.utils import load_json
from tinydb import TinyDB
import os

db_path = './db.json'
if os.path.exists(db_path):
    print("del db")
    os.remove(db_path)
db = TinyDB(db_path)

material = db.table('material')
for id,data in load_json("./data/药材.json").items():
    name = data["name"]
    level = data["level"]
    material.insert({'name': f"{name}({level[:2]})", 'level': level,
               'main_temp': data["主药"]["h_a_c"]["type"]*data["主药"]["h_a_c"]["power"],
               'main_func_t': data["主药"]["type"],
               'main_func_p': data["主药"]["power"],
               'phar_temp': data["药引"]["h_a_c"]["type"]*data["药引"]["h_a_c"]["power"],
               'auxi_func_t': data["辅药"]["type"],
               'auxi_func_p': data["主药"]["power"],
               })


medicine = db.table('medicine')
for id,data in load_json("./data/炼丹丹药.json").items():
    name = data["name"]
    desc = data["desc"]

    if "点修为" in desc:
        type = "增加修为"
    elif "概率提升" in desc:
        type = "突破概率"
    elif "点攻击力" in desc:
        type = "加攻击力"
    else:
        print(desc)
        type = "???"

    if type == "突破概率":
        state_f = data["境界"][0:3]
        t = desc.split(",")[1]
        state_t = t[2:5]
        name = name + f"({state_f}->{state_t})"
    elif type == "增加修为":
        num = desc[7:-4]
        name = name + f"(修{num})"
    elif type == "加攻击力":
        num = desc[9:-5]
        name = name + f"(攻{num})"

    elixir_config = data["elixir_config"]
    l0 = []
    for key,i in elixir_config.items():
        l0.append((int(key),i))
    medicine.insert(
        {
            "name":name,
            "type":type,
            "func1_type":l0[0][0],
            "func1_power":l0[0][1],
            "func2_type": l0[1][0],
            "func2_power": l0[1][1]
        }
    )