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/exalted-equipment-game-test/session.json'),
    [string]$ReportDirectory = (Join-Path $PSScriptRoot '../artifacts/exalted-equipment-game-test/exalted-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 $status.version -ne '1.4.3') { throw 'Expected the isolated server and exalted-equipment bridge.' }
    $taskEvidence.build = $status.gameVersion; $taskEvidence.bridgeVersion = $status.version
    $config = Get-Content -LiteralPath (Join-Path $taskTest.runtime 'server.json') -Raw | ConvertFrom-Json
    $headers = @{Authorization='Bearer ' + $config.AdminToken}
    $accountUrl = $taskTest.origin + '/control/v1/accounts/' + $taskTest.accountId
    $inventory = Invoke-RestMethod ($accountUrl + '/export') -Headers $headers
    if (($inventory.Suits | Where-Object ItemType -EQ '/Lotus/Powersuits/Choir/Choir')) { throw 'This fixture must not own Jade.' }
    $glory = @($inventory.SpecialItems | Where-Object ItemType -EQ '/Lotus/Powersuits/Choir/ChoirEruptWeapon')[0]
    if (-not $glory -or $glory.Configs.Count -ne 6) { throw 'Prepare the owned Glory A-F fixture before launching the game.' }
    $gunslinger = @($inventory.Upgrades | Where-Object { $_.ItemType -eq '/Lotus/Upgrades/Mods/Pistol/WeaponFireRateMod' -and ($_.UpgradeFingerprint | ConvertFrom-Json).lvl -eq 5 })[0]
    if (-not $gunslinger -or $glory.Configs[2].Upgrades -notcontains $gunslinger.ItemId.'$oid') { throw 'Configuration C must install the owned rank-5 Gunslinger.' }
    function Check([string]$Kind, [bool]$Passed, $Details) {
        $taskEvidence.checks.Add(@{kind=$Kind;passed=$Passed;details=$Details})
        if (-not $Passed) { throw "Exalted game validation failed: $Kind" }
        Write-Host "Passed: $Kind"
    }
    $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
    }
    function SkillInput([int]$Milliseconds) {
        $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$true;exclusive=$true}
        Start-Sleep -Milliseconds $Milliseconds
        $null = Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$true}
        Start-Sleep -Milliseconds 250
    }
    function FillEnergy {
        $null=Invoke-Engine ($taskSuitSteps+@(@{from=6;field='GetMaxEnergy'},@{call=7;args=@(@{ref=6})},@{from=6;field='SetEnergy'},@{call=9;args=@(@{ref=6},@{ref=8})}))
    }
    function FireRate {
        $r=Invoke-Engine ($taskSuitSteps[0..4]+@(@{from=4;field='GetWeaponInSlot'},@{call=5;args=@(@{ref=4},0)},@{from=6;field='GetType'},@{call=7;args=@(@{ref=6})},@{from=8;field='GetFullName'},@{call=9;args=@(@{ref=8})},@{from=6;field='GetFireRate'},@{call=11;args=@(@{ref=6})}))
        if ($r[10].text -ne '/Lotus/Powersuits/Choir/ChoirEruptWeapon') { throw 'Glory is not the actual equipped weapon.' }
        return [double]$r[12].number
    }
    $jade = @('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','ChoirEruptAbility')
    Select-Config 1 @('InfestRuptureAbility','InfestTendrilsAbility','InfestLinkAbility','InfestPodsAbility')
    Select-Config 3 $jade; FillEnergy; SkillInput 480; Start-Sleep -Seconds 3
    $baseline = FireRate
    Check 'D-native-default-fire-rate' ([Math]::Abs($baseline - 1.6666667) -lt 0.0001) @{fireRate=$baseline}
    Select-Config 2 $jade; FillEnergy; SkillInput 480; Start-Sleep -Seconds 3
    $modified = FireRate; $snapshot = Invoke-Runtime '/runtime/v1/game/ability-state'
    Check 'C-owned-mods-on-transplanted-glory' ([Math]::Abs($modified - $baseline * 1.72) -lt 0.0001 -and $snapshot.exaltedEquipment.weapons[0].mods -eq 2 -and $snapshot.exaltedEquipment.weapons[0].config -eq 2) @{fireRate=$modified;baseline=$baseline;mods=2;animation=$snapshot.animationController}
    foreach ($choice in 1,2,0) {
        SkillInput 70
        $snapshot = Invoke-Runtime '/runtime/v1/game/ability-state'
        Check "wheel-retains-glory-and-mods-$choice" ($snapshot.slots[3].selected -eq $choice -and [Math]::Abs((FireRate) - $modified) -lt 0.0001 -and $snapshot.exaltedEquipment.weapons[0].mods -eq 2) @{choice=$choice;weapons=$snapshot.exaltedEquipment.weapons}
    }
    SkillInput 480
    Wait-Engine { (Invoke-Runtime '/runtime/v1/game/ability-state').exaltedEquipment.pending -eq 0 } 'channel cleanup'
    Start-Sleep -Seconds 4 # Choir's end animation must finish before the next native cast.
    FillEnergy; SkillInput 480; Start-Sleep -Seconds 3
    $snapshot = Invoke-Runtime '/runtime/v1/game/ability-state'
    Check 'repeated-summon-no-stacked-mods' ($snapshot.slots[3].active -and $snapshot.exaltedEquipment.weapons[0].mods -eq 2 -and [Math]::Abs((FireRate) - $modified) -lt 0.0001) @{fireRate=(FireRate);active=$snapshot.slots[3].active}
    Select-Config 3 $jade; FillEnergy; SkillInput 480; Start-Sleep -Seconds 3
    Check 'configuration-switch-restores-baseline' ([Math]::Abs((FireRate) - $baseline) -lt 0.0001) @{fireRate=(FireRate)}
    # Save after the live checks. Editing a running game's inventory deliberately
    # invalidates its cache; the supported application boundary is a fresh login.
    $view = Invoke-RestMethod ($accountUrl + '/editor?category=SpecialItems&item=' + $glory.ItemId.'$oid') -Headers $headers
    $action = @($view.actions | Where-Object key -EQ 'exalted.mods.2')[0]
    $values = @{}; foreach ($field in $action.fields) { $values[$field.key] = $field.value }
    $body = @{version=$view.version;category='SpecialItems';item=$glory.ItemId.'$oid';action=$action.key;values=$values}
    $null = Invoke-RestMethod ($accountUrl + '/editor') -Headers $headers -Method Post -ContentType 'application/json' -Body ([Text.Encoding]::UTF8.GetBytes(($body | ConvertTo-Json -Depth 12 -Compress)))
    $saved = Invoke-RestMethod ($accountUrl + '/export') -Headers $headers
    $savedGlory = @($saved.SpecialItems | Where-Object ItemType -EQ $glory.ItemType)[0]
    Check 'versioned-mod-editor-api' (($glory.Configs | ConvertTo-Json -Depth 12 -Compress) -eq ($savedGlory.Configs | ConvertTo-Json -Depth 12 -Compress)) @{configs=$savedGlory.Configs.Count;ownedJade=0;ownedGlory=1}
    $taskEvidence.passed = $true
} catch { $taskEvidence.error=$_.Exception.Message; throw }
finally {
    try { $null=Invoke-Runtime '/runtime/v1/game/ability-input' @{slot=3;pressed=$false;exclusive=$false} } catch { }
    $taskEvidence.finished=[DateTimeOffset]::UtcNow.ToString('o')
    $taskEvidence | ConvertTo-Json -Depth 16 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'result.json') -Encoding utf8
    $taskHttp.Dispose()
}