# sync-from-notion.ps1

Write-Host "============================================================" -ForegroundColor Cyan
Write-Host "🔄 Notion → Excel → C# 클래스 통합 동기화" -ForegroundColor Cyan
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host ""

# Python 확인
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
    Write-Host "❌ Python이 설치되어 있지 않습니다." -ForegroundColor Red
    Write-Host "https://www.python.org 에서 설치해주세요." -ForegroundColor Yellow
    Write-Host ""
    pause
    exit 1
}

# ===== 1. 노션 → Excel =====
Write-Host "1️⃣ 노션 스키마 → Excel 동기화..." -ForegroundColor Yellow
Write-Host ""

Push-Location DataTools

try {
    python sync_from_notion.py
    $exitCode1 = $LASTEXITCODE
}
catch {
    Write-Host "❌ 실행 중 오류: $_" -ForegroundColor Red
    $exitCode1 = 1
}
finally {
    Pop-Location
}

if ($exitCode1 -ne 0) {
    Write-Host ""
    Write-Host "❌ Excel 동기화 실패!" -ForegroundColor Red
    Write-Host ""
    pause
    exit 1
}

Write-Host ""
Write-Host "✅ Excel 동기화 완료" -ForegroundColor Green
Write-Host ""

# ===== 2. C# 클래스 생성 =====
Write-Host "2️⃣ C# 클래스 자동 생성..." -ForegroundColor Yellow
Write-Host ""

Push-Location DataTools

try {
    python generate_csharp_classes.py
    $exitCode2 = $LASTEXITCODE
}
catch {
    Write-Host "❌ 실행 중 오류: $_" -ForegroundColor Red
    $exitCode2 = 1
}
finally {
    Pop-Location
}

if ($exitCode2 -ne 0) {
    Write-Host ""
    Write-Host "❌ C# 클래스 생성 실패!" -ForegroundColor Red
    Write-Host ""
    pause
    exit 1
}

Write-Host ""
Write-Host "✅ C# 클래스 생성 완료" -ForegroundColor Green
Write-Host ""

# ===== 완료 =====
Write-Host "============================================================" -ForegroundColor Green
Write-Host "🎉 모든 작업 완료!" -ForegroundColor Green
Write-Host "============================================================" -ForegroundColor Green
Write-Host ""

Write-Host "📋 다음 단계:" -ForegroundColor Cyan
Write-Host "  1. GameData 폴더에서 Excel 파일 확인" -ForegroundColor White
Write-Host "  2. Excel에서 데이터 수정" -ForegroundColor White
Write-Host "  3. Unity 열기" -ForegroundColor White
Write-Host "  4. Northbound → Data Importer 실행" -ForegroundColor White
Write-Host "  5. ScriptableObject 생성 확인" -ForegroundColor White
Write-Host ""

pause