mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 01:54:22 +00:00
Refactor associated_cards
so that only codes are kept
This commit is contained in:
parent
1e7230994a
commit
0f25aaebc4
1 changed files with 12 additions and 4 deletions
|
@ -1,11 +1,11 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// A single Legends of Runeterra card as represented in the data files from [Data Dragon](https://developer.riotgames.com/docs/lor).
|
/// A single Legends of Runeterra card as represented in the data files from [Data Dragon](https://developer.riotgames.com/docs/lor).
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
|
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
|
||||||
#[serde(rename_all="camelCase")]
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct Card {
|
pub struct Card {
|
||||||
/// Localized names of the cards associated with this one.
|
/// Codes of other cards associated with this one.
|
||||||
/// For some reason, might not match what is contained in `associated_card_refs`.
|
/// To access
|
||||||
pub associated_cards: Vec<String>,
|
|
||||||
/// `card_code`s of the cards associated with this one.
|
|
||||||
pub associated_card_refs: Vec<String>,
|
pub associated_card_refs: Vec<String>,
|
||||||
|
|
||||||
/// Art assets of this card.
|
/// Art assets of this card.
|
||||||
|
@ -75,6 +75,14 @@ pub struct Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Card {
|
||||||
|
/// Get references to the cards associated with this one, given an hashmap of all cards.
|
||||||
|
pub fn associated_cards<'c, 'hm: 'c>(&'c self, hashmap: &'hm HashMap<String, Card>) -> impl Iterator<Item=Option<&'hm Card>> + 'c {
|
||||||
|
self.associated_card_refs.iter().map(|r| hashmap.get(r))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// An art asset associated with a given card.
|
/// An art asset associated with a given card.
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
|
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
|
||||||
#[serde(rename_all="camelCase")]
|
#[serde(rename_all="camelCase")]
|
||||||
|
|
Loading…
Reference in a new issue