aboutsummaryrefslogtreecommitdiff
path: root/assets/json/enemies_gen.py
blob: 8e1ba8891be4ffbe787a8fa28b5646ce24246cd1 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
nodes = [
    'T', 'kT', 'dkT',
    'aT', 'kaT', 'dkaT', 'aaT', 'daaT', 'kdaaT', 
    'dkdaaT', 'aaaT', 'daaaT', 'daT', 'kdaT', 'dkdaT', 'saT', 'dsaT',
    'sT', 'ksT', 'dksT', 'asT', 'dasT', 'kdasT', 
    'dkdasT', 'aasT', 'daasT', 'dsT', 'kdsT', 'dkdsT', 'ssT', 'dssT'
]

edges = {
    'kT': 'T',
    'dkT': 'kT',
    'aT': 'T',
    'kaT': 'aT',
    'dkaT': 'kaT',
    'aaT': 'aT',
    'daaT': 'aaT',
    'kdaaT': 'daaT',
    'dkdaaT': 'kdaaT',
    'aaaT': 'aaT',
    'daaaT': 'aaaT',
    'daT': 'aT',
    'kdaT': 'daT',
    'dkdaT': 'kdaT',
    'saT': 'aT',
    'dsaT': 'saT',
    'sT': 'T',
    'ksT': 'sT',
    'dksT': 'ksT',
    'asT': 'sT',
    'dasT': 'asT',
    'kdasT': 'dasT',
    'dkdasT': 'kdasT',
    'aasT': 'asT',
    'daasT': 'aasT',
    'dsT': 'sT',
    'kdsT': 'dsT',
    'dkdsT': 'kdsT',
    'ssT': 'sT',
    'dssT': 'ssT',
}

base = {
    "lives": 10,
    "speed": 1,
    "damage": 1,
    "spawn_num": 1
}

bonus = {
    "T": {},
    "k": { "speed": 1.2 },
    "a": { "damage": 2 },
    "d": { "spawn_num": 2 },
    "s": { "speed": 0.8, "lives": 3 },
}

colors = {
    "T": [1, 1, 1, 1],
    "k": [0.2, 0.7, 0, 1],
    "a": [1, 0, 0, 1],
    "d": [0, 0.4, 1, 1],
    "s": [1, 1, 0, 1],
}

def get_stats (node):
    stats = base.copy()
    bonuses = { k:1 for k in stats }
    for char in node:
        effects = bonus[char]
        for e in effects:
            bonuses[e] = effects[e] * bonuses[e]

    for s in stats:
        stats[s] *= bonuses[s]
    return stats

def get_color (node):
    color = [0,0,0,0]
    for r in node:
        for i in range(len(color)): color[i] += colors[r][i]
    for i in range(len(color)): color[i] /= len(node)
    return color

def get_enemy (node):
    enemy = get_stats(node)
    enemy['name'] = node
    if node in edges:
        enemy['spawn_on_death'] = edges[node]
    else: enemy['spawn_num'] = 0
    enemy["model_name"] = node + '.glb'
    enemy["thumbnail_name"] = node + '.png'
    enemy["resource"] = node[0]
    enemy["color"] = get_color(node)
    return enemy


def main ():
    enemies = []
    for n in nodes:
        enemies += [ get_enemy(n) ]
    
    import json
    raw = json.dumps(enemies, indent=4)
    with open("enemies.json", "w") as f: f.write(raw)

if __name__ == "__main__": main()