diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e41bd344..8a369081 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -38,4 +38,4 @@ jobs: mv cargo-nextest /home/runner/.cargo/bin - name: run the tests - run: cargo nextest run + run: cargo nextest run -E 'not test(images::icons::tests::soulsy_pack_complete)' diff --git a/layouts/icon-pack-soulsy/ammo_arrow.svg b/layouts/icon-pack-soulsy/ammo_arrow.svg index 8ead7448..2a4f1583 100644 --- a/layouts/icon-pack-soulsy/ammo_arrow.svg +++ b/layouts/icon-pack-soulsy/ammo_arrow.svg @@ -1,12 +1,7 @@ - - - - - - - - + + + diff --git a/layouts/icon-pack-soulsy/ammo_arrow_bodkin.svg b/layouts/icon-pack-soulsy/ammo_arrow_bodkin.svg new file mode 100644 index 00000000..26f53c06 --- /dev/null +++ b/layouts/icon-pack-soulsy/ammo_arrow_bodkin.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/layouts/icon-pack-soulsy/ammo_arrow_broadhead.svg b/layouts/icon-pack-soulsy/ammo_arrow_broadhead.svg new file mode 100644 index 00000000..4ab7d7ab --- /dev/null +++ b/layouts/icon-pack-soulsy/ammo_arrow_broadhead.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/layouts/icon-pack-soulsy/ammo_arrow_hammerhead.svg b/layouts/icon-pack-soulsy/ammo_arrow_hammerhead.svg new file mode 100644 index 00000000..e6de767c --- /dev/null +++ b/layouts/icon-pack-soulsy/ammo_arrow_hammerhead.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/layouts/icon-pack-soulsy/ammo_bolt.svg b/layouts/icon-pack-soulsy/ammo_bolt.svg new file mode 100644 index 00000000..af005b4e --- /dev/null +++ b/layouts/icon-pack-soulsy/ammo_bolt.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/layouts/icon-pack-soulsy/ammo_dart.svg b/layouts/icon-pack-soulsy/ammo_dart.svg new file mode 100644 index 00000000..ddf8d841 --- /dev/null +++ b/layouts/icon-pack-soulsy/ammo_dart.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/data/ammo.rs b/src/data/ammo.rs index 7cca3329..7dce0832 100644 --- a/src/data/ammo.rs +++ b/src/data/ammo.rs @@ -39,32 +39,34 @@ impl HasKeywords for AmmoType { /// Use OCF keywords to identify this ammunition type and map it to /// one of the enum variants. fn classify(_name: &str, keywords: Vec, _ignored: bool) -> Self { - let color = super::color::color_from_keywords(&keywords); + let color = super::color::color_from_keywords(&keywords).clone(); - let ammo_keywords: Vec = keywords + let ammo_kinds: Vec = keywords .iter() .filter_map(|xs| match xs.as_str() { - "ArrowBodkin" => Some(Self::BodkinArrow(color.clone())), - "ArrowBroadhead" => Some(Self::BroadheadArrow(color.clone())), - "ArrowHammer" => Some(Self::HammerheadArrow(color.clone())), - "ArrowCrescent" => Some(Self::CrescentArrow(color.clone())), - "ArrowFire" => Some(Self::FireArrow(color.clone())), - "ArrowWhistle" => Some(Self::WhistleArrow(color.clone())), - "ArrowPractice" => Some(Self::PracticeArrow(color.clone())), - "OCF_AmmoTypeArrow" => Some(Self::Arrow(color.clone())), - "OCF_AmmoTypeBolt" => Some(Self::Bolt(color.clone())), - "OCF_AmmoTypeBullet" => Some(Self::Bullet(color.clone())), - "OCF_AmmoTypeDart" => Some(Self::Dart(color.clone())), - "OCF_AmmoTypeSlingshot" => Some(Self::Slingshot(color.clone())), - "OCF_WeapTypeMelee" => Some(Self::Melee(color.clone())), - "WAF_WeapTypeGrenade" => Some(Self::Grenade(color.clone())), + "ArrowBodkin" => Some(Self::BodkinArrow(color.clone().unwrap_or_default())), + "ArrowBroadhead" => Some(Self::BroadheadArrow(color.clone().unwrap_or_default())), + "ArrowHammer" => Some(Self::HammerheadArrow(color.clone().unwrap_or_default())), + "ArrowCrescent" => Some(Self::CrescentArrow(color.clone().unwrap_or_default())), + "ArrowFire" => Some(Self::FireArrow( + color.clone().unwrap_or_else(|| InvColor::Fire), + )), + "ArrowWhistle" => Some(Self::WhistleArrow(color.clone().unwrap_or_default())), + "ArrowPractice" => Some(Self::PracticeArrow(color.clone().unwrap_or_default())), + "OCF_AmmoTypeArrow" => Some(Self::Arrow(color.clone().unwrap_or_default())), + "OCF_AmmoTypeBolt" => Some(Self::Bolt(color.clone().unwrap_or_default())), + "OCF_AmmoTypeBullet" => Some(Self::Bullet(color.clone().unwrap_or_default())), + "OCF_AmmoTypeDart" => Some(Self::Dart(color.clone().unwrap_or_default())), + "OCF_AmmoTypeSlingshot" => Some(Self::Slingshot(color.clone().unwrap_or_default())), + "OCF_WeapTypeMelee" => Some(Self::Melee(color.clone().unwrap_or_default())), + "WAF_WeapTypeGrenade" => Some(Self::Grenade(color.clone().unwrap_or_default())), _ => None, }) .collect(); - if let Some(keyword) = ammo_keywords.first() { - keyword.clone() + if let Some(ammo) = ammo_kinds.first() { + ammo.clone() } else { - Self::Arrow(color) + Self::Arrow(color.unwrap_or_default()) } } } @@ -95,13 +97,13 @@ impl HasIcon for AmmoType { AmmoType::Bolt(_) => &Icon::AmmoBolt, AmmoType::Dart(_) => &Icon::AmmoDart, AmmoType::Slingshot(_) => &Icon::AmmoSlingshot, - AmmoType::BodkinArrow(_) => &Icon::AmmoBodkinArrow, - AmmoType::BroadheadArrow(_) => &Icon::AmmoBroadheadArrow, - AmmoType::HammerheadArrow(_) => &Icon::AmmoHammerheadArrow, - AmmoType::CrescentArrow(_) => &Icon::AmmoCrescentArrow, - AmmoType::FireArrow(_) => &Icon::AmmoFireArrow, - AmmoType::WhistleArrow(_) => &Icon::AmmoWhistleArrow, - AmmoType::PracticeArrow(_) => &Icon::AmmoPracticeArrow, + AmmoType::BodkinArrow(_) => &Icon::AmmoArrowBodkin, + AmmoType::BroadheadArrow(_) => &Icon::AmmoArrowBroadhead, + AmmoType::HammerheadArrow(_) => &Icon::AmmoArrowHammerhead, + AmmoType::CrescentArrow(_) => &Icon::AmmoArrowCrescent, + AmmoType::FireArrow(_) => &Icon::AmmoArrowFire, + AmmoType::WhistleArrow(_) => &Icon::AmmoArrowWhistle, + AmmoType::PracticeArrow(_) => &Icon::AmmoArrowPractice, _ => &Icon::AmmoArrow, } } diff --git a/src/data/armor.rs b/src/data/armor.rs index 796d0a1a..05458c36 100644 --- a/src/data/armor.rs +++ b/src/data/armor.rs @@ -37,7 +37,7 @@ impl HasIcon for ArmorType { impl HasKeywords for ArmorType { fn classify(name: &str, keywords: Vec, _twohanded: bool) -> Self { // log::debug!("ARMOR KWDS: {keywords:?}"); - let color = super::color::color_from_keywords(&keywords); + let color = super::color::color_from_keywords(&keywords).unwrap_or_default(); let tagset: EnumSet = strings_to_enumset(&keywords); let weight = if !WEIGHT_LIGHT.is_disjoint(tagset) { diff --git a/src/data/base.rs b/src/data/base.rs index ae5df049..6ddebd71 100644 --- a/src/data/base.rs +++ b/src/data/base.rs @@ -302,7 +302,7 @@ mod tests { "OCF_AccessoryBelt".to_string(), "Armor".to_string(), ]; - assert_eq!(color_from_keywords(&input), InvColor::Fire); + assert_eq!(color_from_keywords(&input), Some(InvColor::Fire)); let input = vec![ "Ammo".to_string(), @@ -316,7 +316,7 @@ mod tests { .filter_map(|xs| InvColor::try_from(xs.as_str()).ok()) .collect(); assert_eq!(1, color_keywords.len()); - assert_eq!(color_from_keywords(&input), InvColor::Water); + assert_eq!(color_from_keywords(&input), Some(InvColor::Water)); } #[test] diff --git a/src/data/color.rs b/src/data/color.rs index 6b69978f..e7d5cb0c 100644 --- a/src/data/color.rs +++ b/src/data/color.rs @@ -64,15 +64,15 @@ pub enum InvColor { Yellow, } -pub fn color_from_keywords(keywords: &[String]) -> InvColor { +pub fn color_from_keywords(keywords: &[String]) -> Option { let color_keywords: Vec = keywords .iter() .filter_map(|xs| InvColor::try_from(xs.as_str()).ok()) .collect(); if let Some(c) = color_keywords.first() { - c.clone() + Some(c.clone()) } else { - InvColor::default() + None } } diff --git a/src/data/food.rs b/src/data/food.rs index e5faf382..e7cf93d9 100644 --- a/src/data/food.rs +++ b/src/data/food.rs @@ -30,7 +30,7 @@ impl HasIcon for FoodType { /// We select color and icon from keywords, so we implement this trait. impl HasKeywords for FoodType { fn classify(name: &str, keywords: Vec, _twohanded: bool) -> Self { - let color = super::color::color_from_keywords(&keywords); + let color = super::color::color_from_keywords(&keywords).unwrap_or_default(); let tags = strings_to_enumset::(&keywords); let containers = strings_to_enumset::(&keywords); diff --git a/src/data/weapon.rs b/src/data/weapon.rs index e9edd6cf..d2815562 100644 --- a/src/data/weapon.rs +++ b/src/data/weapon.rs @@ -81,7 +81,7 @@ impl WeaponType { impl HasKeywords for WeaponType { fn classify(name: &str, keywords: Vec, twohanded: bool) -> Self { // log::debug!("WEAPON KWDS: {keywords:?}"); - let color = super::color_from_keywords(&keywords); + let color = super::color_from_keywords(&keywords).unwrap_or_default(); let tagset: EnumSet = strings_to_enumset(&keywords); // TODO This is not good enough. diff --git a/src/images/icons.rs b/src/images/icons.rs index ab582dac..b375bff1 100644 --- a/src/images/icons.rs +++ b/src/images/icons.rs @@ -16,17 +16,17 @@ use strum::{Display, EnumString, EnumVariantNames}; pub enum Icon { Alteration, AmmoArrow, + AmmoArrowBodkin, + AmmoArrowBroadhead, + AmmoArrowCrescent, + AmmoArrowFire, + AmmoArrowHammerhead, + AmmoArrowPractice, + AmmoArrowWhistle, AmmoBolt, AmmoBullet, AmmoDart, AmmoSlingshot, - AmmoBodkinArrow, - AmmoBroadheadArrow, - AmmoHammerheadArrow, - AmmoCrescentArrow, - AmmoFireArrow, - AmmoWhistleArrow, - AmmoPracticeArrow, ArmorAmulet, ArmorBackpack, ArmorBelt, @@ -223,13 +223,13 @@ impl Icon { Icon::AmmoBolt => Icon::AmmoArrow, Icon::AmmoDart => Icon::AmmoArrow, Icon::AmmoSlingshot => Icon::AmmoArrow, - Icon::AmmoBodkinArrow => Icon::AmmoArrow, - Icon::AmmoBroadheadArrow => Icon::AmmoArrow, - Icon::AmmoHammerheadArrow => Icon::AmmoArrow, - Icon::AmmoCrescentArrow => Icon::AmmoArrow, - Icon::AmmoFireArrow => Icon::AmmoArrow, - Icon::AmmoWhistleArrow => Icon::AmmoArrow, - Icon::AmmoPracticeArrow => Icon::AmmoArrow, + Icon::AmmoArrowBodkin => Icon::AmmoArrow, + Icon::AmmoArrowBroadhead => Icon::AmmoArrow, + Icon::AmmoArrowHammerhead => Icon::AmmoArrow, + Icon::AmmoArrowCrescent => Icon::AmmoArrow, + Icon::AmmoArrowFire => Icon::AmmoArrow, + Icon::AmmoArrowWhistle => Icon::AmmoArrow, + Icon::AmmoArrowPractice => Icon::AmmoArrow, // All armor becomes the heavy armor icon. Icon::ArmorAmulet => Icon::ArmorHeavy,