From bdf98246622515c8b46ad9ac9dd8d9063368636d Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 15 Mar 2020 17:31:29 -0700 Subject: [PATCH] add unit drops to drop table --- src/ship/drops/mod.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/ship/drops/mod.rs b/src/ship/drops/mod.rs index c1780aa..a768a66 100644 --- a/src/ship/drops/mod.rs +++ b/src/ship/drops/mod.rs @@ -12,12 +12,11 @@ use std::path::PathBuf; use std::io::Read; use serde::{Serialize, Deserialize}; use rand::{Rng, SeedableRng}; -use rand::distributions::{WeightedIndex, Distribution}; use crate::ship::monster::MonsterType; use crate::ship::room::{Difficulty, Episode}; use crate::entity::item::ItemDetail; -use crate::entity::item::weapon::{WeaponType, Attribute, WeaponAttribute, WeaponSpecial}; +use crate::entity::item::weapon::WeaponType; use crate::entity::item::armor::ArmorType; use crate::entity::item::shield::ShieldType; use crate::entity::item::unit::UnitType; @@ -27,6 +26,7 @@ use crate::entity::character::SectionID; use crate::ship::drops::generic_weapon::GenericWeaponTable; use crate::ship::drops::generic_armor::GenericArmorTable; use crate::ship::drops::generic_shield::GenericShieldTable; +use crate::ship::drops::generic_unit::GenericUnitTable; fn data_file_path(episode: Episode, difficulty: Difficulty, section_id: SectionID, filename: &str) -> PathBuf { @@ -127,6 +127,7 @@ struct DropTable { weapon_table: GenericWeaponTable, armor_table: GenericArmorTable, shield_table: GenericShieldTable, + unit_table: GenericUnitTable, rng: R, } @@ -149,6 +150,7 @@ impl DropTable { weapon_table: GenericWeaponTable::new(episode, difficulty, section_id), armor_table: GenericArmorTable::new(episode, difficulty, section_id), shield_table: GenericShieldTable::new(episode, difficulty, section_id), + unit_table: GenericUnitTable::new(episode, difficulty, section_id), rng: R::from_entropy(), } } @@ -161,30 +163,17 @@ impl DropTable { None } - fn generate_armor(&self) -> Option { - None - } - - fn generate_shield(&self) -> Option { - None - } - - fn generate_unit(&self) -> Option { - None - } - fn generate_typed_drop(&mut self, map_area: &MapVariantType, monster: &MonsterDropStats) -> Option { match monster.drop_type { MonsterDropType::Weapon => self.weapon_table.get_drop(map_area, &mut self.rng), MonsterDropType::Armor => self.armor_table.get_drop(map_area, &mut self.rng), MonsterDropType::Shield => self.shield_table.get_drop(map_area, &mut self.rng), - MonsterDropType::Unit => self.generate_unit(), + MonsterDropType::Unit => self.unit_table.get_drop(map_area, &mut self.rng), MonsterDropType::None => None, } } fn get_drop(&mut self, map_area: &MapVariantType, monster: &MonsterType) -> Option { - //let mut rng = rand::thread_rng(); let monster_stat = *self.monster_stats.get(monster)?; let drop_anything = self.rng.gen_range(0, 100);