diff --git a/dar2oar_core/src/condition_parser/conditions.rs b/dar2oar_core/src/condition_parser/conditions.rs index d88cfe8..77602a0 100644 --- a/dar2oar_core/src/condition_parser/conditions.rs +++ b/dar2oar_core/src/condition_parser/conditions.rs @@ -11,7 +11,7 @@ use crate::conditions::{ IsWornHasKeyword, Level, Or, RandomCondition, }; use crate::dar_syntax::syntax::{self, Expression}; -use crate::values::{Cmp, DirectionValue, NumericValue}; +use crate::values::{Cmp, DirectionValue}; pub fn parse_conditions(input: syntax::Condition) -> Result { Ok(match input { @@ -50,7 +50,7 @@ fn parse_condition(condition: Expression<'_>) -> Result ConditionSet::CurrentGameTime(CurrentGameTime { negated, comparison: Cmp::Lt, - numeric_value: NumericValue::StaticValue(args[0].clone().try_into().unwrap()), + numeric_value: args.try_get(0, "NumericValue for CurrentGameTime")?.into(), ..Default::default() }), "CurrentWeather" => gen_cond!( @@ -75,7 +75,7 @@ fn parse_condition(condition: Expression<'_>) -> Result ConditionSet::Level(Level { negated, comparison: Cmp::Lt, - numeric_value: args.try_get(0, "NumericValue")?.into(), + numeric_value: args.try_get(0, "NumericValue for Level")?.into(), ..Default::default() }), "IsParentCell" => gen_cond!( diff --git a/dar2oar_core/src/values/type_value.rs b/dar2oar_core/src/values/type_value.rs index f25a0e5..eccefd1 100644 --- a/dar2oar_core/src/values/type_value.rs +++ b/dar2oar_core/src/values/type_value.rs @@ -90,11 +90,11 @@ impl TryFrom for WeaponType { fn try_from(value: NumericLiteral) -> Result { match value { NumericLiteral::Hex(num) => match num { - 1..=18 => Ok((num as i64).try_into().expect("unreachable")), + 1..=18 => Ok((num as i64).try_into()?), _ => Err("Got hex, Out of range 1..=18"), }, NumericLiteral::Decimal(num) => match num { - -1..=18 => Ok((num as i64).try_into().expect("unreachable")), + -1..=18 => Ok((num as i64).try_into()?), _ => Err("Got Decimal, Out of range -1..=18"), }, NumericLiteral::Float(num) => Ok(num.to_string().as_str().try_into()?),