Implementation(Bindings) - Implements base bindings
This commit is contained in:
parent
1c89864b70
commit
0eef1be6b9
28
python3.py
28
python3.py
|
|
@ -5,6 +5,28 @@ rich.inspect(xiv_craft_solver)
|
|||
rich.inspect(xiv_craft_solver.test_result)
|
||||
rich.inspect(xiv_craft_solver.test_result())
|
||||
rich.inspect(xiv_craft_solver.test_result())
|
||||
rich.inspect(xiv_craft_solver.solve_from_python)
|
||||
rich.inspect(xiv_craft_solver.solve_from_python(1))
|
||||
rich.inspect(xiv_craft_solver.solve_from_python("az"))
|
||||
|
||||
|
||||
class feedMeDaddy:
|
||||
durability = 70
|
||||
progress = 3900
|
||||
quality = 10920
|
||||
progress_divider = 130
|
||||
quality_divider = 115
|
||||
progress_modifier = 80
|
||||
quality_modifier = 70
|
||||
craftsmanship = 4041
|
||||
control = 3959
|
||||
max_cp = 602
|
||||
|
||||
# Config
|
||||
depth=10
|
||||
byregot_step=10
|
||||
desperate=False
|
||||
threads=8
|
||||
verbose=0
|
||||
|
||||
|
||||
el_daddy=feedMeDaddy()
|
||||
rich.inspect(xiv_craft_solver.solve_from_python(el_daddy))
|
||||
|
||||
|
|
|
|||
16
src/io.rs
16
src/io.rs
|
|
@ -187,31 +187,31 @@ pub fn test_result()-> SolverResult {
|
|||
|
||||
/// Create a stat struct stats with the base values
|
||||
#[cfg(not(feature="no_python"))]
|
||||
use crate::{Recipe,Stats};
|
||||
use crate::{Recipe,Stats,solve_craft};
|
||||
|
||||
#[cfg(not(feature="no_python"))]
|
||||
#[pyfunction]
|
||||
pub fn solve_from_python(values : &PyAny)->PyResult<()>{
|
||||
pub fn solve_from_python(values : &PyAny)->PyResult<Option<Vec<SolverResult>>>{
|
||||
// // Create Recipe
|
||||
let _recipe = Recipe{
|
||||
let recipe = Recipe{
|
||||
durability: values.getattr("durability")?.extract()?,
|
||||
progress: values.getattr("progress")?.extract()?,
|
||||
progress_divider: values.getattr("progress_divider")?.extract()?,
|
||||
progress_modifier: values.getattr("progress_modifier")?.extract()?,
|
||||
quality:values.getattr("values")?.extract()?,
|
||||
quality: values.getattr("quality")?.extract()?,
|
||||
quality_divider:values.getattr("quality_divider")?.extract()?,
|
||||
quality_modifier:values.getattr("quality_modifier")?.extract()?,
|
||||
};
|
||||
|
||||
// Create Stats
|
||||
let _stats = Stats{
|
||||
let stats = Stats{
|
||||
craftsmanship: values.getattr("craftsmanship")?.extract()?,
|
||||
control: values.getattr("control")?.extract()?,
|
||||
max_cp: values.getattr("max_cp")?.extract()?,
|
||||
};
|
||||
|
||||
// Create parameters
|
||||
let _param = Parameters{
|
||||
let param = Parameters{
|
||||
depth: values.getattr("depth")?.extract()?,
|
||||
byregot_step: values.getattr("byregot_step")?.extract()?,
|
||||
desperate: values.getattr("desperate")?.extract()?,
|
||||
|
|
@ -220,6 +220,6 @@ pub fn solve_from_python(values : &PyAny)->PyResult<()>{
|
|||
};
|
||||
|
||||
// println!("{:?} len: {:?} ",values,values.getattr("len()"));
|
||||
|
||||
Ok(())
|
||||
let res = solve_craft(recipe, stats, param);
|
||||
Ok(res)
|
||||
}
|
||||
Reference in New Issue