Addentum(Doc) - Adds more documentation
This commit is contained in:
parent
0c5ed39573
commit
a5c196b764
1
Todo.md
1
Todo.md
|
|
@ -15,6 +15,7 @@
|
|||
🟩 (CLI) Rework the parameters and return structs to only have one ref each
|
||||
### Features
|
||||
🟩 (GUI) Refactor code
|
||||
🟩 (GUI) Restore GUI state
|
||||
|
||||
# Roadmap
|
||||
## v1.0.0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use lazy_static::lazy_static;
|
|||
use std::fmt::Debug;
|
||||
|
||||
/// Hold an action for the solver to try using
|
||||
///
|
||||
///
|
||||
/// It will be used heavily to try/discard actions durin craft
|
||||
pub struct Action {
|
||||
/// The action name, in a human readable format, it will be used to generate a short_name
|
||||
|
|
@ -30,7 +30,7 @@ pub struct Action {
|
|||
}
|
||||
|
||||
/// Builds an action based on an action
|
||||
///
|
||||
///
|
||||
/// Made to initialize lazy_static and nothing more
|
||||
pub struct ActionBuilder {
|
||||
action: Action,
|
||||
|
|
@ -39,7 +39,7 @@ pub struct ActionBuilder {
|
|||
impl ActionBuilder {
|
||||
/// Base creator, takes a name and initialize an empty action with the short_name
|
||||
/// and name setup and default values for all other fields
|
||||
///
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use xiv_csolver_lib::action::ActionBuilder;
|
||||
|
|
@ -99,8 +99,8 @@ impl ActionBuilder {
|
|||
self
|
||||
}
|
||||
/// Makes an action add a buff for certain number of actions
|
||||
/// The buffs available are defined in [specs.rs](xiv_csolver::specs::Buff)
|
||||
///
|
||||
/// The buffs available are defined in [specs.rs](crate::specs::Buff)
|
||||
///
|
||||
/// ``
|
||||
/// (self.recipe.progress as f32 - self.progression as f32) / self.get_base_progression() as f32;
|
||||
/// ``
|
||||
|
|
@ -126,8 +126,8 @@ impl PartialEq for Action {
|
|||
}
|
||||
}
|
||||
|
||||
/// A craft action, after compilation (with lazy_static)
|
||||
// no other actions should be created
|
||||
/// A craft action, after compilation (with lazy_static)
|
||||
// no other actions should be created
|
||||
impl Action {
|
||||
/// Get the printable name of the action
|
||||
pub fn get_name(&self) -> String {
|
||||
|
|
@ -184,7 +184,7 @@ impl Action {
|
|||
(prog * mult).floor() as u32
|
||||
}
|
||||
|
||||
/// Get the quality effect this action would have if used at this stage of the craft.
|
||||
/// Get the quality effect this action would have if used at this stage of the craft.
|
||||
/// This method account for the **inner quiet** stacking effect, **innovation** and **great strides**
|
||||
pub fn get_quality(&self, _craft: &Craft) -> u32 {
|
||||
let mut qual = self.quality as f64;
|
||||
|
|
@ -210,12 +210,12 @@ impl Action {
|
|||
}
|
||||
/// Returns a bool representing if this action **can** be used, note that this does only account
|
||||
/// for the game limitations and not viability limitation
|
||||
///
|
||||
///
|
||||
/// # Improvements
|
||||
/// This function could easily prune useless actions by considering them not available.
|
||||
/// Doing so could stop early refresh of buffs and spam of observe and such.
|
||||
/// However some of such "optimisations" could just plain hurt the craft by forbidding a *seemingly*
|
||||
/// useless action. The "bruteforce" method being easily computatble on a modern computer, such
|
||||
/// useless action. The "bruteforce" method being easily computatble on a modern computer, such
|
||||
/// optimisations arent warrented and left to aother time.
|
||||
pub fn can_use(&self, _craft: &Craft) -> bool {
|
||||
if self.get_cp_cost(_craft) > _craft.cp as u32 {
|
||||
|
|
@ -318,27 +318,25 @@ pub struct ActionList {
|
|||
/// Success Rate: 100%
|
||||
/// Available only when Inner Quiet stack size is 10.
|
||||
pub trained_finesse: Action,
|
||||
/// Restores item durability by 30.
|
||||
/// Restores item durability by 30.
|
||||
pub masters_mend: Action,
|
||||
|
||||
// Restores item durability by 60.
|
||||
// Restores item durability by 60.
|
||||
// pub masters_mend_2: Action,
|
||||
|
||||
/// Reduces loss of durability by 50% for the next four steps.
|
||||
/// Reduces loss of durability by 50% for the next four steps.
|
||||
pub waste_not: Action,
|
||||
/// Reduces loss of durability by 50% for the next eight steps.
|
||||
/// Reduces loss of durability by 50% for the next eight steps.
|
||||
pub waste_not_ii: Action,
|
||||
/// Restores 5 points of durability after each step for the next eight steps.
|
||||
pub manipulation: Action,
|
||||
/// Increases efficiency of Synthesis actions by 50% for the next four steps.
|
||||
/// Increases efficiency of Synthesis actions by 50% for the next four steps.
|
||||
pub veneration: Action,
|
||||
/// Increases the efficiency of next Touch action by 100%.
|
||||
/// Effect active for three steps.
|
||||
/// Effect active for three steps.
|
||||
pub great_strides: Action,
|
||||
/// Increases efficiency of Touch actions by 50% for the next four steps.
|
||||
pub innovation: Action,
|
||||
|
||||
// Do nothing for one step.
|
||||
// Do nothing for one step.
|
||||
//pub observe: Action,
|
||||
// Increases progress.
|
||||
// Efficiency: 200%
|
||||
|
|
@ -453,6 +451,6 @@ impl Default for ActionList {
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
/// Initialize a static pseudo &Craft: ACTIONS
|
||||
/// Initialize a static pseudo &Craft: ACTIONS
|
||||
pub static ref ACTIONS: ActionList = ActionList::default();
|
||||
}
|
||||
|
|
|
|||
14
src/craft.rs
14
src/craft.rs
|
|
@ -1,16 +1,16 @@
|
|||
//! Module containing everything to create a craft and all methods to get the current state of the craft
|
||||
//!
|
||||
//!
|
||||
//! A craft represent the state of the recipe with a vector of actions applied to it.
|
||||
//! Applying actions to it will make the craft progress, while branching and trying other actions
|
||||
//! Applying actions to it will make the craft progress, while branching and trying other actions
|
||||
//! will be done by cloning
|
||||
//!
|
||||
//!
|
||||
|
||||
use crate::action::Action;
|
||||
use crate::specs::{Buff, BuffState, Recipe, Stats, Success};
|
||||
use crate::Parameters;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
|
||||
/// The craft structure, note that there is no standard way of backtracking
|
||||
/// The craft structure, note that there is no standard way of backtracking
|
||||
/// and a traditional branching method is applied when solving.
|
||||
#[derive(Clone)]
|
||||
pub struct Craft<'a> {
|
||||
|
|
@ -32,7 +32,7 @@ pub struct Craft<'a> {
|
|||
pub cp: i32,
|
||||
/// Wether the craft has succeded, is pending sucess, or failed
|
||||
pub success: Success,
|
||||
/// The vector of action already applied, structs are used for the vector since
|
||||
/// The vector of action already applied, structs are used for the vector since
|
||||
/// static references are used and therefore take no additional memory at runtime
|
||||
pub actions: Vec<&'a Action>,
|
||||
/// The parameters used for the craft
|
||||
|
|
@ -60,7 +60,7 @@ impl<'a> Craft<'a> {
|
|||
}
|
||||
|
||||
/// How much progression will be done by an action with 100 efficiency and no buffs
|
||||
/// This function is mainly used to know wether or not the craft will finish in
|
||||
/// This function is mainly used to know wether or not the craft will finish in
|
||||
/// 1, 1.2 or 2.0 actions.
|
||||
pub fn get_base_progression(&self) -> u32 {
|
||||
let base_value = (self.stats.craftsmanship as f64 / 10.0)
|
||||
|
|
@ -69,7 +69,7 @@ impl<'a> Craft<'a> {
|
|||
(base_value * (self.recipe.progress_modifier as f64 / 100.0) as f64).floor() as u32
|
||||
}
|
||||
/// How much quality will the crafter generate with one action with 100 efficiency and no buffs
|
||||
/// This function is usually called by [`run_action`](crate::craft::Craft::run_action)
|
||||
/// This function is usually called by [`run_action`](crate::craft::Craft::run_action)
|
||||
/// wich will then apply all needed buff and progress the craft
|
||||
pub fn get_base_quality(&self) -> u32 {
|
||||
let base_value = (self.stats.control as f64 / 10.0)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! The main IO module
|
||||
//! For now it contains the python bindings, the Args bindings (for clap) and the struct
|
||||
//! For now it contains the python bindings, the Args bindings (for clap) and the struct
|
||||
//! needed to hold all parameters needed at runtime
|
||||
//!
|
||||
//!
|
||||
//! Moving the bindings and making them non mandatory is a WIP
|
||||
|
||||
use crate::Craft;
|
||||
|
|
@ -169,7 +169,7 @@ impl SolverResult {
|
|||
|
||||
#[pymethods]
|
||||
impl SolverResult {
|
||||
/// Default method to create an empty solution, only used for debug purposes
|
||||
/// Default method to create an empty solution, only used for debug purposes
|
||||
/// to test wether the import worked
|
||||
/// ```py
|
||||
/// import xiv_csolver_lib
|
||||
|
|
@ -250,7 +250,7 @@ use crate::{solve_craft, Recipe, Stats};
|
|||
/// The values are all obtained by a `&PyAny`, wich must guaranty that several attributes are
|
||||
/// accesible by `__getattr__`
|
||||
///
|
||||
/// ```py
|
||||
/// ```python
|
||||
/// import xiv_craft_solver, rich
|
||||
///
|
||||
/// class FeedingClass:
|
||||
|
|
|
|||
59
src/specs.rs
59
src/specs.rs
|
|
@ -4,55 +4,103 @@ use std::fmt::Debug;
|
|||
use strum_macros::EnumIter;
|
||||
|
||||
/// The recipe to craft
|
||||
/// On some websites the fields are instead called
|
||||
/// [Progress, quality, durability, progress difficulty, quality difficulty, extra progress difficulty, extra quality difficulty]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Recipe {
|
||||
/// The craft durability (also called solidity)
|
||||
/// The recipe durability (also called solidity) (35, 40, 70 or 80 usually)
|
||||
pub durability: u32,
|
||||
/// The total recipe progress needed
|
||||
pub progress: u32,
|
||||
/// The total recipe quality
|
||||
pub quality: u32,
|
||||
/// How much the progress is hard to set,
|
||||
/// it's an (hidden) extra progress multiplier,
|
||||
/// inflicting a -10% to -30% to starred recipes
|
||||
/// Also called `progress_difficulty`
|
||||
pub progress_divider: u32,
|
||||
/// The same (hidden) difficulty multiplier, for quality
|
||||
/// Also called `progress_difficulty`
|
||||
pub quality_divider: u32,
|
||||
/// Modifies how much the base stats are affecting the craft progress
|
||||
/// Also called `progress_extra_difficulty`
|
||||
pub progress_modifier: u32,
|
||||
/// Modifies how much the base stats are affectif the craft quality
|
||||
/// Also called `quality_extra_difficulty`
|
||||
pub quality_modifier: u32,
|
||||
}
|
||||
|
||||
/// The craftsman stats
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Stats {
|
||||
/// The craftsmanship, influences the progress
|
||||
pub craftsmanship: u32,
|
||||
/// The control, inluences the quality
|
||||
pub control: u32,
|
||||
/// The amount of cp, ressource used for actions
|
||||
pub max_cp: u32,
|
||||
}
|
||||
|
||||
/// The buffs available for the crafter
|
||||
#[derive(Debug, Clone, Copy, PartialEq, EnumIter)]
|
||||
pub enum Buff {
|
||||
/// Gain a stack of Inner Quiet with every increase in quality, up to a maximum of 10.
|
||||
/// Grants a 10% bonus to the efficiency of Touch actions for each stack.
|
||||
InnerQuiet,
|
||||
/// Reduces loss of durability by 50%.
|
||||
WasteNot,
|
||||
/// Increases the efficiency of next Touch action by 100%.
|
||||
GreatStrides,
|
||||
/// Increases efficiency of Touch actions by 50%.
|
||||
Innovation,
|
||||
/// Increases efficiency of Synthesis actions by 50%.
|
||||
Veneration,
|
||||
/// Restores 5 points of durability after each step.
|
||||
Manipulation,
|
||||
/// Increases progress.
|
||||
/// Efficiency: 300%
|
||||
/// Success Rate: 100%
|
||||
/// Additional Effect: Efficiency of your next Synthesis action is increased by 100%
|
||||
/// Available only on the first step.
|
||||
/// Additional effect is active for five steps.
|
||||
MuscleMemory,
|
||||
// v Hidden v
|
||||
/// (Hidden) Combo with Standart touch costs 18 cp.
|
||||
BasicTouch,
|
||||
/// (Hidden) Combo with Advanced touch costs 18 cp.
|
||||
StandardTouch,
|
||||
/// (Hidden) Do nothing for one step.
|
||||
Observe,
|
||||
}
|
||||
|
||||
/// Keeps track of all the durations remaining on all buffs
|
||||
/// Also called buff tracker in the docs
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct BuffState {
|
||||
/// Caps at 10 for a 100% extra efficiency in quality increase
|
||||
pub inner_quiet: u8,
|
||||
/// Lasts for four steps if Waste not was used, height if Waste Not II was.
|
||||
pub waste_not: u8,
|
||||
/// Effect active for three steps, dissipates after a quality action is used.
|
||||
pub great_strides: u8,
|
||||
/// Lasts four steps
|
||||
pub innovation: u8,
|
||||
/// Lasts four steps.
|
||||
pub veneration: u8,
|
||||
/// Lasts height steps
|
||||
pub manipulation: u8,
|
||||
/// Lasts five steps, dissipate after a progression action is used.
|
||||
pub muscle_memory: u8,
|
||||
/// Lasts one step
|
||||
pub basic_touch: u8,
|
||||
/// Lasts one step
|
||||
pub standard_touch: u8,
|
||||
/// Lasts one step
|
||||
pub observe: u8,
|
||||
}
|
||||
|
||||
impl BuffState {
|
||||
/// Default state of buffs (all at zero) as per the beggining of craft
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
inner_quiet: 0,
|
||||
|
|
@ -68,6 +116,7 @@ impl BuffState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Remove the given buff from the buff tracker
|
||||
pub fn remove(&mut self, buff: Buff) {
|
||||
match buff {
|
||||
Buff::InnerQuiet => self.inner_quiet = 0,
|
||||
|
|
@ -83,6 +132,8 @@ impl BuffState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Apply the given buff to the buff tracker for `value` steps
|
||||
/// In the case of Inner Quiet, it inseads adds one to the stack counter
|
||||
pub fn apply(&mut self, buff: Buff, value: u8) {
|
||||
match buff {
|
||||
Buff::InnerQuiet => {
|
||||
|
|
@ -104,6 +155,7 @@ impl BuffState {
|
|||
}
|
||||
}
|
||||
|
||||
/// Tick downs the remaining duration of all buffs, if up
|
||||
pub fn tick(&mut self) {
|
||||
if self.waste_not > 0 {
|
||||
self.waste_not -= 1;
|
||||
|
|
@ -132,9 +184,14 @@ impl BuffState {
|
|||
}
|
||||
}
|
||||
|
||||
/// State the craft is in, used to keep track of wether the craft
|
||||
/// is to be worked on, added to the success vector or discarded
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Success {
|
||||
/// Pending success and therefor still ongoing
|
||||
Pending,
|
||||
/// Finised, not ongoing and finished without breaking (Doens't take quality into account)
|
||||
Success,
|
||||
/// Finised because of lack of remaining durability
|
||||
Failure,
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue