Add scripted event withdrawals
This commit is contained in:
@@ -93,7 +93,7 @@ $validConditionTypes = @(
|
||||
"any"
|
||||
)
|
||||
$validTriggers = @("battle_start", "battle_begin", "turn_start", "unit_reaches_tile")
|
||||
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments")
|
||||
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments", "withdraw_unit", "withdraw_units")
|
||||
$validEffects = @("heal_hp", "heal_mp", "cure_status")
|
||||
$validItemKinds = @("weapon", "armor", "accessory", "consumable")
|
||||
$validItemRarities = @("common", "named")
|
||||
@@ -554,6 +554,32 @@ function Check-Event-Grant-Item($Entry, [string]$Context) {
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Event-Withdraw-Unit-Id([string]$UnitId, $KnownUnitIds, [string]$Context) {
|
||||
if ([string]::IsNullOrWhiteSpace($UnitId)) {
|
||||
Fail "$Context has empty unit id."
|
||||
}
|
||||
if (-not $KnownUnitIds.Contains($UnitId)) {
|
||||
Fail "$Context references unknown unit: $UnitId"
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Event-Withdraw-Units($UnitIds, $KnownUnitIds, [string]$Context) {
|
||||
if ($null -eq $UnitIds -or -not ($UnitIds -is [System.Array])) {
|
||||
Fail "$Context unit_ids must be an array."
|
||||
}
|
||||
if (@($UnitIds).Count -le 0) {
|
||||
Fail "$Context unit_ids must not be empty."
|
||||
}
|
||||
$seenWithdrawals = New-Object System.Collections.Generic.HashSet[string]
|
||||
foreach ($unitIdValue in @($UnitIds)) {
|
||||
$unitId = [string]$unitIdValue
|
||||
Check-Event-Withdraw-Unit-Id $unitId $KnownUnitIds $Context
|
||||
if (-not $seenWithdrawals.Add($unitId)) {
|
||||
Fail "$Context has duplicate unit: $unitId"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Class-Equipment-Slots() {
|
||||
$weaponTypes = @()
|
||||
$armorTypes = @()
|
||||
@@ -1757,6 +1783,13 @@ foreach ($scenario in $campaign.scenarios) {
|
||||
Check-Event-Grant-Item $entry "Scenario $scenarioId event $eventId grant_items"
|
||||
}
|
||||
}
|
||||
if ($actionType -eq "withdraw_unit") {
|
||||
$unitId = [string](Get-Prop $action "unit_id" (Get-Prop $action "id" ""))
|
||||
Check-Event-Withdraw-Unit-Id $unitId $knownUnitIds "Scenario $scenarioId event $eventId withdraw_unit"
|
||||
}
|
||||
if ($actionType -eq "withdraw_units") {
|
||||
Check-Event-Withdraw-Units (Get-Prop $action "unit_ids" $null) $knownUnitIds "Scenario $scenarioId event $eventId withdraw_units"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user