Add named locomotive availability runtime surface
This commit is contained in:
parent
c04c19ac82
commit
8c7ff335cb
16 changed files with 542 additions and 13 deletions
|
|
@ -72,6 +72,8 @@ pub struct RuntimeSummary {
|
|||
pub event_runtime_record_count: usize,
|
||||
pub candidate_availability_count: usize,
|
||||
pub zero_candidate_availability_count: usize,
|
||||
pub named_locomotive_availability_count: usize,
|
||||
pub zero_named_locomotive_availability_count: usize,
|
||||
pub special_condition_count: usize,
|
||||
pub enabled_special_condition_count: usize,
|
||||
pub save_profile_kind: Option<String>,
|
||||
|
|
@ -570,6 +572,12 @@ impl RuntimeSummary {
|
|||
.values()
|
||||
.filter(|value| **value == 0)
|
||||
.count(),
|
||||
named_locomotive_availability_count: state.named_locomotive_availability.len(),
|
||||
zero_named_locomotive_availability_count: state
|
||||
.named_locomotive_availability
|
||||
.values()
|
||||
.filter(|value| **value == 0)
|
||||
.count(),
|
||||
special_condition_count: state.special_conditions.len(),
|
||||
enabled_special_condition_count: state
|
||||
.special_conditions
|
||||
|
|
@ -781,6 +789,7 @@ mod tests {
|
|||
}),
|
||||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
named_locomotive_availability: BTreeMap::new(),
|
||||
special_conditions: BTreeMap::new(),
|
||||
service_state: RuntimeServiceState::default(),
|
||||
};
|
||||
|
|
@ -869,6 +878,7 @@ mod tests {
|
|||
packed_event_collection: None,
|
||||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
named_locomotive_availability: BTreeMap::new(),
|
||||
special_conditions: BTreeMap::new(),
|
||||
service_state: RuntimeServiceState::default(),
|
||||
};
|
||||
|
|
@ -878,6 +888,44 @@ mod tests {
|
|||
assert_eq!(summary.active_company_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counts_named_locomotive_availability_entries_and_zero_values() {
|
||||
let state = RuntimeState {
|
||||
calendar: CalendarPoint {
|
||||
year: 1830,
|
||||
month_slot: 0,
|
||||
phase_slot: 0,
|
||||
tick_slot: 0,
|
||||
},
|
||||
world_flags: BTreeMap::new(),
|
||||
save_profile: RuntimeSaveProfileState::default(),
|
||||
world_restore: RuntimeWorldRestoreState::default(),
|
||||
metadata: BTreeMap::new(),
|
||||
companies: Vec::new(),
|
||||
selected_company_id: None,
|
||||
players: Vec::new(),
|
||||
selected_player_id: None,
|
||||
trains: Vec::new(),
|
||||
territories: Vec::new(),
|
||||
company_territory_track_piece_counts: Vec::new(),
|
||||
company_territory_access: Vec::new(),
|
||||
packed_event_collection: None,
|
||||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
named_locomotive_availability: BTreeMap::from([
|
||||
("Big Boy".to_string(), 0),
|
||||
("GP7".to_string(), 1),
|
||||
("Mikado".to_string(), 0),
|
||||
]),
|
||||
special_conditions: BTreeMap::new(),
|
||||
service_state: RuntimeServiceState::default(),
|
||||
};
|
||||
|
||||
let summary = RuntimeSummary::from_state(&state);
|
||||
assert_eq!(summary.named_locomotive_availability_count, 3);
|
||||
assert_eq!(summary.zero_named_locomotive_availability_count, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counts_world_frontier_buckets_separately() {
|
||||
let state = RuntimeState {
|
||||
|
|
@ -966,6 +1014,7 @@ mod tests {
|
|||
}),
|
||||
event_runtime_records: Vec::new(),
|
||||
candidate_availability: BTreeMap::new(),
|
||||
named_locomotive_availability: BTreeMap::new(),
|
||||
special_conditions: BTreeMap::new(),
|
||||
service_state: RuntimeServiceState::default(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue