Skip to content

Commit

Permalink
chore: add sort by is_melee, is_ranged, is_spellcaster
Browse files Browse the repository at this point in the history
  • Loading branch information
RakuJa committed Dec 9, 2024
1 parent 2fdafc1 commit ab95c49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/db/bestiary_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ pub async fn get_paginated_creatures(
.essential
.family
.cmp(&b.core_data.essential.family),
CreatureSortEnum::Alignment => a
.core_data
.essential
.alignment
.cmp(&b.core_data.essential.alignment),
CreatureSortEnum::Melee => a
.core_data
.derived
.is_melee
.cmp(&b.core_data.derived.is_melee),
CreatureSortEnum::Ranged => a
.core_data
.derived
.is_ranged
.cmp(&b.core_data.derived.is_ranged),
CreatureSortEnum::SpellCaster => a
.core_data
.derived
.is_spell_caster
.cmp(&b.core_data.derived.is_spell_caster),
};
match pagination
.bestiary_sort_data
Expand Down
8 changes: 8 additions & 0 deletions src/models/bestiary_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ pub enum CreatureSortEnum {
Rarity,
#[serde(alias = "family", alias = "FAMILY")]
Family,
#[serde(alias = "alignment", alias = "ALIGNMENT")]
Alignment,
#[serde(alias = "melee", alias = "MELEE")]
Melee,
#[serde(alias = "ranged", alias = "RANGED")]
Ranged,
#[serde(alias = "SPELLCASTER", alias = "SPELLCASTER")]
SpellCaster,
}

#[derive(Serialize, Deserialize, IntoParams, ToSchema, Eq, PartialEq, Hash, Default)]
Expand Down

0 comments on commit ab95c49

Please sign in to comment.