diff --git a/README.md b/README.md
index fb2e1c4..0a64ce8 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Originaly written by [RikaKagurasaka](https://github.com/RikaKagurasaka/xiv_craf
it now is widely improved and provides python bindings for a GUI (or anything else really)
-
+
### Basic RUST CLI Usage
Everything is done through the regular cargo interface
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 0000000..4e727a0
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1 @@
+reorder_imports = true
\ No newline at end of file
diff --git a/src/action.rs b/src/action.rs
index 9ff889f..fe4d716 100644
--- a/src/action.rs
+++ b/src/action.rs
@@ -145,9 +145,10 @@ impl Action {
}
/// Get the durability cost this action would have if used at this stage of the craft
/// This method accounts for the effects of **master mend** and **waste not**.
- pub fn get_durability_cost(&self, _craft: &Craft) -> u32 {
+ /// Note that not using i32 for durability from scratch is a desing choice
+ pub fn get_durability_cost(&self, _craft: &Craft) -> i32 {
if self == &ACTIONS.masters_mend {
- return 30;
+ return -30;
}
if self.dur == 0 || self.progress == 0 && self.quality == 0 {
return 0;
@@ -159,7 +160,7 @@ impl Action {
if dur < 5 {
dur = 5;
}
- dur
+ dur as i32
}
/// Get the progress effect this action would have if used at this stage of the craft
/// This method accounts for the effects of **groundwork** under 20 durability,
@@ -419,6 +420,7 @@ impl Default for ActionList {
.build(),
masters_mend: ActionBuilder::new("Master's Mend").cp(88).build(),
+ //masters_mend: ActionBuilder::new("Master's Mend").dur(-30).cp(88).build(),
waste_not: ActionBuilder::new("Waste Not")
.cp(56)
.buff(Some((Buff::WasteNot, 4)))
@@ -514,7 +516,7 @@ mod test {
assert_eq!(&ACTIONS.standard_touch.get_cp_cost(&craft), &18);
assert_eq!(&ACTIONS.advanced_touch.get_cp_cost(&craft), &18);
- assert_eq!(&ACTIONS.masters_mend.get_durability_cost(&craft), &30);
+ assert_eq!(&ACTIONS.masters_mend.get_durability_cost(&craft), &-30);
assert_eq!(&ACTIONS.byregot_blessing.get_quality(&craft), &420);
assert_eq!(&ACTIONS.byregot_blessing.can_use(&craft), &true);
diff --git a/src/bin/xiv_csolver.rs b/src/bin/xiv_csolver.rs
index c94c690..9549faf 100644
--- a/src/bin/xiv_csolver.rs
+++ b/src/bin/xiv_csolver.rs
@@ -30,7 +30,7 @@
//!
//! It is really recommended to set up a venv to handle the python development
//!
-//! All bindings and the explanation of how to use them can be found in the [`io`](crate::io) module.
+//! All bindings and the explanation of how to use them can be found in the [`io`](xiv_csolver_lib::io) module.
//!
//! ### Features
//!
diff --git a/src/craft.rs b/src/craft.rs
index 2a43a4d..777e696 100644
--- a/src/craft.rs
+++ b/src/craft.rs
@@ -215,10 +215,48 @@ impl<'a> Craft<'a> {
#[cfg(test)]
mod test {
- // use pretty_assertions::assert_eq;
+ use pretty_assertions::assert_eq;
// Struct Test
#[test]
pub fn struct_tests() {
- let _craft = crate::craft::Craft::default();
+ let craft = crate::craft::Craft::default().clone();
+ assert_eq!(craft.get_base_progression(), 22);
+ assert_eq!(craft.get_base_quality(), 55);
+
+ format!("{}", craft);
+ format!("{:?}", craft);
+ }
+
+ #[test]
+ pub fn test_craft() {
+ let mut craft = crate::craft::Craft::default();
+ craft.cp = 1000;
+ format!("{:?}", craft);
+ let mut craft2 = craft.run_action(&crate::action::ACTIONS.veneration).clone();
+
+ craft.run_action(&crate::action::ACTIONS.masters_mend);
+ craft.run_action(&crate::action::ACTIONS.masters_mend);
+ craft.run_action(&crate::action::ACTIONS.manipulation);
+ craft.run_action(&crate::action::ACTIONS.basic_touch);
+ craft.run_action(&crate::action::ACTIONS.basic_synthesis);
+ assert_eq!(craft.durability, 190);
+ craft.run_action(&crate::action::ACTIONS.masters_mend);
+ assert_eq!(craft.durability, 200);
+ craft.run_action(&crate::action::ACTIONS.masters_mend);
+ for _ in 0..10 {
+ craft.run_action(&crate::action::ACTIONS.basic_touch);
+ }
+
+ for _ in 0..3 {
+ craft.run_action(&crate::action::ACTIONS.masters_mend);
+ craft.run_action(&crate::action::ACTIONS.groundwork);
+ }
+ assert_eq!(craft.success, crate::craft::Success::Success);
+
+ for _ in 0..20 {
+ craft2.run_action(&crate::action::ACTIONS.preparatory_touch);
+ }
+ assert_eq!(craft2.durability, 0);
+ assert_eq!(craft2.success, crate::craft::Success::Failure);
}
}
diff --git a/src/io.rs b/src/io.rs
index 4c6e038..c9bd331 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -235,7 +235,26 @@ fn xiv_csolver_lib(_py: Python, m: &PyModule) -> PyResult<()> {
Ok(())
}
-///
+/// A test result, useful for debugging, all values are set to zero as per the
+/// [`default`](crate::io::SolverResult::default)
+/// ```
+/// # use xiv_csolver_lib::io::SolverResult;
+/// SolverResult{
+/// steps: 0,
+/// progression: 0,
+/// quality: 0,
+/// durability: 0,
+/// total_progression: 0,
+/// total_quality: 0,
+/// total_durability: 0,
+/// actions: vec!["Act1".to_string(), "Act2".to_string()],
+/// step1_solutions: 0,
+/// step2_solutions: 0,
+/// found_100_percent: false,
+/// cp: 0,
+/// total_cp: 0,
+/// };
+/// ```
#[cfg(not(feature = "no_python"))]
#[pyfunction]
pub fn test_result() -> SolverResult {
@@ -273,6 +292,7 @@ use crate::{solve_craft, Recipe, Stats};
/// crafting_feeder = FeedingClass()
/// rich.inspect(xiv_csolver_lib.solve_from_python(crafting_feeder))
/// ```
+
#[cfg(not(feature = "no_python"))]
#[pyfunction]
pub fn solve_from_python(py: Python<'_>, values: &PyAny) -> PyResult