Browse Source

add unit drops to drop table

pbs
jake 5 years ago
parent
commit
bdf9824662
  1. 21
      src/ship/drops/mod.rs

21
src/ship/drops/mod.rs

@ -12,12 +12,11 @@ use std::path::PathBuf;
use std::io::Read; use std::io::Read;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand::distributions::{WeightedIndex, Distribution};
use crate::ship::monster::MonsterType; use crate::ship::monster::MonsterType;
use crate::ship::room::{Difficulty, Episode}; use crate::ship::room::{Difficulty, Episode};
use crate::entity::item::ItemDetail; 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::armor::ArmorType;
use crate::entity::item::shield::ShieldType; use crate::entity::item::shield::ShieldType;
use crate::entity::item::unit::UnitType; 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_weapon::GenericWeaponTable;
use crate::ship::drops::generic_armor::GenericArmorTable; use crate::ship::drops::generic_armor::GenericArmorTable;
use crate::ship::drops::generic_shield::GenericShieldTable; 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 { fn data_file_path(episode: Episode, difficulty: Difficulty, section_id: SectionID, filename: &str) -> PathBuf {
@ -127,6 +127,7 @@ struct DropTable<R: Rng + SeedableRng> {
weapon_table: GenericWeaponTable, weapon_table: GenericWeaponTable,
armor_table: GenericArmorTable, armor_table: GenericArmorTable,
shield_table: GenericShieldTable, shield_table: GenericShieldTable,
unit_table: GenericUnitTable,
rng: R, rng: R,
} }
@ -149,6 +150,7 @@ impl<R: Rng + SeedableRng> DropTable<R> {
weapon_table: GenericWeaponTable::new(episode, difficulty, section_id), weapon_table: GenericWeaponTable::new(episode, difficulty, section_id),
armor_table: GenericArmorTable::new(episode, difficulty, section_id), armor_table: GenericArmorTable::new(episode, difficulty, section_id),
shield_table: GenericShieldTable::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(), rng: R::from_entropy(),
} }
} }
@ -161,30 +163,17 @@ impl<R: Rng + SeedableRng> DropTable<R> {
None None
} }
fn generate_armor(&self) -> Option<ItemDetail> {
None
}
fn generate_shield(&self) -> Option<ItemDetail> {
None
}
fn generate_unit(&self) -> Option<ItemDetail> {
None
}
fn generate_typed_drop(&mut self, map_area: &MapVariantType, monster: &MonsterDropStats) -> Option<ItemDetail> { fn generate_typed_drop(&mut self, map_area: &MapVariantType, monster: &MonsterDropStats) -> Option<ItemDetail> {
match monster.drop_type { match monster.drop_type {
MonsterDropType::Weapon => self.weapon_table.get_drop(map_area, &mut self.rng), 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::Armor => self.armor_table.get_drop(map_area, &mut self.rng),
MonsterDropType::Shield => self.shield_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, MonsterDropType::None => None,
} }
} }
fn get_drop(&mut self, map_area: &MapVariantType, monster: &MonsterType) -> Option<ItemDetail> { fn get_drop(&mut self, map_area: &MapVariantType, monster: &MonsterType) -> Option<ItemDetail> {
//let mut rng = rand::thread_rng();
let monster_stat = *self.monster_stats.get(monster)?; let monster_stat = *self.monster_stats.get(monster)?;
let drop_anything = self.rng.gen_range(0, 100); let drop_anything = self.rng.gen_range(0, 100);

Loading…
Cancel
Save