Skip to content

Commit

Permalink
🐛 Fix Deserialize Artifact Config Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
luoshuijs committed Nov 7, 2023
1 parent 36b308e commit e8cef5e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/applications/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::anyhow;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

use mona::artifacts::effect_config::ArtifactEffectConfig;
use mona::artifacts::effect_config::{ArtifactConfigInterface, ArtifactEffectConfig};
use mona::artifacts::{Artifact, ArtifactList};
use mona::attribute::{AttributeUtils, ComplicatedAttributeGraph, SimpleAttributeGraph2};
use mona::buffs::Buff;
Expand Down Expand Up @@ -40,12 +40,18 @@ pub fn get_damage_analysis(calculator_config: PyCalculatorConfig) -> PyResult<Py
.collect::<Result<Vec<Artifact>, anyhow::Error>>()?;
let artifacts = artifacts.iter().collect::<Vec<&Artifact>>();

let artifact_config: ArtifactEffectConfig =
let artifact_config_interface: Option<ArtifactConfigInterface> =
if let Some(artifact_config) = calculator_config.artifact_config {
Python::with_gil(|py| {
depythonize(artifact_config.as_ref(py))
.map_err(|err| anyhow!("Failed to deserialize artifact config: {}", err))
})?
} else {
None
};
let artifact_config =
if let Some(artifact_config) = artifact_config_interface {
artifact_config.to_config()
} else {
ArtifactEffectConfig::default()
};
Expand Down Expand Up @@ -109,12 +115,18 @@ pub fn get_transformative_damage(
.collect::<Result<Vec<Artifact>, anyhow::Error>>()?;
let artifacts = artifacts.iter().collect::<Vec<&Artifact>>();

let artifact_config: ArtifactEffectConfig =
let artifact_config_interface: Option<ArtifactConfigInterface> =
if let Some(artifact_config) = calculator_config.artifact_config {
Python::with_gil(|py| {
depythonize(artifact_config.as_ref(py))
.map_err(|err| anyhow!("Failed to deserialize artifact config: {}", err))
})?
} else {
None
};
let artifact_config =
if let Some(artifact_config) = artifact_config_interface {
artifact_config.to_config()
} else {
ArtifactEffectConfig::default()
};
Expand Down

0 comments on commit e8cef5e

Please sign in to comment.