-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake-team.py
executable file
·72 lines (58 loc) · 2.33 KB
/
make-team.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
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
66
67
68
69
70
71
72
#!/usr/bin/env python3
import json
import re
background = "grass field"
team_1 = [
("fish", "lucky", 3, 10, 50, "abandon"),
("fish", "lucky", 3, 10, 50, "abandon"),
("fish", "lucky", 3, 10, 50, "abandon"),
("fish", "lucky", 3, 10, 50, "abandon"),
("fish", "lucky", 3, 10, 50, "abandon"),
]
team_2 = [
("worm", "lucky", 3, 10, 50, "trophy"),
("worm", "lucky", 3, 10, 50, "trophy"),
("worm", "lucky", 3, 10, 50, "trophy"),
("worm", "lucky", 3, 10, 50, "trophy"),
("worm", "lucky", 3, 10, 50, "trophy"),
]
with open("data/abilities.json") as f:
abilities = json.load(f)
with open("data/animals.json") as f:
animals = json.load(f)
with open("data/backgrounds.json") as f:
backgrounds = json.load(f)
with open("data/battle.json") as f:
data = json.load(f)
with open("data/hats.json") as f:
hats = json.load(f)
with open("data/perks.json") as f:
perks = json.load(f)
def transform_ability(ability_id, level):
return {
"Enum": ability_id,
"Level": level,
"Native": True,
"Duration": 0,
"TriggerCount": 1
}
def edit_board(team, board_name, board_background, index_function):
global data
for i, (animal, perk, level, attack, health, hat) in enumerate(team):
index = index_function(i)
animal_id = animals.get(animal)
if animal_id != None:
data[board_name]["Minions"]["Items"][index]["Enum"] = animal_id
data[board_name]["Minions"]["Items"][index]["Abilities"] = [transform_ability(ability_id, level) for ability_id in (abilities.get(animal) or [])]
data[board_name]["Minions"]["Items"][index]["Level"] = level
data[board_name]["Minions"]["Items"][index]["Perk"] = perks.get(perk)
data[board_name]["Minions"]["Items"][index]["Attack"]["Permanent"] = attack
data[board_name]["Minions"]["Items"][index]["Health"]["Permanent"] = health
data[board_name]["Minions"]["Items"][index]["Cosmetic"] = hats.get(hat) or 0
else:
data[board_name]["Minions"]["Items"][index] = None
data[board_name]["Background"] = backgrounds.get(board_background)
edit_board(team_1, "UserBoard", background, lambda i: i)
edit_board(team_2, "OpponentBoard", background, lambda i: 4-i)
with open("generated-battle.json", "w") as f:
json.dump(data, f, indent=2)