# -*- coding: utf-8 -*-
from Bosses import *
from Enemies import *
from generator import *

if False:
    print('\n\n === Bosses ===')
    for a in bosses:
        print(a.name.plain(), end = ', ')
    print('\n\n === Enemies ===')
    for a in enemies:
        print(a.name.plain(), end = ', ')

gen = Generator(tutorial, "bosses", "Tutorial")
gen.make()
gen = Generator(b_floor_1, "bosses", "Floor 1")
gen.make()
gen = Generator(b_floor_2, "bosses", "Floor 2" )
gen.make()

gen = Generator(e_floor_1, floor = "Floor 1")
gen.make()
gen = Generator(e_floor_2, floor = "Floor 2" )
gen.make()
gen = Generator(e_others, floor = "Others")
gen.make()

# ====== Enemies ========
stone_marker = open('../enemies_py/functions/1_stone_marker.mcfunction', 'w')
spawn_enemies = open('../enemies_py/functions/0_spawn_enemy.mcfunction',"w")
for mob in enemies:
    spawn_enemies.write('execute if entity @s[tag={0}] run function enemies_py:{0}\n'.format(mob.name_))
    stone_marker.write('give @s stone{{type:"{0}",display:{{Name:{1}{{"text":"{0}"}}{1}}}}} 64\n'.format(mob.name_,"'"))
spawn_enemies.write('\nkill @s')
spawn_enemies.close()
stone_marker.close()

# ====== Bosses ========
bossbar_name = open('../bosses_py/functions/1_bossbar_name.mcfunction', 'w')
spawn_bosses = open('../bosses_py/functions/0_spawn_boss.mcfunction', "w")
for mob in bosses:
    spawn_bosses.write('execute if entity @s[tag={0}] run function bosses_py:{0}\n'.format(mob.name_))
    bossbar_name.write('execute if entity @s[tag={0}] run bossbar set boss name {{"text":"{1}","color":"red"}}\n'.format(mob.name_, mob.name.plain()))
spawn_bosses.close()
bossbar_name.close()

total = len(bosses) + len(enemies)
print('\n\t· Bosses: {0}, Enemies: {1}, Total:{2}\n'.format(len(bosses), len(enemies), total))


"""
Entity(
    mob = "<str>",
    name = JTxt("<JTxt>", color = "red"),
    hp = 1.3,
    baby = False,
    follow_range = 1.2,
    movement_speed = 1.5,
    attack_damage = 4.2,
    knockback_resistance = 0.3,
    right_hand = 'id:"flint",Count:1,tag:{CustomModelData:3001}',
    left_hand = '<nbt>',
    feet = 'id:"leather_leggings",Count:1',
    legs = '<nbt>',
    chest = '<nbt>',
    head = '<nbt>',
    tags =  ["enemy","boss"],
    silent = False,
    eClock = False)
"""
