# Writes minis_jobs.json for minis.py: every SKCombat animated token, its skin (texture + overlay pieces from
# annexes.json) and the clips the VTT plays (Unity frame ranges from the .fbx.meta files).
# Run: python -I minis_jobs.py <annexes.json> <out minis_jobs.json>
import sys, json
ann = json.load(open(sys.argv[1]))
SP = '[07]Spider/xsiT_Spider.fbx'
SK = '[06]Skeleton/xsiT_Skeleton.fbx'
spider_clips = {'spawn': [SP, 0, 50], 'idle': [SP, 100, 150], 'act': [SP, 200, 250], 'dead': [SP, 400, 450], 'hit': [SP, 600, 650]}
skel_clips = {'spawn': [SK, 0, 95], 'idle': [SK, 200, 250], 'hit': [SK, 300, 350], 'dead': ['[06]Skeleton/xsiT_SkeletonV3_Dead.fbx', 1, 40]}
FIG = '[00]Free/xsiT_BaseV3'
fig_clips = lambda idle: {'spawn': [FIG + '_Spawn.fbx', 1, 33], 'idle': [FIG + '_' + idle + '.fbx', 1, 49], 'dead': [FIG + '_Dead2.fbx', 1, 60]}
jobs = []
for name, tex, pack in [('spider-stone', 'spider-stone', 'Stone'), ('spider-widow', 'spider-widow', 'Widow'), ('spider-infernal', 'spider-infernal', 'Infernal'),
                        ('spider-mecha', 'spider-mecha', 'Mechanical'), ('spider-hairy', 'spider-hairy', 'Hairy'), ('spider-moss', 'spider-moss', 'Moss'),
                        ('spider-crystal', 'spider-crystal', 'Crystal')]:
    jobs.append({'name': name, 'base': SP, 'tex': tex, 'clips': spider_clips, 'overlays': [['[07]Spider/' + f, m, a] for f, m, a in ann['Spider'][pack]]})
for name, tex, pack in [('skeleton', 'skeleton-normal', 'Clear'), ('skeleton-armored', 'skeleton-armorm', 'Armor (heavy)'), ('skeleton-shielded', 'skeleton-armors', 'Armor (light)'),
                        ('skeleton-blood', 'skeleton-blood', 'Bloody'), ('skeleton-mecha', 'skeleton-mecha', 'Mechanical'), ('skeleton-moss', 'skeleton-moss', 'Moss'),
                        ('skeleton-ice', 'skeleton-ice', 'Frozen')]:
    jobs.append({'name': name, 'base': SK, 'tex': tex, 'clips': skel_clips, 'overlays': [['[06]Skeleton/' + f, m, a] for f, m, a in ann['Skeleton'][pack]]})
for name, idle in [('figure', 'Idle'), ('figure-barbarian', 'IdleBarbarian'), ('figure-knight', 'IdleKnight'), ('figure-mage', 'IdleMage'), ('figure-ranger', 'IdleRanger'), ('figure-rogue', 'IdleRogue')]:
    jobs.append({'name': name, 'base': FIG + '.fbx', 'tex': 'basic', 'clips': fig_clips(idle)})
for name, f, pre in [('man', '[00]Free/Human/xsiT_HumanM.fbx', 'M'), ('woman', '[00]Free/Human/xsiT_HumanF.fbx', 'F')]:
    jobs.append({'name': name, 'base': f, 'tex': 'basic', 'clips': {'idle': [f, 200, 250], 'act': [f, 500, 550]}})
json.dump(jobs, open(sys.argv[2], 'w'), indent=1)
print(len(jobs), 'jobs')
