Improve Korean text readability checks
This commit is contained in:
@@ -32,6 +32,23 @@ function Fail($Message) {
|
||||
throw $Message
|
||||
}
|
||||
|
||||
function Check-Readable-Korean-Text([string]$Text, [string]$Context, [switch]$RequireHangul) {
|
||||
if ([string]::IsNullOrWhiteSpace($Text)) {
|
||||
Fail "$Context must not be empty."
|
||||
}
|
||||
$replacementCharacter = [string][char]0xFFFD
|
||||
if ($Text.Contains($replacementCharacter)) {
|
||||
Fail "$Context contains a replacement character; check UTF-8 encoding."
|
||||
}
|
||||
if ($Text -match '\p{IsCJKUnifiedIdeographs}') {
|
||||
Fail "$Context contains Hanja/CJK ideographs; use Korean-facing Hangul text."
|
||||
}
|
||||
$needsHangul = $RequireHangul -or $script:CurrentScenarioRequiresHangul
|
||||
if ($needsHangul -and $Text -notmatch '\p{IsHangulSyllables}') {
|
||||
Fail "$Context should contain readable Hangul text."
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Raw-Skills-Arrays() {
|
||||
$relativePaths = @(
|
||||
"data\defs\classes.json",
|
||||
@@ -80,6 +97,8 @@ $officerIds = Get-Names $officers
|
||||
$skillIds = Get-Names $skills
|
||||
$terrainKeys = Get-Names $terrain
|
||||
|
||||
$script:CurrentScenarioRequiresHangul = $false
|
||||
|
||||
$validConditionTypes = @(
|
||||
"all_units_defeated",
|
||||
"all_enemies_defeated",
|
||||
@@ -171,6 +190,7 @@ foreach ($scenario in @($campaign.scenarios)) {
|
||||
if ([string]::IsNullOrWhiteSpace($scenarioTitle)) {
|
||||
Fail "Campaign scenario $scenarioId has an empty title."
|
||||
}
|
||||
Check-Readable-Korean-Text $scenarioTitle "Campaign scenario $scenarioId title" -RequireHangul
|
||||
if ([string]::IsNullOrWhiteSpace($scenarioPath)) {
|
||||
Fail "Campaign scenario $scenarioId has an empty path."
|
||||
}
|
||||
@@ -216,6 +236,7 @@ if (Has-Prop $campaign "chapters") {
|
||||
if ([string]::IsNullOrWhiteSpace($chapterTitle)) {
|
||||
Fail "Campaign chapter $chapterId has an empty title."
|
||||
}
|
||||
Check-Readable-Korean-Text $chapterTitle "Campaign chapter $chapterId title" -RequireHangul
|
||||
if (-not $campaignScenarioIdSet.Contains($startScenario)) {
|
||||
Fail "Campaign chapter $chapterId references unknown start_scenario: $startScenario"
|
||||
}
|
||||
@@ -1325,6 +1346,7 @@ function Check-Shop($Shop, [string]$ScenarioId) {
|
||||
if ([string]::IsNullOrWhiteSpace($merchantName)) {
|
||||
Fail "Scenario $ScenarioId shop merchant has an empty name."
|
||||
}
|
||||
Check-Readable-Korean-Text $merchantName "Scenario $ScenarioId shop merchant name"
|
||||
$merchantLines = Get-Prop $merchant "lines" $null
|
||||
if ($null -eq $merchantLines -or -not ($merchantLines -is [System.Array])) {
|
||||
Fail "Scenario $ScenarioId shop merchant must have line array."
|
||||
@@ -1333,6 +1355,7 @@ function Check-Shop($Shop, [string]$ScenarioId) {
|
||||
if ([string]::IsNullOrWhiteSpace([string]$merchantLine)) {
|
||||
Fail "Scenario $ScenarioId shop merchant has an empty line."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string]$merchantLine) "Scenario $ScenarioId shop merchant line"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1802,11 +1825,18 @@ function Check-Briefing($Briefing, [string]$ScenarioId) {
|
||||
if ($Briefing -is [string] -or $Briefing -is [System.Array]) {
|
||||
Fail "Scenario $ScenarioId briefing must be an object."
|
||||
}
|
||||
if (Has-Prop $Briefing "title") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $Briefing "title" "")) "Scenario $ScenarioId briefing title"
|
||||
}
|
||||
if (Has-Prop $Briefing "location") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $Briefing "location" "")) "Scenario $ScenarioId briefing location"
|
||||
}
|
||||
$lines = Get-Prop $Briefing "lines" @()
|
||||
foreach ($line in @($lines)) {
|
||||
if ([string]::IsNullOrWhiteSpace([string]$line)) {
|
||||
Fail "Scenario $ScenarioId briefing has an empty line."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string]$line) "Scenario $ScenarioId briefing line"
|
||||
}
|
||||
foreach ($line in @((Get-Prop $Briefing "camp_dialogue" @()))) {
|
||||
Check-Dialogue-Line $line "Scenario $ScenarioId briefing camp_dialogue"
|
||||
@@ -1831,6 +1861,7 @@ function Check-Briefing($Briefing, [string]$ScenarioId) {
|
||||
if ([string]::IsNullOrWhiteSpace([string]$line)) {
|
||||
Fail "Scenario $ScenarioId briefing conditional_lines has an empty line."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string]$line) "Scenario $ScenarioId briefing conditional line"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1861,6 +1892,10 @@ function Check-Camp-Conversations($Conversations, [string]$ScenarioId) {
|
||||
if ([string]::IsNullOrWhiteSpace($label)) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId has an empty label."
|
||||
}
|
||||
Check-Readable-Korean-Text $label "Scenario $ScenarioId briefing camp_conversations $conversationId label"
|
||||
if (Has-Prop $conversation "summary") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $conversation "summary" "")) "Scenario $ScenarioId briefing camp_conversations $conversationId summary"
|
||||
}
|
||||
$group = ([string](Get-Prop $conversation "group" "topic")).Trim().ToLowerInvariant()
|
||||
if (-not $validCampConversationGroups.Contains($group)) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId has unknown group: $group"
|
||||
@@ -1908,6 +1943,9 @@ function Check-Camp-Conversations($Conversations, [string]$ScenarioId) {
|
||||
if ((Has-Prop $effect "text") -and [string]::IsNullOrWhiteSpace([string](Get-Prop $effect "text" ""))) {
|
||||
Fail "Scenario $ScenarioId briefing camp_conversations $conversationId effect text must not be empty."
|
||||
}
|
||||
if (Has-Prop $effect "text") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $effect "text" "")) "Scenario $ScenarioId briefing camp_conversations $conversationId effect text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1918,6 +1956,7 @@ function Check-Dialogue-Line($Line, [string]$Context) {
|
||||
if ([string]::IsNullOrWhiteSpace([string]$Line)) {
|
||||
Fail "$Context has an empty dialogue line."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string]$Line) "$Context dialogue line"
|
||||
return
|
||||
}
|
||||
if ($Line -is [System.Array] -or -not (Has-Prop $Line "text")) {
|
||||
@@ -1926,6 +1965,10 @@ function Check-Dialogue-Line($Line, [string]$Context) {
|
||||
if ([string]::IsNullOrWhiteSpace([string](Get-Prop $Line "text" ""))) {
|
||||
Fail "$Context has an empty dialogue text."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $Line "text" "")) "$Context dialogue text"
|
||||
if (Has-Prop $Line "display_speaker") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $Line "display_speaker" "")) "$Context display speaker"
|
||||
}
|
||||
if (Has-Prop $Line "portrait") {
|
||||
Check-Portrait-Path (Get-Prop $Line "portrait" "") "$Context portrait"
|
||||
}
|
||||
@@ -2115,9 +2158,15 @@ foreach ($scenario in $campaign.scenarios) {
|
||||
$scenarioPath = ([string]$scenario.path).Replace("res://", "")
|
||||
$scenarioData = Read-Json $scenarioPath
|
||||
$scenarioId = [string]$scenarioData.id
|
||||
$script:CurrentScenarioRequiresHangul = $scenarioId -match '^00[1-9]_'
|
||||
if ($scenarioId -ne [string]$scenario.id) {
|
||||
Fail "Campaign id $($scenario.id) does not match scenario file id $scenarioId."
|
||||
}
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $scenarioData "name" "")) "Scenario $scenarioId name"
|
||||
if (Has-Prop $scenarioData "objectives") {
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $scenarioData.objectives "victory" "")) "Scenario $scenarioId victory objective"
|
||||
Check-Readable-Korean-Text ([string](Get-Prop $scenarioData.objectives "defeat" "")) "Scenario $scenarioId defeat objective"
|
||||
}
|
||||
|
||||
$map = $scenarioData.map
|
||||
if (Has-Prop $map "background") {
|
||||
|
||||
Reference in New Issue
Block a user