Implement ordinary packed event conditions
This commit is contained in:
parent
087ebf1097
commit
f73234cb99
28 changed files with 2624 additions and 86 deletions
|
|
@ -3,8 +3,10 @@ use std::collections::BTreeSet;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
RuntimeCompanyControllerKind, RuntimeCompanyTarget, RuntimeEffect, RuntimeEventRecordTemplate,
|
||||
RuntimeState, RuntimeSummary, calendar::BoundaryEventKind,
|
||||
RuntimeCompanyControllerKind, RuntimeCompanyMetric, RuntimeCompanyTarget, RuntimeCondition,
|
||||
RuntimeConditionComparator, RuntimeEffect, RuntimeEventRecordTemplate, RuntimeState,
|
||||
RuntimeSummary, RuntimeTerritoryMetric, RuntimeTrackMetric, RuntimeTrackPieceCounts,
|
||||
calendar::BoundaryEventKind,
|
||||
};
|
||||
|
||||
const PERIODIC_TRIGGER_KIND_ORDER: [u8; 6] = [1, 0, 3, 2, 5, 4];
|
||||
|
|
@ -79,6 +81,11 @@ struct AppliedEffectsSummary {
|
|||
removed_record_ids: Vec<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct ResolvedConditionContext {
|
||||
matching_company_ids: BTreeSet<u32>,
|
||||
}
|
||||
|
||||
pub fn execute_step_command(
|
||||
state: &mut RuntimeState,
|
||||
command: &StepCommand,
|
||||
|
|
@ -212,19 +219,31 @@ fn service_trigger_kind(
|
|||
.or_insert(0) += 1;
|
||||
|
||||
for index in eligible_indices {
|
||||
let (record_id, record_effects, record_marks_collection_dirty, record_one_shot) = {
|
||||
let (
|
||||
record_id,
|
||||
record_conditions,
|
||||
record_effects,
|
||||
record_marks_collection_dirty,
|
||||
record_one_shot,
|
||||
) = {
|
||||
let record = &state.event_runtime_records[index];
|
||||
(
|
||||
record.record_id,
|
||||
record.conditions.clone(),
|
||||
record.effects.clone(),
|
||||
record.marks_collection_dirty,
|
||||
record.one_shot,
|
||||
)
|
||||
};
|
||||
|
||||
let Some(condition_context) = evaluate_record_conditions(state, &record_conditions)? else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let effect_summary = apply_runtime_effects(
|
||||
state,
|
||||
&record_effects,
|
||||
&condition_context,
|
||||
&mut mutated_company_ids,
|
||||
&mut staged_event_graph_mutations,
|
||||
)?;
|
||||
|
|
@ -275,6 +294,7 @@ fn service_trigger_kind(
|
|||
fn apply_runtime_effects(
|
||||
state: &mut RuntimeState,
|
||||
effects: &[RuntimeEffect],
|
||||
condition_context: &ResolvedConditionContext,
|
||||
mutated_company_ids: &mut BTreeSet<u32>,
|
||||
staged_event_graph_mutations: &mut Vec<EventGraphMutation>,
|
||||
) -> Result<AppliedEffectsSummary, String> {
|
||||
|
|
@ -286,7 +306,7 @@ fn apply_runtime_effects(
|
|||
state.world_flags.insert(key.clone(), *value);
|
||||
}
|
||||
RuntimeEffect::SetCompanyCash { target, value } => {
|
||||
let company_ids = resolve_company_target_ids(state, target)?;
|
||||
let company_ids = resolve_company_target_ids(state, target, condition_context)?;
|
||||
for company_id in company_ids {
|
||||
let company = state
|
||||
.companies
|
||||
|
|
@ -300,7 +320,7 @@ fn apply_runtime_effects(
|
|||
}
|
||||
}
|
||||
RuntimeEffect::DeactivateCompany { target } => {
|
||||
let company_ids = resolve_company_target_ids(state, target)?;
|
||||
let company_ids = resolve_company_target_ids(state, target, condition_context)?;
|
||||
for company_id in company_ids {
|
||||
let company = state
|
||||
.companies
|
||||
|
|
@ -319,7 +339,7 @@ fn apply_runtime_effects(
|
|||
}
|
||||
}
|
||||
RuntimeEffect::SetCompanyTrackLayingCapacity { target, value } => {
|
||||
let company_ids = resolve_company_target_ids(state, target)?;
|
||||
let company_ids = resolve_company_target_ids(state, target, condition_context)?;
|
||||
for company_id in company_ids {
|
||||
let company = state
|
||||
.companies
|
||||
|
|
@ -335,7 +355,7 @@ fn apply_runtime_effects(
|
|||
}
|
||||
}
|
||||
RuntimeEffect::AdjustCompanyCash { target, delta } => {
|
||||
let company_ids = resolve_company_target_ids(state, target)?;
|
||||
let company_ids = resolve_company_target_ids(state, target, condition_context)?;
|
||||
for company_id in company_ids {
|
||||
let company = state
|
||||
.companies
|
||||
|
|
@ -352,7 +372,7 @@ fn apply_runtime_effects(
|
|||
}
|
||||
}
|
||||
RuntimeEffect::AdjustCompanyDebt { target, delta } => {
|
||||
let company_ids = resolve_company_target_ids(state, target)?;
|
||||
let company_ids = resolve_company_target_ids(state, target, condition_context)?;
|
||||
for company_id in company_ids {
|
||||
let company = state
|
||||
.companies
|
||||
|
|
@ -456,9 +476,114 @@ fn commit_staged_event_graph_mutations(
|
|||
state.validate()
|
||||
}
|
||||
|
||||
fn evaluate_record_conditions(
|
||||
state: &RuntimeState,
|
||||
conditions: &[RuntimeCondition],
|
||||
) -> Result<Option<ResolvedConditionContext>, String> {
|
||||
if conditions.is_empty() {
|
||||
return Ok(Some(ResolvedConditionContext::default()));
|
||||
}
|
||||
|
||||
let mut company_matches: Option<BTreeSet<u32>> = None;
|
||||
|
||||
for condition in conditions {
|
||||
match condition {
|
||||
RuntimeCondition::CompanyNumericThreshold {
|
||||
target,
|
||||
metric,
|
||||
comparator,
|
||||
value,
|
||||
} => {
|
||||
let resolved = resolve_company_target_ids(
|
||||
state,
|
||||
target,
|
||||
&ResolvedConditionContext::default(),
|
||||
)?;
|
||||
let matching = resolved
|
||||
.into_iter()
|
||||
.filter(|company_id| {
|
||||
state.companies.iter().find(|company| company.company_id == *company_id).is_some_and(
|
||||
|company| compare_condition_value(
|
||||
company_metric_value(company, *metric),
|
||||
*comparator,
|
||||
*value,
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect::<BTreeSet<_>>();
|
||||
if matching.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
intersect_company_matches(&mut company_matches, matching);
|
||||
if company_matches.as_ref().is_some_and(BTreeSet::is_empty) {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
RuntimeCondition::TerritoryNumericThreshold {
|
||||
metric,
|
||||
comparator,
|
||||
value,
|
||||
} => {
|
||||
let actual = territory_metric_value(state, *metric);
|
||||
if !compare_condition_value(actual, *comparator, *value) {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
RuntimeCondition::CompanyTerritoryNumericThreshold {
|
||||
target,
|
||||
metric,
|
||||
comparator,
|
||||
value,
|
||||
} => {
|
||||
let resolved = resolve_company_target_ids(
|
||||
state,
|
||||
target,
|
||||
&ResolvedConditionContext::default(),
|
||||
)?;
|
||||
let matching = resolved
|
||||
.into_iter()
|
||||
.filter(|company_id| {
|
||||
compare_condition_value(
|
||||
company_territory_metric_value(state, *company_id, *metric),
|
||||
*comparator,
|
||||
*value,
|
||||
)
|
||||
})
|
||||
.collect::<BTreeSet<_>>();
|
||||
if matching.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
intersect_company_matches(&mut company_matches, matching);
|
||||
if company_matches.as_ref().is_some_and(BTreeSet::is_empty) {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Some(ResolvedConditionContext {
|
||||
matching_company_ids: company_matches.unwrap_or_default(),
|
||||
}))
|
||||
}
|
||||
|
||||
fn intersect_company_matches(
|
||||
company_matches: &mut Option<BTreeSet<u32>>,
|
||||
next: BTreeSet<u32>,
|
||||
) {
|
||||
match company_matches {
|
||||
Some(existing) => {
|
||||
existing.retain(|company_id| next.contains(company_id));
|
||||
}
|
||||
None => {
|
||||
*company_matches = Some(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_company_target_ids(
|
||||
state: &RuntimeState,
|
||||
target: &RuntimeCompanyTarget,
|
||||
condition_context: &ResolvedConditionContext,
|
||||
) -> Result<Vec<u32>, String> {
|
||||
match target {
|
||||
RuntimeCompanyTarget::AllActive => Ok(state
|
||||
|
|
@ -538,11 +663,101 @@ fn resolve_company_target_ids(
|
|||
}
|
||||
}
|
||||
RuntimeCompanyTarget::ConditionTrueCompany => {
|
||||
Err("target requires condition-evaluation context".to_string())
|
||||
if condition_context.matching_company_ids.is_empty() {
|
||||
Err("target requires condition-evaluation context".to_string())
|
||||
} else {
|
||||
Ok(condition_context
|
||||
.matching_company_ids
|
||||
.iter()
|
||||
.copied()
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn company_metric_value(company: &crate::RuntimeCompany, metric: RuntimeCompanyMetric) -> i64 {
|
||||
match metric {
|
||||
RuntimeCompanyMetric::CurrentCash => company.current_cash,
|
||||
RuntimeCompanyMetric::TotalDebt => company.debt as i64,
|
||||
RuntimeCompanyMetric::CreditRating => company.credit_rating_score.unwrap_or(0),
|
||||
RuntimeCompanyMetric::PrimeRate => company.prime_rate.unwrap_or(0),
|
||||
RuntimeCompanyMetric::TrackPiecesTotal => i64::from(company.track_piece_counts.total),
|
||||
RuntimeCompanyMetric::TrackPiecesSingle => i64::from(company.track_piece_counts.single),
|
||||
RuntimeCompanyMetric::TrackPiecesDouble => i64::from(company.track_piece_counts.double),
|
||||
RuntimeCompanyMetric::TrackPiecesTransition => {
|
||||
i64::from(company.track_piece_counts.transition)
|
||||
}
|
||||
RuntimeCompanyMetric::TrackPiecesElectric => {
|
||||
i64::from(company.track_piece_counts.electric)
|
||||
}
|
||||
RuntimeCompanyMetric::TrackPiecesNonElectric => {
|
||||
i64::from(company.track_piece_counts.non_electric)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn territory_metric_value(state: &RuntimeState, metric: RuntimeTerritoryMetric) -> i64 {
|
||||
state.territories
|
||||
.iter()
|
||||
.map(|territory| {
|
||||
track_piece_metric_value(
|
||||
territory.track_piece_counts,
|
||||
territory_metric_to_track_metric(metric),
|
||||
)
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
fn company_territory_metric_value(
|
||||
state: &RuntimeState,
|
||||
company_id: u32,
|
||||
metric: RuntimeTrackMetric,
|
||||
) -> i64 {
|
||||
state.company_territory_track_piece_counts
|
||||
.iter()
|
||||
.filter(|entry| entry.company_id == company_id)
|
||||
.map(|entry| track_piece_metric_value(entry.track_piece_counts, metric))
|
||||
.sum()
|
||||
}
|
||||
|
||||
fn track_piece_metric_value(counts: RuntimeTrackPieceCounts, metric: RuntimeTrackMetric) -> i64 {
|
||||
match metric {
|
||||
RuntimeTrackMetric::Total => i64::from(counts.total),
|
||||
RuntimeTrackMetric::Single => i64::from(counts.single),
|
||||
RuntimeTrackMetric::Double => i64::from(counts.double),
|
||||
RuntimeTrackMetric::Transition => i64::from(counts.transition),
|
||||
RuntimeTrackMetric::Electric => i64::from(counts.electric),
|
||||
RuntimeTrackMetric::NonElectric => i64::from(counts.non_electric),
|
||||
}
|
||||
}
|
||||
|
||||
fn territory_metric_to_track_metric(metric: RuntimeTerritoryMetric) -> RuntimeTrackMetric {
|
||||
match metric {
|
||||
RuntimeTerritoryMetric::TrackPiecesTotal => RuntimeTrackMetric::Total,
|
||||
RuntimeTerritoryMetric::TrackPiecesSingle => RuntimeTrackMetric::Single,
|
||||
RuntimeTerritoryMetric::TrackPiecesDouble => RuntimeTrackMetric::Double,
|
||||
RuntimeTerritoryMetric::TrackPiecesTransition => RuntimeTrackMetric::Transition,
|
||||
RuntimeTerritoryMetric::TrackPiecesElectric => RuntimeTrackMetric::Electric,
|
||||
RuntimeTerritoryMetric::TrackPiecesNonElectric => RuntimeTrackMetric::NonElectric,
|
||||
}
|
||||
}
|
||||
|
||||
fn compare_condition_value(
|
||||
actual: i64,
|
||||
comparator: RuntimeConditionComparator,
|
||||
expected: i64,
|
||||
) -> bool {
|
||||
match comparator {
|
||||
RuntimeConditionComparator::Ge => actual >= expected,
|
||||
RuntimeConditionComparator::Le => actual <= expected,
|
||||
RuntimeConditionComparator::Gt => actual > expected,
|
||||
RuntimeConditionComparator::Lt => actual < expected,
|
||||
RuntimeConditionComparator::Eq => actual == expected,
|
||||
RuntimeConditionComparator::Ne => actual != expected,
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_u64_delta(current: u64, delta: i64, company_id: u32) -> Result<u64, String> {
|
||||
if delta >= 0 {
|
||||
current
|
||||
|
|
@ -583,10 +798,15 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Unknown,
|
||||
current_cash: 10,
|
||||
debt: 0,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
}],
|
||||
selected_company_id: None,
|
||||
territories: Vec::new(),
|
||||
company_territory_track_piece_counts: Vec::new(),
|
||||
packed_event_collection: None,
|
||||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
|
|
@ -647,6 +867,7 @@ mod tests {
|
|||
marks_collection_dirty: true,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "runtime.effect_fired".to_string(),
|
||||
value: true,
|
||||
|
|
@ -660,6 +881,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::AllActive,
|
||||
delta: 5,
|
||||
|
|
@ -673,6 +895,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetSpecialCondition {
|
||||
label: "Dirty rerun fired".to_string(),
|
||||
value: 1,
|
||||
|
|
@ -747,6 +970,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Unknown,
|
||||
current_cash: 10,
|
||||
debt: 5,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -755,6 +981,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Unknown,
|
||||
current_cash: 20,
|
||||
debt: 8,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -767,6 +996,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![
|
||||
RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::Ids { ids: vec![2] },
|
||||
|
|
@ -803,6 +1033,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Human,
|
||||
current_cash: 10,
|
||||
debt: 0,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -811,6 +1044,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Ai,
|
||||
current_cash: 20,
|
||||
debt: 2,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -825,6 +1061,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::HumanCompanies,
|
||||
delta: 5,
|
||||
|
|
@ -838,6 +1075,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyDebt {
|
||||
target: RuntimeCompanyTarget::AiCompanies,
|
||||
delta: 3,
|
||||
|
|
@ -851,6 +1089,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::SelectedCompany,
|
||||
delta: 7,
|
||||
|
|
@ -884,6 +1123,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::SelectedCompany,
|
||||
delta: 1,
|
||||
|
|
@ -912,6 +1152,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::HumanCompanies,
|
||||
delta: 1,
|
||||
|
|
@ -938,6 +1179,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Human,
|
||||
current_cash: 10,
|
||||
debt: 1,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -946,6 +1190,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Human,
|
||||
current_cash: 20,
|
||||
debt: 2,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: false,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -954,6 +1201,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Ai,
|
||||
current_cash: 30,
|
||||
debt: 3,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -967,6 +1217,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::AllActive,
|
||||
delta: 5,
|
||||
|
|
@ -980,6 +1231,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyDebt {
|
||||
target: RuntimeCompanyTarget::HumanCompanies,
|
||||
delta: 4,
|
||||
|
|
@ -993,6 +1245,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyDebt {
|
||||
target: RuntimeCompanyTarget::AiCompanies,
|
||||
delta: 6,
|
||||
|
|
@ -1024,6 +1277,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Human,
|
||||
current_cash: 10,
|
||||
debt: 0,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: Some(8),
|
||||
}],
|
||||
|
|
@ -1036,6 +1292,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::DeactivateCompany {
|
||||
target: RuntimeCompanyTarget::SelectedCompany,
|
||||
}],
|
||||
|
|
@ -1063,6 +1320,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Human,
|
||||
current_cash: 10,
|
||||
debt: 0,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -1071,6 +1331,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Ai,
|
||||
current_cash: 20,
|
||||
debt: 0,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
},
|
||||
|
|
@ -1083,6 +1346,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetCompanyTrackLayingCapacity {
|
||||
target: RuntimeCompanyTarget::Ids { ids: vec![2] },
|
||||
value: Some(14),
|
||||
|
|
@ -1113,6 +1377,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyCash {
|
||||
target: RuntimeCompanyTarget::ConditionTrueCompany,
|
||||
delta: 1,
|
||||
|
|
@ -1141,6 +1406,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: true,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "one_shot".to_string(),
|
||||
value: true,
|
||||
|
|
@ -1177,6 +1443,9 @@ mod tests {
|
|||
controller_kind: RuntimeCompanyControllerKind::Unknown,
|
||||
current_cash: 10,
|
||||
debt: 2,
|
||||
credit_rating_score: None,
|
||||
prime_rate: None,
|
||||
track_piece_counts: RuntimeTrackPieceCounts::default(),
|
||||
active: true,
|
||||
available_track_laying_capacity: None,
|
||||
}],
|
||||
|
|
@ -1188,6 +1457,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AdjustCompanyDebt {
|
||||
target: RuntimeCompanyTarget::AllActive,
|
||||
delta: -3,
|
||||
|
|
@ -1215,6 +1485,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: true,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AppendEventRecord {
|
||||
record: Box::new(RuntimeEventRecordTemplate {
|
||||
record_id: 41,
|
||||
|
|
@ -1222,6 +1493,7 @@ mod tests {
|
|||
active: true,
|
||||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "follow_on_later_pass".to_string(),
|
||||
value: true,
|
||||
|
|
@ -1268,6 +1540,7 @@ mod tests {
|
|||
marks_collection_dirty: true,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AppendEventRecord {
|
||||
record: Box::new(RuntimeEventRecordTemplate {
|
||||
record_id: 51,
|
||||
|
|
@ -1275,6 +1548,7 @@ mod tests {
|
|||
active: true,
|
||||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "dirty_rerun_follow_on".to_string(),
|
||||
value: true,
|
||||
|
|
@ -1314,6 +1588,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: true,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![
|
||||
RuntimeEffect::AppendEventRecord {
|
||||
record: Box::new(RuntimeEventRecordTemplate {
|
||||
|
|
@ -1322,6 +1597,7 @@ mod tests {
|
|||
active: true,
|
||||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetCandidateAvailability {
|
||||
name: "Appended Industry".to_string(),
|
||||
value: 1,
|
||||
|
|
@ -1341,6 +1617,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "deactivated_after_first_pass".to_string(),
|
||||
value: true,
|
||||
|
|
@ -1354,6 +1631,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetSpecialCondition {
|
||||
label: "Activated On Second Pass".to_string(),
|
||||
value: 1,
|
||||
|
|
@ -1367,6 +1645,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::SetWorldFlag {
|
||||
key: "removed_after_first_pass".to_string(),
|
||||
value: true,
|
||||
|
|
@ -1436,6 +1715,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::AppendEventRecord {
|
||||
record: Box::new(RuntimeEventRecordTemplate {
|
||||
record_id: 71,
|
||||
|
|
@ -1443,6 +1723,7 @@ mod tests {
|
|||
active: true,
|
||||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
conditions: Vec::new(),
|
||||
effects: Vec::new(),
|
||||
}),
|
||||
}],
|
||||
|
|
@ -1455,6 +1736,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: Vec::new(),
|
||||
},
|
||||
],
|
||||
|
|
@ -1480,6 +1762,7 @@ mod tests {
|
|||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![RuntimeEffect::ActivateEventRecord { record_id: 999 }],
|
||||
}],
|
||||
..state()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue