XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
#requires -Version 7.0
param(
    [string]$SessionFile = (Join-Path $PSScriptRoot '../artifacts/ability-bank-game-test/session.json'),
    [string]$ReportDirectory = (Join-Path $PSScriptRoot '../artifacts/ability-wheels-game-test/wheel-validation')
)
. (Join-Path $PSScriptRoot 'Game-TestHelpers.ps1') -SessionFile $SessionFile -ReportDirectory $ReportDirectory
try {
    $status = Invoke-Runtime '/runtime/v1/status'
    if ($status.serverUrl -ne $taskTest.origin -or [version]$status.version -lt [version]'1.4.2' -or
        -not ($status.capabilities | Where-Object { $_.key -eq 'game_test_control' -and $_.available })) {
        throw 'Use the isolated game session with the wheel component and --game-test-control.'
    }
    $taskEvidence.bridgeVersion = $status.version; $taskEvidence.build = $status.gameVersion
    function Check($Kind, [bool]$Passed, $Details) {
        $taskEvidence.checks.Add(@{kind=$Kind;passed=$Passed;details=$Details})
        if (-not $Passed) { throw "Wheel validation failed: $Kind" }
        Write-Host "Passed: $Kind"
    }
    function Energy {
        $r = Invoke-Engine ($taskSuitSteps + @(@{from=6;field='0xEF680AA6'},@{call=7;args=@(@{ref=6})})); $r[8].number
    }
    function Input([int]$Slot, [int]$Milliseconds=70) {
        $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=$Slot;pressed=$true;exclusive=$true}
        Start-Sleep -Milliseconds $Milliseconds
        $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=$Slot;pressed=$false;exclusive=$true}
        Start-Sleep -Milliseconds 300 # Original selector tween duration is 200 ms.
    }
    function Wheel([int]$Slot) { (Invoke-Runtime '/runtime/v1/game/ability-state').hud.slots | Where-Object slot -EQ $Slot }
    $scene = Invoke-Engine @(@{global='gGameRules'},@{from=0;field='GetType'},@{call=1;args=@(@{ref=0})},@{from=2;field='GetFullName'},@{call=3;args=@(@{ref=2})})
    if ($scene[4].text -notlike '*LotusDangerRoomGameRules') {
        $null = Invoke-Engine @(@{global='require'},@{call=0;args=@('Lotus.Scripts.SimulacrumUtilities')},@{from=1;field='LaunchDangerRoom'},@{call=2;args=@()})
        Wait-Engine { $r=Invoke-Engine @(@{global='gGameRules'},@{from=0;field='GetType'},@{call=1;args=@(@{ref=0})},@{from=2;field='GetFullName'},@{call=3;args=@(@{ref=2})});$r[4].text -like '*LotusDangerRoomGameRules' } 'Simulacrum'
        Start-Sleep -Seconds 3
    }
    $a = @('ShockAbility','PullAbility','IronSkinAbility','IronSkinAbility')
    $native = @('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
    $c = @('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','ChoirEruptAbility')
    Select-Config 0 $a
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 4 -and @($hud.slots | Where-Object selected -NE 0).Count -eq 0 } 'four native wheels'
    Start-Sleep -Milliseconds 300
    $initial = Invoke-Runtime '/runtime/v1/game/ability-state'
    $banks = @(@('ShockAbility','RhinoRoarAbility','PullAbility'),@('PullAbility','ShockAbility','RhinoRoarAbility'),
        @('IronSkinAbility','ShockAbility','RhinoRoarAbility'),@('IronSkinAbility','ShockAbility','RhinoRoarAbility'))
    $iconNames = @(@('VoltChainLightning.png','RhinoRadialBlast.png','MagPull.png'),@('MagPull.png','VoltChainLightning.png','RhinoRadialBlast.png'),
        @('RhinoIronSkin.png','VoltChainLightning.png','RhinoRadialBlast.png'),@('RhinoIronSkin.png','VoltChainLightning.png','RhinoRadialBlast.png'))
    foreach ($slot in 0..3) {
        $wheel = @($initial.hud.slots | Where-Object slot -EQ $slot)[0]
        $icons = @($wheel.candidates | ForEach-Object { Split-Path $_.icon -Leaf })
        Check "original-icons-slot-$slot" ($wheel.visible -and $wheel.candidates.Count -eq 3 -and
            @($wheel.candidates | Where-Object { -not $_.exists }).Count -eq 0 -and ($icons -join ',') -eq ($iconNames[$slot] -join ',')) $wheel
    }
    $xPositions = @($initial.hud.slots.x | Sort-Object -Unique)
    Check 'four-independent-wheel-positions' ($xPositions.Count -eq 4 -and ($xPositions[-1]-$xPositions[0]) -gt 300) $initial.hud
    foreach ($slot in 0..3) {
        foreach ($choice in 1,2,0) {
            $before = Invoke-Runtime '/runtime/v1/game/ability-state'; $beforeEnergy = Energy
            Input $slot
            $after = Invoke-Runtime '/runtime/v1/game/ability-state'; $wheel = @($after.hud.slots | Where-Object slot -EQ $slot)[0]
            $names = @(Get-Abilities)
            $otherChanged = @(0..3 | Where-Object { $_ -ne $slot -and $after.slots[$_].selected -ne $before.slots[$_].selected }).Count
            Check "wheel-cycle-slot-$slot-choice-$choice" ($wheel.selected -eq $choice -and $after.slots[$slot].selected -eq $choice -and
                $names[$slot] -eq $banks[$slot][$choice] -and $otherChanged -eq 0 -and (Energy) -eq $beforeEnergy -and
                $wheel.candidates[$choice].scale -ge 95 -and @($wheel.candidates | Where-Object scale -GT 80).Count -eq 1) @{hud=$wheel;ability=$names[$slot];otherSlotsChanged=$otherChanged}
        }
    }
    Input 0 # Roar, for an easily measured sustained cast.
    $null=Invoke-Engine ($taskSuitSteps+@(@{from=6;field='GetMaxEnergy'},@{call=7;args=@(@{ref=6})},@{from=6;field='SetEnergy'},@{call=9;args=@(@{ref=6},@{ref=8})}))
    $beforeEnergy = Energy
    $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=0;pressed=$true;exclusive=$true}
    Start-Sleep -Milliseconds 110
    $holding = Wheel 0
    Check 'native-hold-progress-before-cast' ($holding.progress -gt 0 -and $holding.progress -lt 1 -and (Energy) -eq $beforeEnergy) $holding
    Start-Sleep -Milliseconds 550
    $held = Wheel 0
    Check 'hold-progress-completes-and-casts-once' ($held.selected -eq 1 -and $held.progress -eq 1 -and ($beforeEnergy-(Energy)) -eq 75) $held
    $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=0;pressed=$false;exclusive=$true}
    Start-Sleep -Milliseconds 150
    $released = Wheel 0
    Check 'release-clears-progress-without-cycling' ($released.progress -eq 0 -and $released.selected -eq 1) $released
    Select-Config 1 $native
    Wait-Engine { -not (Invoke-Runtime '/runtime/v1/game/ability-state').hud.ready } 'original configuration without custom wheels'
    Check 'original-config-closes-wheels' (-not (Invoke-Runtime '/runtime/v1/game/ability-state').hud.ready) @(Get-Abilities)
    Select-Config 2 $c
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 1 } 'one bank in config C'
    $wheel = Wheel 3
    Check 'single-bank-config-C-only-slot-four' ($wheel.slot -eq 3 -and $wheel.selected -eq 0 -and $wheel.candidates[0].icon -like '*/ChoirEruption.png') $wheel
    Input 3
    $wheel = Wheel 3
    Check 'config-C-wheel-selects-roar' ($wheel.selected -eq 1 -and @(Get-Abilities)[3] -eq 'RhinoRoarAbility') $wheel
    Select-Config 3 @('ShockAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 1 -and $hud.slots[0].candidates.Count -eq 2 } 'two-choice bank with Helminth'
    $wheel = Wheel 0
    Check 'two-choice-wheel-includes-Helminth-icon' ($wheel.candidates[1].icon -like '*/HelminthHackAbility.png' -and $wheel.candidates[1].exists) $wheel
    Input 0
    $wheel = Wheel 0
    Check 'two-choice-wheel-selects-Helminth' ($wheel.selected -eq 1 -and @(Get-Abilities)[0] -eq 'HelminthHackAbility' -and $wheel.candidates[1].scale -ge 95) $wheel
    Input 0
    $wheel = Wheel 0
    Check 'two-choice-wheel-wraps-to-first' ($wheel.selected -eq 0 -and @(Get-Abilities)[0] -eq 'ShockAbility') $wheel
    Select-Config 4 @('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','StalkerAbsorbAbility')
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 1 } 'single Stalker two-choice bank'
    $wheel = Wheel 3
    Check 'single-Stalker-two-choice-wheel' ($wheel.slot -eq 3 -and $wheel.visible -and $wheel.candidates.Count -eq 2 -and $wheel.candidates[0].exists -and $wheel.candidates[1].exists) $wheel
    Input 3
    Check 'single-Stalker-two-choice-cycle' ((Wheel 3).selected -eq 1 -and @(Get-Abilities)[3] -eq 'StalkerSmokeScreenAbility') (Wheel 3)
    Select-Config 5 @('StalkerAbsorbAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 1 } 'single Stalker three-choice bank'
    $wheel = Wheel 0
    Check 'single-Stalker-three-choice-wheel' ($wheel.slot -eq 0 -and $wheel.visible -and $wheel.candidates.Count -eq 3 -and @($wheel.candidates | Where-Object exists -NE $true).Count -eq 0) $wheel
    foreach ($choice in 1,2,0) {
        Input 0
        Check "single-Stalker-three-choice-cycle-$choice" ((Wheel 0).selected -eq $choice) (Wheel 0)
    }
    Select-Config 0 $a
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 4 -and @($hud.slots | Where-Object selected -NE 0).Count -eq 0 } 'rebuilt config A'
    $final = Invoke-Runtime '/runtime/v1/game/ability-state'
    # The allocator can reuse a closed movie's address. Validate the rebuilt
    # controls and selection instead of treating pointer inequality as identity.
    $rebuilt = $final.hud.ready -and @($final.hud.slots).Count -eq 4 -and @($final.hud.slots.x | Sort-Object -Unique).Count -eq 4
    foreach ($slot in 0..3) {
        $wheel = @($final.hud.slots | Where-Object slot -EQ $slot)[0]
        $icons = @($wheel.candidates | ForEach-Object { Split-Path $_.icon -Leaf })
        $rebuilt = $rebuilt -and $wheel.visible -and $wheel.selected -eq 0 -and $wheel.progress -eq 0 -and
            $wheel.candidates.Count -eq 3 -and @($wheel.candidates | Where-Object exists -NE $true).Count -eq 0 -and
            ($icons -join ',') -eq ($iconNames[$slot] -join ',') -and $wheel.candidates[0].scale -ge 95 -and
            @($wheel.candidates | Where-Object scale -GT 80).Count -eq 1
    }
    Check 'rebuild-restores-four-wheels-and-first-choices' $rebuilt $final.hud
    # Create a second instance of the original Xaku HUD. Its six native callbacks
    # must survive our movie shutdown and the next custom-wheel initialization.
    $null = Invoke-Engine @(@{global='_T'},@{global='Type'},@{call=1;args=@('/Lotus/Interface/PowerSuitCustomHuds/BrokenFrameCustomHud.swf')},
        @{global='gFlashMgr'},@{from=3;field='0x297A9947'},@{call=4;args=@(@{ref=3},@{ref=2})},
        @{global='rawset'},@{call=6;args=@(@{ref=0},'XFEOriginalWheelCheck',@{ref=5})})
    $taskExtraWheelOpened = $true
    $callbackNames = @('BROKEN_SetHudSwitchProp','BROKEN_SetActiveHudIcon','BROKEN_SetHudTimer','BROKEN_PauseTimer','BROKEN_UpdateHudTimers','BROKEN_GetHudLocTag')
    function Callbacks {
        $steps = @(@{global='_T'})
        foreach ($name in $callbackNames) { $steps += @{from=0;field=$name;literal=$true} }
        @(Invoke-Engine $steps)[1..6]
    }
    Wait-Engine { @((Callbacks) | Where-Object type -NE 8).Count -eq 0 } 'original Xaku HUD callbacks'
    $originalCallbacks = @(Callbacks)
    Select-Config 1 $native
    Start-Sleep -Milliseconds 300
    $afterClose = @(Callbacks)
    Check 'original-Xaku-callbacks-survive-wheel-close' (($originalCallbacks.object -join ',') -eq ($afterClose.object -join ',')) $afterClose
    Select-Config 0 $a
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 4 } 'custom wheels beside original Xaku HUD'
    Start-Sleep -Milliseconds 300
    $afterOpen = @(Callbacks)
    Check 'original-Xaku-callbacks-survive-wheel-reopen' (($originalCallbacks.object -join ',') -eq ($afterOpen.object -join ',')) $afterOpen
    Select-Config 1 $native # Close our movie before closing the additional test movie.
    $null = Invoke-Engine @(@{global='_T'},@{from=0;field='XFEOriginalWheelCheck';literal=$true},@{from=1;field='Close'},@{call=2;args=@(@{ref=1})},
        @{global='rawset'},@{call=4;args=@(@{ref=0},'XFEOriginalWheelCheck',$null)})
    $taskExtraWheelOpened = $false
    Select-Config 0 $a
    Wait-Engine { $hud=(Invoke-Runtime '/runtime/v1/game/ability-state').hud; $hud.ready -and @($hud.slots).Count -eq 4 } 'restored four-wheel HUD'
    $bridgeLog = @(Get-ChildItem -LiteralPath (Join-Path $GameDirectory 'XFEWarframe/logs') -Filter "*-$($taskGame[0].Id).log")
    $errors = @(Select-String -LiteralPath $bridgeLog.FullName -Pattern 'Ability wheels:.*(error|unavailable|required|No wheel icon|changed)')
    Check 'no-wheel-engine-errors' ($errors.Count -eq 0) @{errors=$errors.Count}
    $taskEvidence.passed = $true
} catch { $taskEvidence.error=$_.Exception.Message; throw }
finally {
    if ($taskExtraWheelOpened) {
        try {
            Select-Config 1 $native
            $null = Invoke-Engine @(@{global='_T'},@{from=0;field='XFEOriginalWheelCheck';literal=$true},@{from=1;field='Close'},@{call=2;args=@(@{ref=1})},
                @{global='rawset'},@{call=4;args=@(@{ref=0},'XFEOriginalWheelCheck',$null)})
            Select-Config 0 $a
        } catch { }
    }
    foreach ($slot in 0..3) { try { $null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=$slot;pressed=$false;exclusive=$false} } catch { } }
    $taskEvidence.finished=[DateTimeOffset]::UtcNow.ToString('o')
    $taskEvidence | ConvertTo-Json -Depth 25 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'result.json') -Encoding utf8
    $taskHttp.Dispose()
}
Write-Host "Ability wheel game validation passed: $ReportDirectory/result.json"