#!/usr/bin/env python3
"""개선 요청사항 확인 스크립트"""
import json
from pathlib import Path

val_file = Path("D:/Work/WorldStalker/DS-전투분석_저장소/분석결과/20251024_213233_v2/validated_data.json")
with open(val_file, 'r', encoding='utf-8') as f:
    data = json.load(f)

print("=" * 80)
print("개선 요청사항 확인")
print("=" * 80)

# 1. CastingTime 확인
print("\n1. CastingTime 수집 현황")
print("-" * 80)
casting_skills = []
for stalker_id, stalker_data in data.items():
    skills = stalker_data.get('skills', {})
    for skill_id, skill in skills.items():
        casting_time = skill.get('castingTime', 0)
        if casting_time > 0:
            casting_skills.append({
                'stalker': stalker_id,
                'skillId': skill_id,
                'name': skill.get('name'),
                'castingTime': casting_time
            })

print(f"시전시간이 있는 스킬: {len(casting_skills)}개")
for item in casting_skills[:10]:
    print(f"  [{item['stalker']}] {item['skillId']} - {item['name']}: {item['castingTime']}초")

# 2. SK170101 소수점 문제 확인
print("\n2. SK170101 (카지모르드 흘리기) 소수점 문제")
print("-" * 80)
cazi = data['cazimord']
sk170101 = cazi['skills']['SK170101']
print(f"DescValues (원본): {sk170101.get('descValues')}")
print(f"DescFormatted: {sk170101.get('descFormatted')[:100]}...")

# 3. Projectile Shot TriggerTime 확인
print("\n3. Projectile Shot 노티파이 TriggerTime")
print("-" * 80)

projectile_skills = []
for stalker_id, stalker_data in data.items():
    skills = stalker_data.get('skills', {})
    for skill_id, skill in skills.items():
        montages = skill.get('montageData', [])
        for montage in montages:
            all_notifies = montage.get('allNotifies', [])
            for notify in all_notifies:
                notify_class = notify.get('NotifyClass', '')
                if 'Trigger_Projectile_Shot' in notify_class:
                    projectile_skills.append({
                        'stalker': stalker_id,
                        'skillId': skill_id,
                        'name': skill.get('name'),
                        'montage': montage.get('assetName'),
                        'triggerTime': notify.get('TriggerTime', 0),
                        'sequenceLength': montage.get('sequenceLength', 0),
                        'actualDuration': montage.get('actualDuration', 0)
                    })

print(f"Projectile Shot 노티파이가 있는 스킬: {len(projectile_skills)}개")
for item in projectile_skills[:10]:
    print(f"  [{item['stalker']}] {item['skillId']} - {item['name']}")
    print(f"    Montage: {item['montage']}")
    print(f"    TriggerTime: {item['triggerTime']:.3f}초 (전체: {item['actualDuration']:.2f}초)")
    print(f"    빠른 발사: {item['actualDuration'] - item['triggerTime']:.3f}초 단축 가능")

# 4. DoT 스킬 확인
print("\n4. DoT 스킬 현황")
print("-" * 80)
dot_skills = []
for stalker_id, stalker_data in data.items():
    skills = stalker_data.get('skills', {})
    for skill_id, skill in skills.items():
        is_dot = skill.get('isDot', False)
        if is_dot:
            dot_skills.append({
                'stalker': stalker_id,
                'skillId': skill_id,
                'name': skill.get('name'),
                'damageRate': skill.get('skillDamageRate', 0)
            })

print(f"DoT 스킬: {len(dot_skills)}개")
for item in dot_skills:
    print(f"  [{item['stalker']}] {item['skillId']} - {item['name']}: rate={item['damageRate']}")

# 5. descValues 소수점 문제가 있는 스킬 찾기
print("\n5. descValues 소수점 문제 스킬 찾기")
print("-" * 80)
long_decimal_skills = []
for stalker_id, stalker_data in data.items():
    skills = stalker_data.get('skills', {})
    for skill_id, skill in skills.items():
        desc_values = skill.get('descValues', [])
        for val in desc_values:
            if isinstance(val, float):
                # 소수점 자리수가 2보다 크면
                val_str = str(val)
                if '.' in val_str:
                    decimal_part = val_str.split('.')[1]
                    if len(decimal_part) > 2:
                        long_decimal_skills.append({
                            'stalker': stalker_id,
                            'skillId': skill_id,
                            'name': skill.get('name'),
                            'value': val,
                            'rounded': round(val, 2)
                        })
                        break

print(f"소수점 문제가 있는 스킬: {len(long_decimal_skills)}개")
for item in long_decimal_skills:
    print(f"  [{item['stalker']}] {item['skillId']} - {item['name']}")
    print(f"    원본: {item['value']}")
    print(f"    반올림: {item['rounded']}")
