Execute locomotive cost packed event descriptors
This commit is contained in:
parent
e2174713a9
commit
09039d24e4
18 changed files with 785 additions and 21 deletions
|
|
@ -495,6 +495,9 @@ fn apply_runtime_effects(
|
|||
.named_locomotive_availability
|
||||
.insert(name.clone(), u32::from(*value));
|
||||
}
|
||||
RuntimeEffect::SetNamedLocomotiveCost { name, value } => {
|
||||
state.named_locomotive_cost.insert(name.clone(), *value);
|
||||
}
|
||||
RuntimeEffect::SetSpecialCondition { label, value } => {
|
||||
state.special_conditions.insert(label.clone(), *value);
|
||||
}
|
||||
|
|
@ -1165,6 +1168,7 @@ mod tests {
|
|||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
named_locomotive_availability: BTreeMap::new(),
|
||||
named_locomotive_cost: BTreeMap::new(),
|
||||
special_conditions: BTreeMap::new(),
|
||||
service_state: RuntimeServiceState::default(),
|
||||
}
|
||||
|
|
@ -1416,6 +1420,43 @@ mod tests {
|
|||
assert_eq!(result.service_events[0].applied_effect_count, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn applies_named_locomotive_cost_effects() {
|
||||
let mut state = RuntimeState {
|
||||
event_runtime_records: vec![RuntimeEventRecord {
|
||||
record_id: 11,
|
||||
trigger_kind: 7,
|
||||
active: true,
|
||||
service_count: 0,
|
||||
marks_collection_dirty: false,
|
||||
one_shot: false,
|
||||
has_fired: false,
|
||||
conditions: Vec::new(),
|
||||
effects: vec![
|
||||
RuntimeEffect::SetNamedLocomotiveCost {
|
||||
name: "Big Boy".to_string(),
|
||||
value: 250000,
|
||||
},
|
||||
RuntimeEffect::SetNamedLocomotiveCost {
|
||||
name: "GP7".to_string(),
|
||||
value: 175000,
|
||||
},
|
||||
],
|
||||
}],
|
||||
..state()
|
||||
};
|
||||
|
||||
let result = execute_step_command(
|
||||
&mut state,
|
||||
&StepCommand::ServiceTriggerKind { trigger_kind: 7 },
|
||||
)
|
||||
.expect("named locomotive cost effects should succeed");
|
||||
|
||||
assert_eq!(state.named_locomotive_cost.get("Big Boy"), Some(&250000));
|
||||
assert_eq!(state.named_locomotive_cost.get("GP7"), Some(&175000));
|
||||
assert_eq!(result.service_events[0].applied_effect_count, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_symbolic_company_targets() {
|
||||
let mut state = RuntimeState {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue