|
@ -13,7 +13,7 @@ use crate::ship::drops::load_data_file; |
|
|
use crate::ship::drops::tech_table::TechniqueTable;
|
|
|
use crate::ship::drops::tech_table::TechniqueTable;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, enum_utils::FromStr)]
|
|
|
enum ToolRateType {
|
|
|
enum ToolRateType {
|
|
|
Monomate,
|
|
|
Monomate,
|
|
|
Dimate,
|
|
|
Dimate,
|
|
@ -50,6 +50,19 @@ struct ToolRate { |
|
|
}*/
|
|
|
}*/
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
|
|
struct ToolRatesRaw {
|
|
|
|
|
|
area1: BTreeMap<String, u32>,
|
|
|
|
|
|
area2: BTreeMap<String, u32>,
|
|
|
|
|
|
area3: BTreeMap<String, u32>,
|
|
|
|
|
|
area4: BTreeMap<String, u32>,
|
|
|
|
|
|
area5: BTreeMap<String, u32>,
|
|
|
|
|
|
area6: BTreeMap<String, u32>,
|
|
|
|
|
|
area7: BTreeMap<String, u32>,
|
|
|
|
|
|
area8: BTreeMap<String, u32>,
|
|
|
|
|
|
area9: BTreeMap<String, u32>,
|
|
|
|
|
|
area10: BTreeMap<String, u32>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
struct ToolRates {
|
|
|
struct ToolRates {
|
|
|
area1: BTreeMap<ToolRateType, u32>,
|
|
|
area1: BTreeMap<ToolRateType, u32>,
|
|
|
area2: BTreeMap<ToolRateType, u32>,
|
|
|
area2: BTreeMap<ToolRateType, u32>,
|
|
@ -63,6 +76,23 @@ struct ToolRates { |
|
|
area10: BTreeMap<ToolRateType, u32>,
|
|
|
area10: BTreeMap<ToolRateType, u32>,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ToolRates {
|
|
|
|
|
|
fn new(raw: ToolRatesRaw) -> ToolRates {
|
|
|
|
|
|
ToolRates {
|
|
|
|
|
|
area1: raw.area1.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area2: raw.area2.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area3: raw.area3.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area4: raw.area4.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area5: raw.area5.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area6: raw.area6.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area7: raw.area7.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area8: raw.area8.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area9: raw.area9.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
area10: raw.area10.into_iter().map(|(name, rate)| (name.parse().unwrap(), rate)).collect(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
impl ToolRates {
|
|
|
impl ToolRates {
|
|
|
fn get_by_area<'a>(&'a self, map_area: &MapVariantType) -> &'a BTreeMap<ToolRateType, u32> {
|
|
|
fn get_by_area<'a>(&'a self, map_area: &MapVariantType) -> &'a BTreeMap<ToolRateType, u32> {
|
|
|
match map_area.area_value().unwrap() {
|
|
|
match map_area.area_value().unwrap() {
|
|
@ -87,8 +117,10 @@ pub struct ToolTable { |
|
|
|
|
|
|
|
|
impl ToolTable {
|
|
|
impl ToolTable {
|
|
|
pub fn new(episode: Episode, difficulty: Difficulty, section_id: SectionID) -> ToolTable {
|
|
|
pub fn new(episode: Episode, difficulty: Difficulty, section_id: SectionID) -> ToolTable {
|
|
|
|
|
|
let rates = load_data_file(episode, difficulty, section_id, "tool_rate.toml");
|
|
|
|
|
|
|
|
|
ToolTable {
|
|
|
ToolTable {
|
|
|
rates: load_data_file(episode, difficulty, section_id, "tool_rate.toml"),
|
|
|
|
|
|
|
|
|
rates: ToolRates::new(rates),
|
|
|
tech_table: TechniqueTable::new(episode, difficulty, section_id),
|
|
|
tech_table: TechniqueTable::new(episode, difficulty, section_id),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|