Skip to content

Commit

Permalink
fix: remove column typos, correctly filter by alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
RakuJa committed Dec 9, 2024
1 parent ab95c49 commit 84d8281
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
8 changes: 2 additions & 6 deletions src/db/data_providers/raw_query_builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::models::bestiary_structs::{BestiaryFilterQuery, CreatureTableFieldsFilter};
use crate::models::creature::creature_metadata::alignment_enum::AlignmentEnum;
use crate::models::creature::creature_metadata::creature_role::CreatureRoleEnum;
use crate::models::item::item_metadata::type_enum::ItemTypeEnum;
use crate::models::shop_structs::{ItemTableFieldsFilter, ShopFilterQuery};
Expand Down Expand Up @@ -261,10 +260,7 @@ fn prepare_creature_filter_statement(
),
prepare_case_insensitive_in_statement(
"alignment",
bestiary_filter_vectors
.alignment_filter
.iter()
.flat_map(AlignmentEnum::to_db_traits),
bestiary_filter_vectors.alignment_filter.iter(),
),
prepare_case_insensitive_in_statement("size", bestiary_filter_vectors.size_filter.iter()),
prepare_case_insensitive_in_statement(
Expand All @@ -276,7 +272,7 @@ fn prepare_creature_filter_statement(
bestiary_filter_vectors.type_filter.iter(),
),
prepare_in_statement_for_generic_type(
"is_spellcaster",
"is_spell_caster",
bestiary_filter_vectors.is_spellcaster_filter.iter(),
),
prepare_in_statement_for_generic_type(
Expand Down
39 changes: 0 additions & 39 deletions src/models/creature/creature_metadata/alignment_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,45 +94,6 @@ impl From<(&Vec<String>, bool)> for AlignmentEnum {
}
}

impl AlignmentEnum {
pub fn to_db_traits(&self) -> Vec<String> {
match self {
Self::Ce => {
vec![String::from("CHAOTIC"), String::from("EVIL")]
}
Self::Cn => {
vec![String::from("CHAOTIC")]
}
Self::Cg => {
vec![String::from("CHAOTIC"), String::from("GOOD")]
}
Self::Ne => {
vec![String::from("EVIL")]
}
Self::N | Self::No => {
vec![]
}
Self::Ng => {
vec![String::from("GOOD")]
}
Self::Le => {
vec![String::from("LAWFUL"), String::from("EVIL")]
}
Self::Ln => {
vec![String::from("LAWFUL")]
}
Self::Lg => {
vec![String::from("LAWFUL"), String::from("GOOD")]
}
Self::Any => ALIGNMENT_TRAITS
.to_vec()
.iter()
.map(ToString::to_string)
.collect(),
}
}
}

impl From<String> for AlignmentEnum {
fn from(value: String) -> Self {
Self::from_str(value.as_str()).unwrap_or_default()
Expand Down

0 comments on commit 84d8281

Please sign in to comment.