diff --git a/src/filter.rs b/src/filter.rs index f274884..618b8d7 100644 --- a/src/filter.rs +++ b/src/filter.rs @@ -61,6 +61,7 @@ pub fn build_filter(query: RawCardFilter) -> Result { Box::new(move |card| card.def.is_none() && card.link_rating.is_none() && card.card_type.contains("monster")) } RawCardFilter(Field::Level, op, Value::Numerical(n)) => Box::new(move |card| op.filter_number(card.level, n)), + RawCardFilter(Field::LinkRating, op, Value::Numerical(n)) => Box::new(move |card| op.filter_number(card.link_rating, n)), RawCardFilter(Field::Type, Operator::Equal, Value::String(s)) => Box::new(move |card| card.r#type == s), RawCardFilter(Field::Type, Operator::NotEqual, Value::String(s)) => Box::new(move |card| card.r#type != s), RawCardFilter(Field::Attribute, Operator::Equal, Value::String(s)) => Box::new(move |card| card.attribute.contains(&s)), diff --git a/src/parser.rs b/src/parser.rs index 2558b0c..aca4cc6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -65,11 +65,12 @@ pub enum Field { Atk = 1, Def = 2, Level = 3, - Type = 4, - Attribute = 5, - Class = 6, - Name = 7, - Text = 8, + LinkRating = 4, + Type = 5, + Attribute = 6, + Class = 7, + Name = 8, + Text = 9, } impl Display for Field { @@ -83,6 +84,7 @@ impl Display for Field { Self::Level => "level/rank", Self::Atk => "ATK", Self::Def => "DEF", + Self::LinkRating => "link rating", }) } } @@ -98,6 +100,7 @@ impl FromStr for Field { "attribute" | "attr" | "a" => Self::Attribute, "c" | "class" => Self::Class, "o" | "eff" | "text" | "effect" | "e" => Self::Text, + "lr" | "linkrating" => Self::LinkRating, _ => Err(s.to_string())?, }) }