Add filter by link rating
This commit is contained in:
parent
e72c760f7b
commit
94d73b2a36
@ -61,6 +61,7 @@ pub fn build_filter(query: RawCardFilter) -> Result<CardFilter, String> {
|
||||
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)),
|
||||
|
@ -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())?,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user