|
|
@ -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<R: Rng + SeedableRng> { |
|
|
|
weapon_table: GenericWeaponTable,
|
|
|
|
armor_table: GenericArmorTable,
|
|
|
|
shield_table: GenericShieldTable,
|
|
|
|
unit_table: GenericUnitTable,
|
|
|
|
rng: R,
|
|
|
|
}
|
|
|
|
|
|
|
@ -149,6 +150,7 @@ impl<R: Rng + SeedableRng> DropTable<R> { |
|
|
|
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<R: Rng + SeedableRng> DropTable<R> { |
|
|
|
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> {
|
|
|
|
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<ItemDetail> {
|
|
|
|
//let mut rng = rand::thread_rng();
|
|
|
|
let monster_stat = *self.monster_stats.get(monster)?;
|
|
|
|
|
|
|
|
let drop_anything = self.rng.gen_range(0, 100);
|
|
|
|