#!/usr/bin/env python3
"""
궁극기 GameplayEffectSet 확인
"""

import json
import sys
from pathlib import Path

STALKERS = ['hilda', 'urud', 'nave', 'baran', 'rio', 'clad', 'rene', 'sinobu', 'lian', 'cazimord']

def main():
    if len(sys.argv) < 2:
        print("사용법: python check_ultimate_effects.py <DataTable.json 경로>")
        sys.exit(1)

    json_path = Path(sys.argv[1])

    with open(json_path, 'r', encoding='utf-8') as f:
        data = json.load(f)

    assets = data.get('Assets', [])

    # DT_CharacterStat에서 궁극기 ID 추출
    dt_char_stat = next((dt for dt in assets if dt.get('AssetName') == 'DT_CharacterStat'), None)
    stalker_ultimates = {}
    for row in dt_char_stat.get('Rows', []):
        row_name = row['RowName']
        if row_name in STALKERS:
            stalker_ultimates[row_name] = row['Data'].get('ultimateSkill', '')

    # DT_Skill에서 궁극기 정보 확인
    dt_skill = next((dt for dt in assets if dt.get('AssetName') == 'DT_Skill'), None)

    print("=" * 100)
    print("궁극기 GameplayEffectSet 확인")
    print("=" * 100)

    for stalker in STALKERS:
        ult_id = stalker_ultimates.get(stalker, '')
        if not ult_id:
            continue

        skill_row = next((row for row in dt_skill['Rows'] if row['RowName'] == ult_id), None)
        if not skill_row:
            continue

        data_field = skill_row['Data']

        print(f"\n【{stalker.upper()}】 {ult_id}")
        print(f"  이름: {data_field.get('name', 'N/A')}")
        print(f"  간단 설명: {data_field.get('simpleDesc', 'N/A')}")
        print(f"  skillDamageRate: {data_field.get('skillDamageRate', 0)}")
        print(f"  skillAttackType: {data_field.get('skillAttackType', 'N/A')}")

        effect_set = data_field.get('gameplayEffectSet', [])
        if effect_set:
            print(f"  gameplayEffectSet: {len(effect_set)}개 효과")
            for i, effect in enumerate(effect_set, 1):
                print(f"    [{i}] {effect}")
        else:
            print(f"  gameplayEffectSet: 비어있음 → Blueprint 확인 필요")

if __name__ == "__main__":
    main()
