Merge pull request 'Workflow and mock' (#25) from weapons into main
Reviewed-on: #25
This commit is contained in:
commit
d3ccc315c1
|
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
rayon = "1.10.0"
|
||||
|
|
|
|||
|
|
@ -4,3 +4,90 @@
|
|||
//!
|
||||
//! These strategies can lock a parameter to allow a more fine tuned balancing
|
||||
//! or balancing specifically one parameter (balancing materials, balencing finishes etc..)
|
||||
//! These strategies must take into account the level of the fighter (hence his precision) and of the craftsman (hence a difficulty diminution)
|
||||
//!
|
||||
#![allow(dead_code)]
|
||||
|
||||
use rayon::iter::ParallelIterator;
|
||||
|
||||
/// Generation strategy, how to generate all the data, instead of a full permutation
|
||||
pub enum EquipementStrategy {
|
||||
/// Full permutation, generate all possible outcomes
|
||||
GenerateAll,
|
||||
/// Generate all the named equipements
|
||||
GenerateNamed,
|
||||
/// Do not add finishing touches
|
||||
NoFinishes,
|
||||
}
|
||||
|
||||
/// Which material to select
|
||||
pub enum MaterialsStrategy {
|
||||
/// Add all materials to the mix
|
||||
AllMaterials,
|
||||
/// Add only tier one material
|
||||
OnlyTier1,
|
||||
/// Add only easy materials
|
||||
OnlyEasy,
|
||||
/// Add only cheap materials
|
||||
OnlyCheap,
|
||||
/// Add only one material
|
||||
OnlyOne,
|
||||
}
|
||||
|
||||
/// Filter to apply after the generation
|
||||
pub enum EquipementFilter {
|
||||
/// Don't filter anything
|
||||
All,
|
||||
/// Filter all outliers
|
||||
Outiliers,
|
||||
/// Filter in all the named
|
||||
Named,
|
||||
}
|
||||
|
||||
// /// D
|
||||
// struct Gen<T>
|
||||
// where
|
||||
// T: Send,
|
||||
// {
|
||||
// /// E
|
||||
// elem: Vec<T>,
|
||||
// }
|
||||
|
||||
// impl<T: Send> ParallelIterator for Gen<T> {
|
||||
// type Item = T;
|
||||
|
||||
// fn drive_unindexed<C>(self, consumer: C) -> C::Result
|
||||
// where
|
||||
// C: rayon::iter::plumbing::UnindexedConsumer<Self::Item>,
|
||||
// {
|
||||
// let _ = consumer;
|
||||
// todo!()
|
||||
// }
|
||||
// }
|
||||
// /// Default full generation strategy
|
||||
// pub fn default_generation() -> impl ParallelIterator {
|
||||
// Gen::<u8> { elem: Vec::new() }
|
||||
// }
|
||||
/// Default full generation strategy
|
||||
pub fn default_generation<T: Copy>(a: Vec<T>, b: Vec<T>) -> Vec<(T, T)> {
|
||||
a.iter()
|
||||
.flat_map(|e| {
|
||||
b.iter()
|
||||
.map(|f| ((e.clone()), (f.clone())))
|
||||
.collect::<Vec<(T, T)>>()
|
||||
})
|
||||
// .collect::<Vec<Vec<(T, T)>>>()
|
||||
// .flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_creator() {
|
||||
let t = default_generation(vec![1, 2, 3], vec![5, 6, 7]);
|
||||
println!("{:?}", t);
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,36 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
/// The inner statistics of the equipement, used across all parts and final weapon
|
||||
#[derive(Default)]
|
||||
pub struct InnerStats {}
|
||||
// #[derive(Default)]
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
pub struct InnerStats {
|
||||
rarity: u8,
|
||||
cost: u8,
|
||||
difficulty: u8,
|
||||
tier: u8,
|
||||
damage: u8,
|
||||
p_damage: u8,
|
||||
precision: u8,
|
||||
rmax: u8,
|
||||
armor_break: u8,
|
||||
armor_pierce: u8,
|
||||
antimaterial: u8,
|
||||
damage_type: DamageMod,
|
||||
protection: u8,
|
||||
integrity: u8,
|
||||
two_handed: u8,
|
||||
one_handed: u8,
|
||||
dodge: u8,
|
||||
parry: u8,
|
||||
speed: u8,
|
||||
stealth: u8,
|
||||
category: WeaponCategory,
|
||||
special: Vec<String>,
|
||||
action_cost: u8,
|
||||
reload_cost: u8,
|
||||
range: u8,
|
||||
agility_bonus: u8,
|
||||
}
|
||||
|
||||
/// The final equipement, obtained by combining all parts
|
||||
pub struct Equipement {
|
||||
|
|
@ -52,21 +80,87 @@ pub enum NatureTarget {
|
|||
Armor,
|
||||
}
|
||||
|
||||
/// Weapon damage types
|
||||
/// Enum of all different physical weapon damage types
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
pub enum SingleDamageType {
|
||||
pub enum PhysicalDamageType {
|
||||
Blunt,
|
||||
Slash,
|
||||
Pierce,
|
||||
}
|
||||
|
||||
/// Weapon damage, signifying wether the damage is pure or [secondary] or [[tertiary]]
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
pub enum DamageMod {
|
||||
Primary(SingleDamageType),
|
||||
Secondary(SingleDamageType),
|
||||
Tertiary(SingleDamageType),
|
||||
impl From<&str> for PhysicalDamageType {
|
||||
fn from(value: &str) -> Self {
|
||||
let _ = value;
|
||||
// Matchcase for all damage types
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Damage values, meant to be serialised to tex and deserialized directly from the table
|
||||
/// Weapon damage, combining the base weapon damage type and it's level
|
||||
///
|
||||
/// Signifying wether the damage is pure or [secondary] or [[tertiary]]
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
pub enum DamageMod {
|
||||
Primary(PhysicalDamageType),
|
||||
Secondary(PhysicalDamageType),
|
||||
Tertiary(PhysicalDamageType),
|
||||
}
|
||||
|
||||
impl From<&str> for DamageMod {
|
||||
fn from(value: &str) -> Self {
|
||||
let _ = value;
|
||||
// Detect [] and recurse from
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Combined damage type, as a vector of all damage types
|
||||
///
|
||||
/// Meant to be serialised to tex and deserialized directly from the table
|
||||
pub struct DamageType(Vec<DamageMod>);
|
||||
|
||||
impl From<&str> for DamageType {
|
||||
fn from(value: &str) -> Self {
|
||||
let _ = value;
|
||||
// Split by , then recurse from and collect
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// List all weapon categories
|
||||
#[allow(clippy::missing_docs_in_private_items)]
|
||||
pub enum WeaponCategory {
|
||||
Exotic,
|
||||
Dagger,
|
||||
Claws,
|
||||
Blade,
|
||||
Haroth,
|
||||
Axe,
|
||||
Kahml,
|
||||
Hammer,
|
||||
Rhodarak,
|
||||
Staff,
|
||||
Lance,
|
||||
Landscapper,
|
||||
Bow,
|
||||
Crossbow,
|
||||
Cannon,
|
||||
}
|
||||
|
||||
impl From<&str> for WeaponCategory {
|
||||
fn from(value: &str) -> Self {
|
||||
let _ = value;
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
// use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_data_serialisation() {}
|
||||
|
||||
#[test]
|
||||
fn test_data_deserialisation() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Workflow
|
||||
A B C
|
||||
Database -> <Structs> -> <Weapons> -> Balancing data
|
||||
-> Exported data
|
||||
|
||||
# Description
|
||||
- A : Use structs defines in weaponry_structs
|
||||
: impl From<ForeignType> for all weapon parts
|
||||
- B : Every part can be converted to a weapon(ish)
|
||||
: Use the correct solver to add all parts
|
||||
- C1 : Use the traits to generate the tex data
|
||||
|
||||
|
||||
# Strategy
|
||||
Since the structs will become more than just weapons but will become craft afterwards, polymorphism is the key
|
||||
|
||||
The creation algorithm will pick a Strategy depending on the user's choice and build a final weapon depending on it
|
||||
The creation will implement an iterator to go with itertools / rayon ?
|
||||
Loading…
Reference in New Issue