Add event prerequisite gates
This commit is contained in:
@@ -1502,6 +1502,25 @@ function Check-Required-Flags($RequiredFlags, [string]$ScenarioId, [string]$Cont
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Event-After-Event($When, [string]$ScenarioId, [string]$EventId, $EventIds) {
|
||||
if (-not (Has-Prop $When "after_event")) {
|
||||
return
|
||||
}
|
||||
$afterEvent = [string](Get-Prop $When "after_event" "")
|
||||
if ([string]::IsNullOrWhiteSpace($afterEvent)) {
|
||||
Fail "Scenario $ScenarioId event $EventId has empty after_event."
|
||||
}
|
||||
if (-not ($afterEvent -match "^[a-z0-9_]+$")) {
|
||||
Fail "Scenario $ScenarioId event $EventId has unstable after_event: $afterEvent"
|
||||
}
|
||||
if ($afterEvent -eq $EventId) {
|
||||
Fail "Scenario $ScenarioId event $EventId cannot depend on itself."
|
||||
}
|
||||
if (-not $EventIds.Contains($afterEvent)) {
|
||||
Fail "Scenario $ScenarioId event $EventId references missing after_event: $afterEvent"
|
||||
}
|
||||
}
|
||||
|
||||
function Check-Briefing($Briefing, [string]$ScenarioId) {
|
||||
if ($null -eq $Briefing) {
|
||||
return
|
||||
@@ -1735,6 +1754,7 @@ foreach ($scenario in $campaign.scenarios) {
|
||||
if ($null -eq $when -or $when -is [string] -or $when -is [System.Array]) {
|
||||
Fail "Scenario $scenarioId event $eventId has malformed when."
|
||||
}
|
||||
Check-Event-After-Event $when $scenarioId $eventId $eventIds
|
||||
Check-Required-Flags (Get-Prop $when "campaign_flags" $null) $scenarioId "event $eventId"
|
||||
$trigger = [string]$event.when.type
|
||||
if (-not $validTriggers.Contains($trigger)) {
|
||||
|
||||
Reference in New Issue
Block a user