Added outfitspace to_hashmap

master
Mark 2024-02-16 18:24:28 -08:00
parent ab17930449
commit f5c9540fb7
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 13 additions and 1 deletions

View File

@ -1,4 +1,7 @@
use std::ops::{Add, AddAssign, Sub, SubAssign}; use std::{
collections::HashMap,
ops::{Add, AddAssign, Sub, SubAssign},
};
pub(crate) mod syntax { pub(crate) mod syntax {
use serde::Deserialize; use serde::Deserialize;
@ -44,6 +47,15 @@ impl OutfitSpace {
&& self.weapon >= smaller.weapon && self.weapon >= smaller.weapon
&& self.engine >= smaller.engine && self.engine >= smaller.engine
} }
/// Return a map of "space name" -> number
pub fn to_hashmap(&self) -> HashMap<String, u32> {
let mut m = HashMap::new();
m.insert("outfit".to_string(), self.outfit);
m.insert("weapon".to_string(), self.weapon);
m.insert("engine".to_string(), self.engine);
m
}
} }
impl Sub for OutfitSpace { impl Sub for OutfitSpace {