Add event gold pickups

This commit is contained in:
2026-06-18 15:33:07 +09:00
parent 5a3e5e1b64
commit 2bde55d76b
9 changed files with 173 additions and 12 deletions

View File

@@ -93,7 +93,7 @@ $validConditionTypes = @(
"any"
)
$validTriggers = @("battle_start", "battle_begin", "turn_start", "unit_reaches_tile", "unit_defeated")
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "spawn_deployment", "spawn_deployments", "withdraw_unit", "withdraw_units", "set_ai_target_priority")
$validActions = @("log", "dialogue", "set_objective", "grant_item", "grant_items", "grant_gold", "spawn_deployment", "spawn_deployments", "withdraw_unit", "withdraw_units", "set_ai_target_priority")
$validEffects = @("heal_hp", "heal_mp", "cure_status")
$validItemKinds = @("weapon", "armor", "accessory", "consumable")
$validItemRarities = @("common", "named")
@@ -621,6 +621,22 @@ function Check-Event-Grant-Item($Entry, [string]$Context) {
}
}
function Check-Event-Grant-Gold($Action, [string]$Context) {
if (-not (Has-Prop $Action "amount")) {
Fail "$Context must set amount."
}
$amountValue = Get-Prop $Action "amount" 0
if (-not ($amountValue -is [int] -or $amountValue -is [long])) {
Fail "$Context amount must be an integer."
}
if ([int]$amountValue -le 0) {
Fail "$Context amount must be positive."
}
if ((Has-Prop $Action "text") -and [string]::IsNullOrWhiteSpace([string](Get-Prop $Action "text" ""))) {
Fail "$Context text must not be empty."
}
}
function Check-Event-Withdraw-Unit-Id([string]$UnitId, $KnownUnitIds, [string]$Context) {
if ([string]::IsNullOrWhiteSpace($UnitId)) {
Fail "$Context has empty unit id."
@@ -1926,6 +1942,9 @@ foreach ($scenario in $campaign.scenarios) {
Check-Event-Grant-Item $entry "Scenario $scenarioId event $eventId grant_items"
}
}
if ($actionType -eq "grant_gold") {
Check-Event-Grant-Gold $action "Scenario $scenarioId event $eventId grant_gold"
}
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"