Tests(Multiple) - Updates multiple test units
This commit is contained in:
parent
d5ff22d026
commit
ee24bdd0af
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
reorder_imports = true
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
//!
|
||||
|
|
|
|||
42
src/craft.rs
42
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
src/io.rs
22
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<Option<Vec<SolverResult>>> {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ pub fn next_action_picker_1<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
|
|||
// ACTIONS.groundwork for the --pls
|
||||
if craft.args.desperate {
|
||||
available_actions.append(&mut action_vec![ACTIONS.groundwork]);
|
||||
available_actions.append(&mut action_vec![ACTIONS.masters_mend]);
|
||||
}
|
||||
|
||||
// For long first run
|
||||
|
|
@ -191,6 +192,9 @@ pub fn next_action_phase_2<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
|
|||
available_actions.push(&ACTIONS.byregot_blessing);
|
||||
}
|
||||
}
|
||||
// if craft.durability + 30 < craft.recipe.durability as i32{
|
||||
// available_actions.push(&ACTIONS.masters_mend);
|
||||
// }
|
||||
let mut final_actions: Vec<Option<&Action>> = Vec::new();
|
||||
|
||||
for action in available_actions {
|
||||
|
|
|
|||
Reference in New Issue