ravenous-tools/weaponry/src/weaponry_structs/equipement_structs.rs

163 lines
4.5 KiB
Rust

// Workspace: weaponry
// File: weaponry/src/weaponry_structs/equipement_structs.rs
//! Base equipement structures
use struct_field_names_as_array::FieldNamesAsArray;
use super::{DamageType, NatureTarget, SpecialCategory, WeaponCategory};
/// The final equipement list
///
/// This list is initialized with the base part and updated by succesive combinaisons
#[derive(Clone)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct FinalEquipementList {
/// Inner List of final equipements
pub(super) inner: Vec<Equipement>,
}
/// The final equipement, obtained by combining all parts
#[derive(Clone, Default)]
#[cfg_attr(test, derive(PartialEq, Debug))]
pub struct Equipement {
/// The inner stats used by the equipement
pub(super) stats: InnerStats,
}
/// The inner statistics of the equipement, used across all parts and final weapon
#[allow(clippy::missing_docs_in_private_items, missing_docs)]
#[derive(Clone, Default, FieldNamesAsArray)]
#[cfg_attr(test, derive(Debug, PartialEq))]
pub struct InnerStats {
pub id: u8,
pub name: Vec<String>,
pub(super) rarity: u8,
pub(super) cost: u8,
pub(super) difficulty: u8,
pub(super) tier: u8,
pub(super) damage: u8,
pub(super) p_damage: u8,
pub(super) precision: u8,
pub(super) rmax: u8,
pub(super) armor_break: u8,
pub(super) armor_pierce: u8,
pub(super) antimaterial: u8,
pub(super) damage_type: Option<DamageType>,
pub(super) protection: u8,
pub(super) integrity: u8,
pub(super) torque_two_handed: u8,
pub(super) torque_one_handed: u8,
pub(super) dodge: u8,
pub(super) parry: u8,
pub(super) speed: u8,
pub(super) stealth: u8,
pub(super) category: Option<WeaponCategory>,
pub(super) special: SpecialCategory,
pub(super) action_cost: u8,
pub(super) reload_cost: Option<u8>,
pub(super) range: u8,
pub(super) agility_bonus: u8,
}
/// Shape of the equipement, first mandatory part of an equipement
pub struct EqShape {
/// The inner stats of the part
pub(super) stats: InnerStats,
}
/// Material used for the equipement, all equipements are crafted with 1-2 materials
pub struct EqMaterial {
/// The inner stats of the part
pub(super) stats: InnerStats,
}
/// Nature of the equipement, some natures are reserved and some can be chained
///
/// Deciding on the combinaison can be tricky an will need an extra field
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,
}
/// Finishing touches, since all of them have a cost, they are treated in a special fashion
pub struct EqFinishing {
/// The inner stats of the part
pub(super) stats: InnerStats,
}
#[cfg(test)]
mod test {
// use super::*;
use crate::{interfaces::RecipeCollection, weaponry_structs::NatureTarget};
use super::{
EqFinishing, EqMaterial, EqNature, EqShape, Equipement, FinalEquipementList, InnerStats,
};
fn list_equip() -> Vec<Equipement> {
(0..10)
.map(|_| Equipement {
..Default::default()
})
.collect::<Vec<_>>()
}
#[test]
fn test_struct_creation() {
let stats = InnerStats::default();
let eq1 = Equipement {
..Default::default()
};
let list_eq = list_equip();
assert_eq!(stats, eq1.stats);
assert_eq!(list_eq[0], eq1);
}
#[test]
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]
fn test_default_behaviour() {
unimplemented!()
}
}