#requires -Version 7.0
param(
[string]$SessionFile = (Join-Path $PSScriptRoot '../artifacts/ability-bank-game-test/session.json'),
[string]$ReportDirectory = (Join-Path $PSScriptRoot '../artifacts/infestation-king-validation')
)
. (Join-Path $PSScriptRoot 'Game-TestHelpers.ps1') -SessionFile $SessionFile -ReportDirectory $ReportDirectory
try {
function Check($Kind, [bool]$Passed, $Details) {
$taskEvidence.checks.Add(@{kind=$Kind;passed=$Passed;details=$Details})
if (-not $Passed) { throw "Game validation failed: $Kind" }
Write-Host "Passed: $Kind"
}
$status=Invoke-Runtime '/runtime/v1/status'
if ($status.serverUrl -ne $taskTest.origin -or -not ($status.capabilities | Where-Object { $_.key -eq 'game_test_control' -and $_.available })) {
throw 'Expected the isolated engine test session.'
}
$taskEvidence.build=$status.gameVersion; $taskEvidence.bridgeVersion=$status.version
$native=@('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
Select-Config 1 $native
Wait-Engine { $s=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing; $s.equipped -and $s.stacks -eq $s.maximum -and $s.maximum -gt 0 } 'installed King MOD at full mutation'
$before=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'owned-installed-card-fills-current-cap' ($before.equipped -and $before.stacks -eq $before.maximum) $before
$negative=Invoke-Engine ($taskSuitSteps+@(@{global='_T'},@{from=7;field='INFESTED_AddStacks';literal=$true},@{call=8;args=@(@{ref=6},-15)},
@{from=7;field='INFESTED_GetStacks';literal=$true},@{call=10;args=@(@{ref=6})}))
$after=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'negative-loss-blocked-within-same-Lua-call' ($negative[11].number -eq $before.maximum -and $after.preventedLosses -gt $before.preventedLosses) @{sameCallStacks=$negative[11].number;state=$after}
$null=Invoke-Engine ($taskSuitSteps+@(@{from=6;field='GetMaxEnergy'},@{call=7;args=@(@{ref=6})},@{from=6;field='SetEnergy'},@{call=9;args=@(@{ref=6},@{ref=8})}))
$before=$after
$null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$true;exclusive=$true}
Start-Sleep -Milliseconds 70
$null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$true}
Start-Sleep -Milliseconds 250
$state=Invoke-Runtime '/runtime/v1/game/ability-state'; $after=$state.infestationKing
Check 'Ravenous-active-without-consuming-mutation' ($state.slots[3].active -and $after.stacks -eq $after.maximum -and $after.preventedLosses -gt $before.preventedLosses) $state
Start-Sleep -Seconds 3 # Leave the native cast animation's invulnerability window.
$health=Invoke-Engine ($taskSuitSteps[0..2]+@(@{from=2;field='GetHealth'},@{call=3;args=@(@{ref=2})},
@{from=2;field='Damage'},@{call=5;args=@(@{ref=2},100000,0)}))
Start-Sleep -Milliseconds 150 # Damage is processed by the next game update.
$healthAfter=Invoke-Engine ($taskSuitSteps[0..2]+@(@{from=2;field='GetHealth'},@{call=3;args=@(@{ref=2})}))
$revived=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'lethal-hit-triggers-Undying-without-mutation-loss' ($health[4].number -gt 0 -and $healthAfter[4].number -gt 0 -and $healthAfter[4].number -lt $health[4].number -and $revived.stacks -eq $revived.maximum -and $revived.preventedLosses -gt $after.preventedLosses) @{healthBefore=$health[4].number;healthAfter=$healthAfter[4].number;state=$revived}
# Use the actual game MOD builder with the existing HUD movie environment.
# A caller environment with mMovie is required by the game's GetMovie helper.
$card=Invoke-Engine @(@{global='_T'},@{from=0;field='SetAbilityDotsDeltaY';literal=$true},@{global='getfenv'},@{call=2;args=@(@{ref=1})},
@{from=3;field='mMovie';literal=$true},@{global='require'},@{call=5;args=@('Lotus.Interface.CardUtilitiesRedux')},
@{from=6;field='CardFromArtifact';literal=$true},@{call=2;args=@(@{ref=7})},@{global='rawset'},@{call=9;args=@(@{ref=8},'mMovie',@{ref=4})},
@{global='gGameData'},@{from=11;field='GetInventory'},@{call=12;args=@(@{ref=11})},@{from=13;field='GetUpgrades'},@{call=14;args=@(@{ref=13})},
@{global='rawget'},@{call=16;args=@(@{ref=15},1)},@{call=7;args=@(@{ref=17});inspect=$true},@{call=9;args=@(@{ref=8},'mMovie',$null)})
$taskNativeCard=$card[18]
$taskName=@($taskNativeCard.fields | Where-Object { $_.key.text -eq 'mName' })[0].value.text
$taskDesc=@($taskNativeCard.fields | Where-Object { $_.key.text -eq 'mDesc' })[0].value.text
Check 'native-MOD-card-name-and-description' ($taskName -eq '感染之王' -and $taskDesc -like '*不消耗层数*') $taskNativeCard
Select-Config 3 @('ShockAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
Wait-Engine { -not (Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing.equipped } 'King MOD removed with config change'
$ordinary=Invoke-Engine ($taskSuitSteps+@(@{global='_T'},@{from=7;field='INFESTED_AddStacks';literal=$true},@{from=7;field='INFESTED_GetStacks';literal=$true},
@{call=8;args=@(@{ref=6},30)},@{call=9;args=@(@{ref=6})},@{call=8;args=@(@{ref=6},-15)},@{call=9;args=@(@{ref=6})}))
Check 'unequipped-Nidus-retains-normal-mutation-loss' ($ordinary[11].number -gt $ordinary[13].number -and $ordinary[13].number -eq [Math]::Max(0,$ordinary[11].number-15)) @{before=$ordinary[11].number;after=$ordinary[13].number}
Select-Config 1 $native
Wait-Engine { $s=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing; $s.equipped -and $s.stacks -eq $s.maximum } 'King restored after configuration switch'
Check 'reinstall-restores-full-cap' $true (Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
$taskEvidence.passed=$true
} finally {
try { $null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$false} } catch { }
# Restore the temporary card environment even if card construction threw.
try { $null=Invoke-Engine @(@{global='require'},@{call=0;args=@('Lotus.Interface.CardUtilitiesRedux')},@{from=1;field='CardFromArtifact';literal=$true},
@{global='getfenv'},@{call=3;args=@(@{ref=2})},@{global='rawset'},@{call=5;args=@(@{ref=4},'mMovie',$null)}) } catch { }
$taskEvidence.finished=[DateTimeOffset]::UtcNow.ToString('o')
$taskEvidence | ConvertTo-Json -Depth 40 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'result.json') -Encoding utf8
$taskHttp.Dispose()
}
#requires -Version 7.0
param(
[string]$SessionFile = (Join-Path $PSScriptRoot '../artifacts/ability-bank-game-test/session.json'),
[string]$ReportDirectory = (Join-Path $PSScriptRoot '../artifacts/infestation-king-validation')
)
. (Join-Path $PSScriptRoot 'Game-TestHelpers.ps1') -SessionFile $SessionFile -ReportDirectory $ReportDirectory
try {
function Check($Kind, [bool]$Passed, $Details) {
$taskEvidence.checks.Add(@{kind=$Kind;passed=$Passed;details=$Details})
if (-not $Passed) { throw "Game validation failed: $Kind" }
Write-Host "Passed: $Kind"
}
$status=Invoke-Runtime '/runtime/v1/status'
if ($status.serverUrl -ne $taskTest.origin -or -not ($status.capabilities | Where-Object { $_.key -eq 'game_test_control' -and $_.available })) {
throw 'Expected the isolated engine test session.'
}
$taskEvidence.build=$status.gameVersion; $taskEvidence.bridgeVersion=$status.version
$native=@('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
Select-Config 1 $native
Wait-Engine { $s=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing; $s.equipped -and $s.stacks -eq $s.maximum -and $s.maximum -gt 0 } 'installed King MOD at full mutation'
$before=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'owned-installed-card-fills-current-cap' ($before.equipped -and $before.stacks -eq $before.maximum) $before
$negative=Invoke-Engine ($taskSuitSteps+@(@{global='_T'},@{from=7;field='INFESTED_AddStacks';literal=$true},@{call=8;args=@(@{ref=6},-15)},
@{from=7;field='INFESTED_GetStacks';literal=$true},@{call=10;args=@(@{ref=6})}))
$after=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'negative-loss-blocked-within-same-Lua-call' ($negative[11].number -eq $before.maximum -and $after.preventedLosses -gt $before.preventedLosses) @{sameCallStacks=$negative[11].number;state=$after}
$null=Invoke-Engine ($taskSuitSteps+@(@{from=6;field='GetMaxEnergy'},@{call=7;args=@(@{ref=6})},@{from=6;field='SetEnergy'},@{call=9;args=@(@{ref=6},@{ref=8})}))
$before=$after
$null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$true;exclusive=$true}
Start-Sleep -Milliseconds 70
$null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$true}
Start-Sleep -Milliseconds 250
$state=Invoke-Runtime '/runtime/v1/game/ability-state'; $after=$state.infestationKing
Check 'Ravenous-active-without-consuming-mutation' ($state.slots[3].active -and $after.stacks -eq $after.maximum -and $after.preventedLosses -gt $before.preventedLosses) $state
Start-Sleep -Seconds 3 # Leave the native cast animation's invulnerability window.
$health=Invoke-Engine ($taskSuitSteps[0..2]+@(@{from=2;field='GetHealth'},@{call=3;args=@(@{ref=2})},
@{from=2;field='Damage'},@{call=5;args=@(@{ref=2},100000,0)}))
Start-Sleep -Milliseconds 150 # Damage is processed by the next game update.
$healthAfter=Invoke-Engine ($taskSuitSteps[0..2]+@(@{from=2;field='GetHealth'},@{call=3;args=@(@{ref=2})}))
$revived=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
Check 'lethal-hit-triggers-Undying-without-mutation-loss' ($health[4].number -gt 0 -and $healthAfter[4].number -gt 0 -and $healthAfter[4].number -lt $health[4].number -and $revived.stacks -eq $revived.maximum -and $revived.preventedLosses -gt $after.preventedLosses) @{healthBefore=$health[4].number;healthAfter=$healthAfter[4].number;state=$revived}
# Use the actual game MOD builder with the existing HUD movie environment.
# A caller environment with mMovie is required by the game's GetMovie helper.
$card=Invoke-Engine @(@{global='_T'},@{from=0;field='SetAbilityDotsDeltaY';literal=$true},@{global='getfenv'},@{call=2;args=@(@{ref=1})},
@{from=3;field='mMovie';literal=$true},@{global='require'},@{call=5;args=@('Lotus.Interface.CardUtilitiesRedux')},
@{from=6;field='CardFromArtifact';literal=$true},@{call=2;args=@(@{ref=7})},@{global='rawset'},@{call=9;args=@(@{ref=8},'mMovie',@{ref=4})},
@{global='gGameData'},@{from=11;field='GetInventory'},@{call=12;args=@(@{ref=11})},@{from=13;field='GetUpgrades'},@{call=14;args=@(@{ref=13})},
@{global='rawget'},@{call=16;args=@(@{ref=15},1)},@{call=7;args=@(@{ref=17});inspect=$true},@{call=9;args=@(@{ref=8},'mMovie',$null)})
$taskNativeCard=$card[18]
$taskName=@($taskNativeCard.fields | Where-Object { $_.key.text -eq 'mName' })[0].value.text
$taskDesc=@($taskNativeCard.fields | Where-Object { $_.key.text -eq 'mDesc' })[0].value.text
Check 'native-MOD-card-name-and-description' ($taskName -eq '感染之王' -and $taskDesc -like '*不消耗层数*') $taskNativeCard
Select-Config 3 @('ShockAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
Wait-Engine { -not (Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing.equipped } 'King MOD removed with config change'
$ordinary=Invoke-Engine ($taskSuitSteps+@(@{global='_T'},@{from=7;field='INFESTED_AddStacks';literal=$true},@{from=7;field='INFESTED_GetStacks';literal=$true},
@{call=8;args=@(@{ref=6},30)},@{call=9;args=@(@{ref=6})},@{call=8;args=@(@{ref=6},-15)},@{call=9;args=@(@{ref=6})}))
Check 'unequipped-Nidus-retains-normal-mutation-loss' ($ordinary[11].number -gt $ordinary[13].number -and $ordinary[13].number -eq [Math]::Max(0,$ordinary[11].number-15)) @{before=$ordinary[11].number;after=$ordinary[13].number}
Select-Config 1 $native
Wait-Engine { $s=(Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing; $s.equipped -and $s.stacks -eq $s.maximum } 'King restored after configuration switch'
Check 'reinstall-restores-full-cap' $true (Invoke-Runtime '/runtime/v1/game/ability-state').infestationKing
$taskEvidence.passed=$true
} finally {
try { $null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$false} } catch { }
# Restore the temporary card environment even if card construction threw.
try { $null=Invoke-Engine @(@{global='require'},@{call=0;args=@('Lotus.Interface.CardUtilitiesRedux')},@{from=1;field='CardFromArtifact';literal=$true},
@{global='getfenv'},@{call=3;args=@(@{ref=2})},@{global='rawset'},@{call=5;args=@(@{ref=4},'mMovie',$null)}) } catch { }
$taskEvidence.finished=[DateTimeOffset]::UtcNow.ToString('o')
$taskEvidence | ConvertTo-Json -Depth 40 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'result.json') -Encoding utf8
$taskHttp.Dispose()
}