1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2024-10-16 09:37:27 +00:00

Refactor Telegram card displaying

This commit is contained in:
Steffo 2023-10-23 01:31:11 +02:00
parent 115af23e4b
commit bbadb3b5ae
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -286,19 +286,19 @@ pub fn display_deck(index: &CardIndex, deck: &Deck, code: &str, name: &Option<&s
})
.join("\n");
let mut tags: Vec<&'static str> = vec![];
let mut tags: Vec<String> = vec![];
let regions = if let Some(regions) = deck.standard(index) {
tags.push("#Standard_4_5");
tags.push("#Standard_4_5".to_string());
regions
} else if let Some(regions) = deck.eternal(index) {
tags.push("#Eternal");
tags.push("#Eternal".to_string());
regions
} else if let Some(regions) = deck.unlimited_champions(index) {
tags.push("#UnlimitedChampions");
tags.push("#UnlimitedChampions".to_string());
regions
} else if let Some(regions) = deck.singleton(index) {
tags.push("#Singleton");
tags.push("#Singleton".to_string());
regions
} else {
HashSet::new()
@ -306,18 +306,8 @@ pub fn display_deck(index: &CardIndex, deck: &Deck, code: &str, name: &Option<&s
for region in regions {
tags.push(match region {
CardRegion::Noxus => "#Noxus",
CardRegion::Demacia => "#Demacia",
CardRegion::Freljord => "#Freljord",
CardRegion::ShadowIsles => "#ShadowIsles",
CardRegion::Targon => "#Targon",
CardRegion::Ionia => "#Ionia",
CardRegion::Bilgewater => "#Bilgewater",
CardRegion::Shurima => "#Shurima",
CardRegion::PiltoverZaun => "#PiltoverZaun",
CardRegion::BandleCity => "#BandleCity",
CardRegion::Runeterra => "#Runeterra",
CardRegion::Unsupported => "<i>Unknown</i>",
CardRegion::Unsupported => "<i>Unknown</i>".to_string(),
_ => format!("#{}", region.to_tag().map_or_else(|| "<i>Unknown</i>", |r| r)),
})
}