"""리옌 연화, 정조준 몽타주 확인 (수정)"""
import json

with open('../../원본데이터/AnimMontage.json', 'r', encoding='utf-8') as f:
    montage_data = json.load(f)

with open('../../원본데이터/DataTable.json', 'r', encoding='utf-8') as f:
    dt_data = json.load(f)

# DT_Skill에서 SK190201, SK190101의 몽타주 이름 찾기
dt_skill = None
for asset in dt_data.get('Assets', []):
    if asset.get('AssetName') == 'DT_Skill':
        dt_skill = asset
        break

print("=== 리옌 스킬 몽타주 확인 ===\n")

target_skills = {
    'SK190201': '연화',
    'SK190101': '정조준'
}
skill_montages = {}

for row in dt_skill.get('Rows', []):
    row_name = row.get('RowName', '')
    if row_name in target_skills:
        row_data = row.get('Data', {})
        use_montages = row_data.get('useMontages', [])
        skill_name = row_data.get('name', '')

        print(f"[{row_name}] {skill_name}")
        print(f"  useMontages: {len(use_montages)}개")

        if use_montages:
            montage_path = use_montages[0]
            print(f"  Path: {montage_path}")

            # 몽타주 이름 추출
            montage_name = montage_path.split('/')[-1].replace("'", "").split('.')[0]
            skill_montages[row_name] = montage_name
            print(f"  Name: {montage_name}\n")

# 각 몽타주에서 노티파이 확인
print("\n=== 몽타주 노티파이 확인 ===\n")

for skill_id, montage_name in skill_montages.items():
    for asset in montage_data.get('Assets', []):
        if asset.get('AssetName') == montage_name:
            print(f"[{skill_id}] {target_skills[skill_id]} - {montage_name}")

            notifies = asset.get('AnimNotifies', [])
            print(f"  총 노티파이: {len(notifies)}개\n")

            found_attack_notify = False

            for idx, notify in enumerate(notifies):
                notify_class = notify.get('NotifyClass', '')

                # SimpleSendEvent 노티파이
                if 'SimpleSendEvent' in notify_class:
                    custom_props = notify.get('CustomProperties', {})
                    event_tag = custom_props.get('Event Tag', '')

                    # Event.SpawnProjectile 또는 Event.SkillActivate 확인
                    if 'SpawnProjectile' in event_tag or 'SkillActivate' in event_tag:
                        print(f"  [{idx}] SimpleSendEvent")
                        print(f"      Event Tag: {event_tag}")
                        print(f"      >>> 공격 스킬 판정!")
                        found_attack_notify = True
                        print()

                # Projectile 노티파이
                if 'Projectile' in notify_class:
                    print(f"  [{idx}] Projectile 노티파이")
                    print(f"      NotifyClass: {notify_class}")
                    trigger_time = notify.get('TriggerTime', 0)
                    print(f"      TriggerTime: {trigger_time}")

                    if 'ProjectileShot' in notify_class or 'Trigger_Projectile' in notify_class:
                        print(f"      >>> 공격 스킬 판정!")
                        found_attack_notify = True
                    print()

            if not found_attack_notify:
                print("  *** 공격 노티파이를 찾지 못했습니다. ***\n")

            print("-" * 60)
            print()
