From 23a3d1212ec028f58d02eef4131d03219fa01c3a Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 1 Sep 2023 12:56:41 -0300 Subject: [PATCH 1/5] match mag feed decrease behaviour with the client and fix test --- src/entity/item/mag.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index 17fa1b4..035f1e3 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -1029,10 +1029,30 @@ impl Mag { MAG_STATS.get(&self.mag).map(|stats| { MAG_FEEDING_TABLES.get(stats.feed_table).map(|feeding_table| { feeding_table.get(&tool).map(|feed_stats| { - self.def = std::cmp::max(std::cmp::max((self.def as i16) + feed_stats.def, 0) as u16, self.def()*100); - self.pow = std::cmp::max(std::cmp::max((self.pow as i16) + feed_stats.pow, 0) as u16, self.pow()*100); - self.dex = std::cmp::max(std::cmp::max((self.dex as i16) + feed_stats.dex, 0) as u16, self.dex()*100); - self.mnd = std::cmp::max(std::cmp::max((self.mnd as i16) + feed_stats.mnd, 0) as u16, self.mind()*100); + self.def = { + if (self.def as i16 + feed_stats.def) < ((self.def()*100) as i16) { + self.def + } else { + std::cmp::max(std::cmp::max((self.def as i16) + feed_stats.def, 0) as u16, self.def()*100) + }}; + self.pow = { + if (self.pow as i16 + feed_stats.pow) < ((self.pow()*100) as i16) { + self.pow + } else { + std::cmp::max(std::cmp::max((self.pow as i16) + feed_stats.pow, 0) as u16, self.pow()*100) + }}; + self.dex = { + if (self.dex as i16 + feed_stats.dex) < ((self.dex()*100) as i16) { + self.dex + } else { + std::cmp::max(std::cmp::max((self.dex as i16) + feed_stats.dex, 0) as u16, self.dex()*100) + }}; + self.mnd = { + if (self.mnd as i16 + feed_stats.mnd) < ((self.mind()*100) as i16) { + self.mnd + } else { + std::cmp::max(std::cmp::max((self.mnd as i16) + feed_stats.mnd, 0) as u16, self.mind()*100) + }}; self.iq = std::cmp::min(((self.iq as i16) + feed_stats.iq as i16) as u8, 200); self.synchro = std::cmp::min(((self.synchro as i8) + feed_stats.syn) as u8, 120); }) @@ -1188,7 +1208,7 @@ mod test { f.read_to_string(&mut s).unwrap(); let mut feed: HashMap>> = toml::from_str(&s).unwrap(); - let feed = feed.remove("feedtable".into()).unwrap(); + let feed = feed.remove("feedtable").unwrap(); let _feed = feed.into_iter() .map(|table| { table.into_iter() @@ -1219,7 +1239,7 @@ mod test { } assert!(mag == Mag { mag: MagType::Sato, - def: 507, + def: 509, pow: 5019, dex: 4505, mnd: 0, -- 2.36.0 From 226577f91a1e3cd1b032dd8d4a86b17c76f4effb Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 1 Sep 2023 13:10:49 -0300 Subject: [PATCH 2/5] car go fast? no, cargo clippy vroom vroom --- src/ship/drops/box_drop_table.rs | 2 +- src/ship/drops/generic_armor.rs | 4 ++-- src/ship/drops/generic_shield.rs | 2 +- src/ship/drops/generic_weapon.rs | 6 +++--- src/ship/items/apply_item.rs | 2 +- src/ship/shops/weapon.rs | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ship/drops/box_drop_table.rs b/src/ship/drops/box_drop_table.rs index f507d27..ae75b58 100644 --- a/src/ship/drops/box_drop_table.rs +++ b/src/ship/drops/box_drop_table.rs @@ -176,7 +176,7 @@ impl BoxDropTable { fn random_box_drop(&self, map_area: &MapArea, rng: &mut R) -> Option { self.rare_drop(map_area, rng).or_else(|| { 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, + 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); match btype { diff --git a/src/ship/drops/generic_armor.rs b/src/ship/drops/generic_armor.rs index 2bf5895..667aadc 100644 --- a/src/ship/drops/generic_armor.rs +++ b/src/ship/drops/generic_armor.rs @@ -46,7 +46,7 @@ impl GenericArmorTable { } fn armor_type(&self, area_map: &MapArea, rng: &mut R) -> ArmorType { - let rank_weights = WeightedIndex::new(&[self.rank_rates.rank0, self.rank_rates.rank1, self.rank_rates.rank2, + let rank_weights = WeightedIndex::new([self.rank_rates.rank0, self.rank_rates.rank1, self.rank_rates.rank2, self.rank_rates.rank3, self.rank_rates.rank4]).unwrap(); let rank = rank_weights.sample(rng) as i32; let armor_level = std::cmp::max(0i32, self.armor_set as i32 - 3i32 + rank + area_map.drop_area_value().unwrap_or(0) as i32); @@ -80,7 +80,7 @@ impl GenericArmorTable { } pub fn slots(&self, _area_map: &MapArea, rng: &mut R) -> usize { - let slot_weights = WeightedIndex::new(&[self.slot_rates.slot0, self.slot_rates.slot1, self.slot_rates.slot2, + let slot_weights = WeightedIndex::new([self.slot_rates.slot0, self.slot_rates.slot1, self.slot_rates.slot2, self.slot_rates.slot3, self.slot_rates.slot4]).unwrap(); slot_weights.sample(rng) } diff --git a/src/ship/drops/generic_shield.rs b/src/ship/drops/generic_shield.rs index 9eec585..8d17e26 100644 --- a/src/ship/drops/generic_shield.rs +++ b/src/ship/drops/generic_shield.rs @@ -36,7 +36,7 @@ impl GenericShieldTable { } fn shield_type(&self, area_map: &MapArea, rng: &mut R) -> ShieldType { - let rank_weights = WeightedIndex::new(&[self.rank_rates.rank0, self.rank_rates.rank1, self.rank_rates.rank2, + let rank_weights = WeightedIndex::new([self.rank_rates.rank0, self.rank_rates.rank1, self.rank_rates.rank2, self.rank_rates.rank3, self.rank_rates.rank4]).unwrap(); let rank = rank_weights.sample(rng) as i32; let shield_level = std::cmp::max(0i32, self.shield_set as i32 - 3i32 + rank + area_map.drop_area_value().unwrap_or(0) as i32); diff --git a/src/ship/drops/generic_weapon.rs b/src/ship/drops/generic_weapon.rs index d1fb2bb..290b267 100644 --- a/src/ship/drops/generic_weapon.rs +++ b/src/ship/drops/generic_weapon.rs @@ -240,7 +240,7 @@ impl AttributeTable { fn generate_attribute(&self, pattern: &PercentPatternType, rates: &AttributeRate, rng: &mut R) -> Option { - let attribute_weights = WeightedIndex::new(&[rates.none, rates.native, rates.abeast, rates.machine, rates.dark, rates.hit]).unwrap(); + let attribute_weights = WeightedIndex::new([rates.none, rates.native, rates.abeast, rates.machine, rates.dark, rates.hit]).unwrap(); let attr = match attribute_weights.sample(rng) { 0 => return None, 1 => Attribute::Native, @@ -253,7 +253,7 @@ impl AttributeTable { let percents = self.percent_rates.get_by_pattern(pattern); - let value_weights = WeightedIndex::new(&percents.as_array()).unwrap(); + let value_weights = WeightedIndex::new(percents.as_array()).unwrap(); let value = value_weights.sample(rng); let percent = ((value + 1) * 5) as i8; @@ -477,7 +477,7 @@ impl GenericWeaponTable { let pattern = std::cmp::min(area % ratio.inc, 3); let weights = self.grind_rates.grind_rate[pattern as usize]; - let grind_choice = WeightedIndex::new(&weights).unwrap(); + let grind_choice = WeightedIndex::new(weights).unwrap(); grind_choice.sample(rng) } diff --git a/src/ship/items/apply_item.rs b/src/ship/items/apply_item.rs index 4c1a636..a003b44 100644 --- a/src/ship/items/apply_item.rs +++ b/src/ship/items/apply_item.rs @@ -226,7 +226,7 @@ pub async fn liberta_kit(entity_gateway: &mut EG, used_cell: fn jack_o_lantern() -> Result, anyhow::Error> { - let mag_rate = WeightedIndex::new(&[13, 13, 13, 13, 12, 12, 12, 12]).unwrap(); + let mag_rate = WeightedIndex::new([13, 13, 13, 13, 12, 12, 12, 12]).unwrap(); let mag_type = match mag_rate.sample(&mut rand_chacha::ChaChaRng::from_entropy()) { 0 => ToolType::CellOfMag502, 1 => ToolType::CellOfMag213, diff --git a/src/ship/shops/weapon.rs b/src/ship/shops/weapon.rs index 14509c8..a17e14d 100644 --- a/src/ship/shops/weapon.rs +++ b/src/ship/shops/weapon.rs @@ -412,7 +412,7 @@ impl WeaponShop { .last() .unwrap(); - let attr_choice = WeightedIndex::new(&[tier.none, tier.native, tier.abeast, tier.machine, tier.dark, tier.hit]).unwrap(); + let attr_choice = WeightedIndex::new([tier.none, tier.native, tier.abeast, tier.machine, tier.dark, tier.hit]).unwrap(); let attr = match attr_choice.sample(&mut self.rng) { 0 => return None, 1 => Attribute::Native, @@ -439,7 +439,7 @@ impl WeaponShop { .last() .unwrap(); - let attr_choice = WeightedIndex::new(&[tier.none, tier.native, tier.abeast, tier.machine, tier.dark, tier.hit]).unwrap(); + let attr_choice = WeightedIndex::new([tier.none, tier.native, tier.abeast, tier.machine, tier.dark, tier.hit]).unwrap(); let attr = match attr_choice.sample(&mut self.rng) { 0 => return None, 1 => Attribute::Native, -- 2.36.0 From 7104ccb9908a81940b0234b3429a3b08d760855f Mon Sep 17 00:00:00 2001 From: andy Date: Sun, 10 Sep 2023 11:15:53 -0300 Subject: [PATCH 3/5] cool empty test bro --- src/entity/item/mag.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index 035f1e3..b865c62 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -1251,9 +1251,5 @@ mod test { id: SectionID::Whitill, }); } - - #[test] - fn test_mag_does_not_level_down() { - } } -- 2.36.0 From e9b2a1340cf5280780b45c2175fe04a482dc27b4 Mon Sep 17 00:00:00 2001 From: andy Date: Sun, 25 Feb 2024 15:11:40 -0400 Subject: [PATCH 4/5] nonsense --- text.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 text.txt diff --git a/text.txt b/text.txt new file mode 100644 index 0000000..e69de29 -- 2.36.0 From dd80302805119a694a0784c836c1f9f9445f9eb1 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 26 Feb 2024 18:07:34 -0400 Subject: [PATCH 5/5] Revert "nonsense" This reverts commit e9b2a1340cf5280780b45c2175fe04a482dc27b4. --- text.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 text.txt diff --git a/text.txt b/text.txt deleted file mode 100644 index e69de29..0000000 -- 2.36.0