def write_animation(out, aa, name): c = [0, 0] for a in aa: count_animations(out, name, a, c) if c[1] > 1: out.write("%d (%d)" % (c[0], c[1])) else: out.write("%d" % c[0]) def count_animations(out, name, a, c): frames = a.get_subs("frame") if frames: c[0] += len(frames) c[1] += 1 for a2 in a.get_subs("animation"): count_animations(out, name, a2, c) for a2 in a.get_subs("if"): count_animations(out, name, a2, c) for a2 in a.get_subs("else"): count_animations(out, name, a2, c) def write_table_row(out, unit, color, name = None): anim_types = [ "attack_anim", "defend", "death", "idle_anim", "movement_anim", "leading_anim", "teleport", "standing_anim", "healing_anim", "victory_anim", "poison_anim", "healed_anim", "recruit_anim", "levelin_anim", "levelout_anim", "extra_anim", ] needed = {} for at in anim_types: needed[at] = True needed["healing_anim"] = False needed["leading_anim"] = False needed["teleport"] = False for abil in unit.get_subs("abilities"): if abil.get_subs("heals"): needed["healing_anim"] = True if abil.get_subs("leadership"): needed["leading_anim"] = True if abil.get_subs("teleport"): needed["teleport"] = True if name == None: name = unit.id out.write("
id | attack | defend | death | idle | movement | leading | teleport | standing | healing | victory | poison | healed | recruit | level in | level out | extra | """.lstrip()) f.write("
---|