167 lines
7.9 KiB
PowerShell
167 lines
7.9 KiB
PowerShell
param()
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
$failures = @()
|
|
|
|
function Add-Failure {
|
|
param([string]$Message)
|
|
$script:failures += $Message
|
|
}
|
|
|
|
function Assert-True {
|
|
param(
|
|
[bool]$Condition,
|
|
[string]$Message
|
|
)
|
|
if (-not $Condition) {
|
|
Add-Failure $Message
|
|
}
|
|
}
|
|
|
|
function Read-RepoText {
|
|
param([string]$RelativePath)
|
|
$path = Join-Path $repoRoot $RelativePath
|
|
Assert-True (Test-Path -LiteralPath $path) "Missing file: $RelativePath"
|
|
if (Test-Path -LiteralPath $path) {
|
|
return Get-Content -LiteralPath $path -Raw
|
|
}
|
|
return ""
|
|
}
|
|
|
|
function Count-Matches {
|
|
param(
|
|
[string]$Text,
|
|
[string]$Pattern
|
|
)
|
|
return ([regex]::Matches($Text, $Pattern)).Count
|
|
}
|
|
|
|
$skillAsset = Read-RepoText "Unity/Assets/BundleResources/DataAssets/SkillDataAssets.asset"
|
|
$unitAsset = Read-RepoText "Unity/Assets/BundleResources/DataAssets/UnitTypeDataAssets.asset"
|
|
$actionAsset = Read-RepoText "Unity/Assets/BundleResources/DataAssets/ActionDataAssets.asset"
|
|
$gridAsset = Read-RepoText "Unity/Assets/BundleResources/DataAssets/GridAndResourceDataAssets.asset"
|
|
$skillEnum = Read-RepoText "Unity/Assets/Scripts/TH1_Logic/Skill/SkillBase.cs"
|
|
$unionFile = Read-RepoText "Unity/Assets/Scripts/TH1_Logic/Skill/Generate/SkillBase.MemoryPackUnion.g.cs"
|
|
|
|
$expectedKasenSkillHex = @{
|
|
1 = "02000000030000004d010000"
|
|
2 = "02000000030000004d0100005201000059010000"
|
|
3 = "02000000030000004d010000520100005901000053010000"
|
|
4 = "02000000030000004d0100005201000059010000530100002701000055010000"
|
|
}
|
|
|
|
foreach ($level in 1..4) {
|
|
$rowPattern = "(?s)- UnitType: 14\s+GiantType: 23\s+UnitLevel: $level\b.*?(?=\r?\n - UnitType:|\z)"
|
|
$row = [regex]::Match($unitAsset, $rowPattern)
|
|
Assert-True $row.Success "Missing Kasen UnitType row for level $level."
|
|
if ($row.Success) {
|
|
$expected = $expectedKasenSkillHex[$level]
|
|
Assert-True ($row.Value -match [regex]::Escape("Skills: $expected")) "Kasen level $level has unexpected skill hex."
|
|
$forbiddenSkillHex = if ($level -eq 4) { "25010000" } else { "25010000|27010000" }
|
|
Assert-True ($row.Value -notmatch $forbiddenSkillHex) "Kasen level $level still references forbidden old skill hex."
|
|
if ($level -lt 4) {
|
|
Assert-True ($row.Value -notmatch "55010000") "KasenPermanentBerserk must only be on Kasen level 4."
|
|
}
|
|
if ($level -eq 4) {
|
|
Assert-True ($row.Value -notmatch "3c010000") "Kasen level 4 must use KasenPermanentBerserk, not temporary Berserk."
|
|
}
|
|
}
|
|
}
|
|
|
|
$expectedSkillTypes = @{
|
|
333 = "KasenBeastGuideReserve"
|
|
334 = "KasenBeastGuideReady"
|
|
335 = "KasenBeastGuideGrid"
|
|
336 = "KasenBeastGuideDefenseBuff"
|
|
337 = "KasenBeastGuideAttackBuff"
|
|
338 = "KasenBeastGuideLv2Display"
|
|
339 = "KasenBeastGuideLv3Display"
|
|
340 = "KasenBeastGuideBerserkBuff"
|
|
341 = "KasenPermanentBerserk"
|
|
345 = "KasenBeastGuideTeleportDisplay"
|
|
}
|
|
|
|
foreach ($entry in $expectedSkillTypes.GetEnumerator()) {
|
|
Assert-True ($skillEnum -match "$($entry.Value)\s*=\s*$($entry.Key)\b") "Missing SkillType enum $($entry.Value) = $($entry.Key)."
|
|
$row = [regex]::Match($skillAsset, "(?s)- SkillType: $($entry.Key)\b.*?(?=\r?\n - SkillType:|\r?\n SkillViewTypeColorList:)")
|
|
Assert-True $row.Success "Missing SkillDataAssets row for SkillType $($entry.Key)."
|
|
if ($row.Success) {
|
|
if ($entry.Key -eq 341) {
|
|
Assert-True ($row.Value -match "NotShow:\s+0") "KasenPermanentBerserk must show in the unit skill list."
|
|
Assert-True ($row.Value -match "ShowOnUnitMono:\s+1") "KasenPermanentBerserk must show on UnitMono."
|
|
}
|
|
else {
|
|
Assert-True ($row.Value -match "ShowOnUnitMono:\s+0") "SkillType $($entry.Key) must not show on UnitMono."
|
|
}
|
|
}
|
|
}
|
|
|
|
$expectedUnions = @{
|
|
323 = "KasenBeastGuideReserveSkill"
|
|
324 = "KasenBeastGuideReadySkill"
|
|
325 = "KasenBeastGuideGridSkill"
|
|
326 = "KasenBeastGuideDefenseBuffSkill"
|
|
327 = "KasenBeastGuideAttackBuffSkill"
|
|
328 = "KasenBeastGuideLv2DisplaySkill"
|
|
329 = "KasenBeastGuideLv3DisplaySkill"
|
|
330 = "KasenBeastGuideBerserkBuffSkill"
|
|
331 = "KasenPermanentBerserkSkill"
|
|
333 = "KasenBeastGuideTeleportDisplaySkill"
|
|
}
|
|
|
|
foreach ($entry in $expectedUnions.GetEnumerator()) {
|
|
$className = $entry.Value
|
|
Assert-True ($unionFile -match "\[MemoryPackUnion\($($entry.Key), typeof\($className\)\)\]") "Missing MemoryPack union $($entry.Key) for $className."
|
|
$generatedPath = Join-Path $repoRoot "Unity/Assets/Scripts/TH1_Logic/Skill/Generate/$className.MemoryPackable.g.cs"
|
|
Assert-True (Test-Path -LiteralPath $generatedPath) "Missing MemoryPackable file for $className."
|
|
}
|
|
|
|
Assert-True ((Count-Matches $actionAsset "UnitActionType:\s+45") -eq 1) "UnitActionType 45 must appear exactly once."
|
|
Assert-True ((Count-Matches $actionAsset "UnitActionType:\s+46") -eq 1) "UnitActionType 46 must appear exactly once."
|
|
Assert-True ($actionAsset -match "(?s)UnitActionType:\s+45.*?ActionName: ""\\u56DE\\u6536\\u517D\\u5F15""") "UnitActionType 45 must be Recall Beast Guide."
|
|
Assert-True ($actionAsset -match "(?s)UnitActionType:\s+46.*?ActionName: ""\\u6E05\\u9664\\u517D\\u5F15""") "UnitActionType 46 must be Clear Beast Guide."
|
|
|
|
Assert-True ($gridAsset -match "GridSpType:\s+6") "GridAndResourceDataAssets must define GridSpType 6 sprite data."
|
|
|
|
$gridData = Read-RepoText "Unity/Assets/Scripts/TH1_Data/GridData.cs"
|
|
$mapData = Read-RepoText "Unity/Assets/Scripts/TH1_Data/MapData.cs"
|
|
$unitLogic = Read-RepoText "Unity/Assets/Scripts/TH1_Logic/Unit/UnitLogic.cs"
|
|
$hakureiNorwayHeroSkill = Read-RepoText "Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/HakureiNorwayHeroSkill.cs"
|
|
$gridObjectDataAssets = Read-RepoText "Unity/Assets/Scripts/TH1_DataAssetsScript/GridObjectDataAssets.cs"
|
|
$gridRenderer = Read-RepoText "Unity/Assets/Scripts/TH1_Renderer/GridRenderer.cs"
|
|
Assert-True ($gridData -match "KasenBeastGuide") "GridData must define KasenBeastGuide GridSpType."
|
|
Assert-True ($mapData -match "NormalizeKasenPermanentBerserkSkill") "MapData must normalize Kasen Lv4 permanent berserk."
|
|
Assert-True ($unitLogic -match "SkillType\.KasenPermanentBerserk") "UnitLogic must include KasenPermanentBerserk in berserk damage calculation."
|
|
Assert-True ($hakureiNorwayHeroSkill -match "(?s)public override void OnMove\(UnitData self, GridData grid, MapData mapData, MoveType moveType,.*?self\.AddOrOverrideSkill\(SkillType\.KasenBeastGuideReady, mapData, self\.Id\).*?self\.AddActionPoint\(ActionPointType\.Attack\).*?\}") "Kasen active move must grant ready and attack action point."
|
|
Assert-True ($hakureiNorwayHeroSkill -notmatch "(?s)public override void OnMove\(UnitData self, GridData grid, MapData mapData, MoveType moveType,.*?FindKasenBeastGuideGrid\(mapData, self\).*?return;.*?\}") "Kasen active move must not skip ready when an old beast guide is still on the map."
|
|
Assert-True ($gridObjectDataAssets -match "GridSpType\.KasenBeastGuide") "GridObjectDataAssets must resolve the Kasen beast-guide sprite."
|
|
Assert-True ($gridRenderer -match "GridSpType\.KasenBeastGuide") "GridRenderer must keep the special tile layer visible for Kasen beast guide."
|
|
|
|
$scriptRoot = Join-Path $repoRoot "Unity/Assets/Scripts"
|
|
$badPatterns = @(
|
|
"UnitType\.KasenBeastGuideMarker",
|
|
"FindKasenGuide",
|
|
"TrySpawnKasenGuide",
|
|
"RecallKasenGuide",
|
|
"IsKasenGuideFor",
|
|
"CanSetBeastGuide"
|
|
)
|
|
|
|
foreach ($pattern in $badPatterns) {
|
|
$matches = Get-ChildItem -LiteralPath $scriptRoot -Recurse -Filter "*.cs" |
|
|
Select-String -Pattern $pattern
|
|
Assert-True (($matches | Measure-Object).Count -eq 0) "Forbidden old Kasen beast-guide pattern remains: $pattern"
|
|
}
|
|
|
|
if ($failures.Count -gt 0) {
|
|
Write-Host "Kasen beast guide implementation check failed:" -ForegroundColor Red
|
|
foreach ($failure in $failures) {
|
|
Write-Host " - $failure" -ForegroundColor Red
|
|
}
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Kasen beast guide implementation checks passed."
|