|
@ -13,7 +13,6 @@ 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;
|
|
|
use crate::ship::drops::generic_unit::GenericUnitTable;
|
|
|
use crate::ship::drops::tool_table::ToolTable;
|
|
|
use crate::ship::drops::tool_table::ToolTable;
|
|
|
use entity::item::ItemDetail;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
struct BoxDropRate {
|
|
|
struct BoxDropRate {
|
|
@ -176,8 +175,8 @@ impl BoxDropTable { |
|
|
fn random_box_drop<R: Rng>(&self, map_area: &MapArea, rng: &mut R) -> Option<ItemDropType> {
|
|
|
fn random_box_drop<R: Rng>(&self, map_area: &MapArea, rng: &mut R) -> Option<ItemDropType> {
|
|
|
self.rare_drop(map_area, rng).or_else(|| {
|
|
|
self.rare_drop(map_area, rng).or_else(|| {
|
|
|
let rate = self.box_rates.rates_by_area(map_area);
|
|
|
let rate = self.box_rates.rates_by_area(map_area);
|
|
|
let type_weights = WeightedIndex::new(&[rate.weapon_rate, rate.armor_rate, rate.shield_rate, rate.unit_rate,
|
|
|
|
|
|
rate.tool_rate, rate.meseta_rate, rate.nothing_rate]).unwrap();
|
|
|
|
|
|
|
|
|
let type_weights = WeightedIndex::new([rate.weapon_rate, rate.armor_rate, rate.shield_rate, rate.unit_rate,
|
|
|
|
|
|
rate.tool_rate, rate.meseta_rate, rate.nothing_rate]).unwrap();
|
|
|
let btype = type_weights.sample(rng);
|
|
|
let btype = type_weights.sample(rng);
|
|
|
match btype {
|
|
|
match btype {
|
|
|
0 => self.weapon_table.get_drop(map_area, rng),
|
|
|
0 => self.weapon_table.get_drop(map_area, rng),
|
|
|