Add event inventory pickups

This commit is contained in:
2026-06-18 10:45:33 +09:00
parent cbfc221782
commit d69453472d
9 changed files with 119 additions and 16 deletions

View File

@@ -93,7 +93,7 @@ $validConditionTypes = @(
"any"
)
$validTriggers = @("battle_start", "battle_begin", "turn_start", "unit_reaches_tile")
$validActions = @("log", "dialogue", "set_objective", "spawn_deployment", "spawn_deployments")
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments")
$validEffects = @("heal_hp", "heal_mp", "cure_status")
$validItemKinds = @("weapon", "armor", "accessory", "consumable")
$validBonusStats = @("hp", "mp", "atk", "def", "int", "agi")
@@ -494,6 +494,32 @@ function Find-Item-Def([string]$ItemId) {
return $prop.Value
}
function Resolve-Event-Grant-Item-Id($Entry, [string]$Context) {
if ($Entry -is [string]) {
return [string]$Entry
}
if ($null -eq $Entry -or $Entry -is [System.Array]) {
Fail "$Context has malformed item grant."
}
return [string](Get-Prop $Entry "item_id" (Get-Prop $Entry "id" ""))
}
function Check-Event-Grant-Item($Entry, [string]$Context) {
$itemId = Resolve-Event-Grant-Item-Id $Entry $Context
if ([string]::IsNullOrWhiteSpace($itemId)) {
Fail "$Context has empty item id."
}
if (-not $itemIds.Contains($itemId)) {
Fail "$Context references unknown item: $itemId"
}
if (-not ($Entry -is [string]) -and (Has-Prop $Entry "count")) {
$count = [int](Get-Prop $Entry "count" 0)
if ($count -le 0) {
Fail "$Context has invalid count for item $itemId."
}
}
}
function Check-Class-Equipment-Slots() {
$weaponTypes = @()
$armorTypes = @()
@@ -1556,6 +1582,19 @@ foreach ($scenario in $campaign.scenarios) {
Check-Dialogue-Line $action "Scenario $scenarioId event $eventId dialogue"
}
}
if ($actionType -eq "grant_item") {
Check-Event-Grant-Item $action "Scenario $scenarioId event $eventId grant_item"
}
if ($actionType -eq "grant_items") {
$rawItems = Get-Prop $action "items" $null
$grantItems = @($rawItems)
if ($null -eq $rawItems -or $grantItems.Count -le 0) {
Fail "Scenario $scenarioId event $eventId grant_items action has malformed items."
}
foreach ($entry in $grantItems) {
Check-Event-Grant-Item $entry "Scenario $scenarioId event $eventId grant_items"
}
}
}
}