-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_effect_to_mode.py
29 lines (22 loc) · 1015 Bytes
/
add_effect_to_mode.py
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
import json
from tabletop_name_import import get_description
import os
userSavesPath = os.path.expanduser("~/Documents/My Games/Tabletop Simulator/Saves/")
with open(f"{userSavesPath}TS_Save_13.json", "r", encoding="utf-8") as file:
tt_dict = json.load(file)
for deck in tt_dict["ObjectStates"]:
if deck["Name"] == "DeckCustom" or deck["Name"] == "Deck":
cards_arr = deck["ContainedObjects"]
elif deck["Name"] == "Infinite_Bag" and deck["Nickname"] != "":
cards_arr = deck["ContainedObjects"][0]["ContainedObjects"]
else:
continue
for card in cards_arr:
nickname = card["Nickname"]
if (card["GUID"] == "" and card["Nickname"] == "") or card["Nickname"] == "BS41-X07":
continue
card["Description"] = get_description(nickname)
print(card["Description"])
print(card["Nickname"])
with open(f"{userSavesPath}TS_Save_13.json", "w", encoding="utf-8") as file:
json.dump(tt_dict, file, ensure_ascii=False, indent=4)