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

XFEWarframe

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

公开
关注 0 Fork 0 Star 0
UTF-8
#requires -Version 7.0
param(
    [Parameter(Mandatory)][string]$Package,
    [string]$SessionFile = (Join-Path $PSScriptRoot '../artifacts/ability-bank-game-test/session.json'),
    [string]$ReportDirectory = (Join-Path $PSScriptRoot '../artifacts/ability-bank-game-test/exalted-validation')
)
$ErrorActionPreference = 'Stop'
$taskPackage = [IO.Path]::GetFullPath($Package)
$taskSession = Get-Content -LiteralPath $SessionFile -Raw | ConvertFrom-Json
if ($taskSession.origin -ne 'http://127.0.0.1:18444' -or $taskSession.accountId -notmatch '^[0-9a-f]{24}$' -or $taskSession.suitId -notmatch '^[0-9a-f]{24}$') { throw 'Expected the isolated ability-bank session.' }
$taskServer = Get-Process -Id $taskSession.serverPid
if ($taskServer.Path -ne (Join-Path $taskPackage 'Server/XFEWarframe.Server.exe')) { throw 'The test server must use this exact package.' }
$taskInstaller = Join-Path $taskPackage 'Client/Installer/XFEWarframe.Installer.exe'
$taskGame = @(Get-Process -Name Warframe.x64 -ErrorAction SilentlyContinue)
if ($taskGame.Count -gt 1 -or ($taskGame.Count -eq 1 -and $taskGame[0].Path -ne 'D:\Warframe\Warframe.x64.exe')) { throw 'Only the copied test game may be restarted.' }
$taskConfig = Get-Content -LiteralPath (Join-Path $taskSession.runtime 'server.json') -Raw | ConvertFrom-Json
$taskHeaders = @{Authorization='Bearer ' + $taskConfig.AdminToken}
$taskAccountUrl = $taskSession.origin + '/control/v1/accounts/' + $taskSession.accountId
$taskProfile = Invoke-RestMethod ($taskAccountUrl + '/profile') -Headers $taskHeaders
if ($taskProfile.email -ne 'multi-ability@example.invalid') { throw 'Only the dedicated multi-ability test account may be changed.' }
function Send-Fixture([string]$Operation, $Body) {
    Invoke-RestMethod ($taskAccountUrl + '/' + $Operation) -Headers $taskHeaders -Method Post -ContentType 'application/json' -Body ([Text.Encoding]::UTF8.GetBytes(($Body | ConvertTo-Json -Depth 30 -Compress)))
}
function Edit-Fixture([string]$Category, [string]$Item, [string]$ActionKey, $Overrides) {
    $view = Invoke-RestMethod ($taskAccountUrl + '/editor?category=' + $Category + '&item=' + $Item) -Headers $taskHeaders
    $action = @($view.actions | Where-Object key -EQ $ActionKey)[0]
    if (-not $action) { throw "Missing production editor action: $ActionKey" }
    $values = @{}; foreach ($field in $action.fields) { $values[$field.key] = $field.value }
    foreach ($fieldKey in $Overrides.Keys) { $values[$fieldKey] = $Overrides[$fieldKey] }
    try { $null = Send-Fixture 'editor' @{version=$view.version;category=$Category;item=$Item;action=$ActionKey;values=$values} }
    catch { throw "Fixture action $Category / $ActionKey failed: $($_.Exception.Message)" }
}
New-Item -ItemType Directory -Path $ReportDirectory -Force | Out-Null
$taskBefore = Invoke-RestMethod ($taskAccountUrl + '/export') -Headers $taskHeaders
if ($taskBefore.Suits | Where-Object ItemType -EQ '/Lotus/Powersuits/Choir/Choir') { throw 'The transplanted fixture must not own Jade.' }
$taskHost = @($taskBefore.Suits | Where-Object { $_.ItemId.'$oid' -eq $taskSession.suitId })[0]
if ($taskHost.ItemType -ne '/Lotus/Powersuits/Infestation/Infestation' -or $taskHost.ModSlotPurchases -ne 3) { throw 'Use the six-configuration Nidus ability-bank fixture.' }
if ($taskGame.Count -eq 1) { Stop-Process -Id $taskGame[0].Id; $taskGame[0].WaitForExit(10000) | Out-Null }
$taskBefore | ConvertTo-Json -Depth 90 | Set-Content -LiteralPath (Join-Path $ReportDirectory 'inventory-before.json') -Encoding utf8
$taskGloryType = '/Lotus/Powersuits/Choir/ChoirEruptWeapon'
$taskFlight = '/Lotus/Powersuits/Choir/Abilities/ChoirEruptAbility'
# Build all equipment through the same bounded, versioned actions used by both desktops.
foreach ($index in 2,3) {
    $view = Invoke-RestMethod ($taskAccountUrl + '/editor?category=Suits&item=' + $taskSession.suitId) -Headers $taskHeaders
    $values = @{}; foreach ($field in @($view.actions | Where-Object key -EQ "ability.multiple.$index")[0].fields) { $values[$field.key] = '' }
    $values.ability4 = $taskFlight
    if ($index -eq 2) { $values.ability4_2='/Lotus/Powersuits/Rhino/Abilities/RhinoRoarAbility'; $values.ability4_3='/Lotus/Powersuits/Rhino/Abilities/IronSkinAbility' }
    Edit-Fixture 'Suits' $taskSession.suitId "ability.multiple.$index" $values
}
Edit-Fixture 'Suits' $taskSession.suitId 'exalted.prepare' @{type=$taskGloryType}
$taskInventory = Invoke-RestMethod ($taskAccountUrl + '/export') -Headers $taskHeaders
$taskGlory = @($taskInventory.SpecialItems | Where-Object ItemType -EQ $taskGloryType)[0]
$taskCards = @('/Lotus/Upgrades/Mods/Pistol/WeaponDamageAmountMod','/Lotus/Upgrades/Mods/Pistol/WeaponFireRateMod')
$taskSelections = @()
foreach ($type in $taskCards) {
    $owned = @($taskInventory.Upgrades | Where-Object ItemType -EQ $type)[0]
    if ($owned) { $taskSelections += $owned.ItemId.'$oid' }
    else {
        if (-not @($taskInventory.RawUpgrades | Where-Object { $_.ItemType -eq $type -and $_.ItemCount -gt 0 }).Count) { $null = Send-Fixture 'item' @{type=$type;count=1} }
        $taskSelections += 'raw:' + $type
    }
}
$taskValues = @{name='C - owned Glory MODs';mod0=$taskSelections[0];mod1=$taskSelections[1]}
foreach ($slot in 2..7) { $taskValues["mod$slot"] = '' }
Edit-Fixture 'SpecialItems' $taskGlory.ItemId.'$oid' 'exalted.mods.2' $taskValues
$taskInventory = Invoke-RestMethod ($taskAccountUrl + '/export') -Headers $taskHeaders
$taskGlory = @($taskInventory.SpecialItems | Where-Object ItemType -EQ $taskGloryType)[0]
Edit-Fixture 'Upgrades' $taskGlory.Configs[2].Upgrades[0] 'mod.rank' @{rank=10}
Edit-Fixture 'Upgrades' $taskGlory.Configs[2].Upgrades[1] 'mod.rank' @{rank=5}
$taskValues = @{name='D - unmodified Glory'}; foreach ($slot in 0..7) { $taskValues["mod$slot"]='' }
Edit-Fixture 'SpecialItems' $taskGlory.ItemId.'$oid' 'exalted.mods.3' $taskValues
foreach ($index in 4,5) {
    if ($taskGlory.Configs.Count -gt $index) { continue }
    $taskValues = @{name=''}; foreach ($slot in 0..7) { $taskValues["mod$slot"]='' }
    Edit-Fixture 'SpecialItems' $taskGlory.ItemId.'$oid' "exalted.mods.$index" $taskValues
}
$null = Send-Fixture 'kick' @{}
$taskInstalled = Get-Content -LiteralPath D:\Warframe\XFEWarframe\client.json -Raw | ConvertFrom-Json
& $taskInstaller repair --game D:\Warframe --server $taskInstalled.ServerUrl --payload (Join-Path $taskPackage 'Client/Bridge')
if ($LASTEXITCODE -ne 0) { throw 'Updating the copied game failed.' }
& $taskInstaller launch --game D:\Warframe --server $taskSession.origin --game-test-control
if ($LASTEXITCODE -ne 0) { throw 'Starting the copied game failed.' }
& (Join-Path $PSScriptRoot 'Test-MultiAbilityGame.ps1') -SessionFile $SessionFile -CryptoAssembly (Join-Path $taskPackage 'Server/BouncyCastle.Cryptography.dll') -ReportDirectory (Join-Path $ReportDirectory 'login') -LoginOnly
& (Join-Path $PSScriptRoot 'Test-ExaltedEquipmentGame.ps1') -SessionFile $SessionFile -ReportDirectory $ReportDirectory
Write-Output "Exalted equipment reports: $ReportDirectory"