Work on the Generic impls
This commit is contained in:
parent
603a1cd8b6
commit
9facac6b9f
|
|
@ -21,7 +21,9 @@ where
|
|||
/// The type of the inner recipes, this type must be combinable
|
||||
type Recipes: Combineable;
|
||||
|
||||
/// Do the parrallel combination all inside
|
||||
/// A blanket implementation giving all combinaisons of recipes with another RecipeCollection
|
||||
///
|
||||
/// This method doesn't make use of parallel iterators as the workload is way faster than would be the memory dispatch
|
||||
fn combine_all_by_blanket<G>(&mut self, other: &G)
|
||||
where
|
||||
G: RecipeCollection<Recipes = Self::Recipes>,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
// Workspace: weaponry
|
||||
// File: weaponry/src/weaponry_structs/equipement_into_impls.rs
|
||||
//! Implementations to transform all Specialized equipement into a generic Equipement
|
||||
//! A specific implementation could be preferable, but this simplicity might allow for easier developpement
|
||||
|
||||
use super::{
|
||||
Equipement,
|
||||
equipement_structs::{EqFinishing, EqMaterial, EqNature, EqShape},
|
||||
};
|
||||
|
||||
impl From<EqShape> for Equipement {
|
||||
fn from(val: EqShape) -> Self {
|
||||
Self { stats: val.stats }
|
||||
}
|
||||
}
|
||||
impl From<EqMaterial> for Equipement {
|
||||
fn from(val: EqMaterial) -> Self {
|
||||
Self { stats: val.stats }
|
||||
}
|
||||
}
|
||||
impl From<EqNature> for Equipement {
|
||||
fn from(val: EqNature) -> Self {
|
||||
Self { stats: val.stats }
|
||||
}
|
||||
}
|
||||
impl From<EqFinishing> for Equipement {
|
||||
fn from(val: EqFinishing) -> Self {
|
||||
Self { stats: val.stats }
|
||||
}
|
||||
}
|
||||
|
|
@ -59,21 +59,6 @@ pub struct InnerStats {
|
|||
pub(super) agility_bonus: u8,
|
||||
}
|
||||
|
||||
// /// A type representing a weapon reload potential
|
||||
// #[derive(Clone, Default)]
|
||||
// #[cfg_attr(test, derive(Debug, PartialEq))]
|
||||
// pub struct OptionnalReloadType(Option<u8>);
|
||||
|
||||
// /// Optionnal Weapon
|
||||
// #[derive(Clone, Default)]
|
||||
// #[cfg_attr(test, derive(Debug, PartialEq))]
|
||||
// pub struct OptionnalWeaponCategory(Option<WeaponCategory>);
|
||||
|
||||
// /// Optionnal damage type
|
||||
// #[derive(Clone, Default)]
|
||||
// #[cfg_attr(test, derive(Debug, PartialEq))]
|
||||
// pub struct OptionnalDamageType(Option<DamageType>);
|
||||
|
||||
/// Shape of the equipement, first mandatory part of an equipement
|
||||
pub struct EqShape {
|
||||
/// The inner stats of the part
|
||||
|
|
@ -92,6 +77,8 @@ pub struct EqMaterial {
|
|||
pub struct EqNature {
|
||||
/// The inner stats of the part
|
||||
pub(super) stats: InnerStats,
|
||||
// TODO: Be sure to take this into account
|
||||
#[allow(dead_code)]
|
||||
/// Which kind of target this nature applies to
|
||||
pub(super) target: NatureTarget,
|
||||
}
|
||||
|
|
@ -106,7 +93,11 @@ pub struct EqFinishing {
|
|||
mod test {
|
||||
// use super::*;
|
||||
|
||||
use super::{Equipement, InnerStats};
|
||||
use crate::{interfaces::RecipeCollection, weaponry_structs::NatureTarget};
|
||||
|
||||
use super::{
|
||||
EqFinishing, EqMaterial, EqNature, EqShape, Equipement, FinalEquipementList, InnerStats,
|
||||
};
|
||||
|
||||
fn list_equip() -> Vec<Equipement> {
|
||||
(0..10)
|
||||
|
|
@ -130,7 +121,38 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_creating_all_equipements() {}
|
||||
fn test_creating_all_equipements() {
|
||||
let shape = vec![
|
||||
EqShape {
|
||||
stats: InnerStats::default(),
|
||||
}
|
||||
.into(),
|
||||
];
|
||||
let nature = vec![
|
||||
EqNature {
|
||||
stats: InnerStats::default(),
|
||||
target: NatureTarget::Armor,
|
||||
}
|
||||
.into(),
|
||||
];
|
||||
let material = vec![
|
||||
EqMaterial {
|
||||
stats: InnerStats::default(),
|
||||
}
|
||||
.into(),
|
||||
];
|
||||
let finishing = vec![
|
||||
EqFinishing {
|
||||
stats: InnerStats::default(),
|
||||
}
|
||||
.into(),
|
||||
];
|
||||
|
||||
let mut leq = FinalEquipementList::from_vectored(shape);
|
||||
leq.combine_all_by_blanket(&FinalEquipementList::from_vectored(nature));
|
||||
leq.combine_all_by_blanket(&FinalEquipementList::from_vectored(material));
|
||||
leq.combine_all_by_blanket(&FinalEquipementList::from_vectored(finishing));
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ mod equipement_impl_database;
|
|||
mod equipement_impl_io;
|
||||
mod equipement_impl_logic;
|
||||
mod equipement_impl_math;
|
||||
mod equipement_into_impls;
|
||||
pub mod equipement_structs;
|
||||
|
||||
// Republishes the most used symbols
|
||||
|
|
|
|||
Loading…
Reference in New Issue