diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-11-28 22:07:08 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-11-28 22:07:08 +0100 |
commit | 40e6c6b25fc2c7da89be6fe8c55b13dc95e4f85a (patch) | |
tree | a6463e316ea1e062130bdcc83d8ae8aa4eec67a3 | |
parent | b9b890b24146fde7d3aa2a8fd1998b27caded462 (diff) | |
download | kondou-40e6c6b25fc2c7da89be6fe8c55b13dc95e4f85a.tar.gz kondou-40e6c6b25fc2c7da89be6fe8c55b13dc95e4f85a.tar.bz2 kondou-40e6c6b25fc2c7da89be6fe8c55b13dc95e4f85a.zip |
-rw-r--r-- | src/api/mod.rs | 22 | ||||
-rw-r--r-- | src/render.rs | 6 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index 0b823ae..b7a92d9 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -218,7 +218,27 @@ impl Api { /// /// Traits that are found in the cache are taken from there. pub fn get_legends(&mut self, ids: &[String]) -> Result<Vec<Legend>, ApiError> { - self.get_multiple_cached("legends", "legends/", ids) + // As of 2022-11-28, the API only knows about 6 legends, missing the latest ("Legendary + // Alliance"). Therefore, we fake the API response here. + let to_fake = super::bt::Legend::Alliance.api_id().unwrap(); + let mut missing_ids = Vec::new(); + let mut result = Vec::new(); + for id in ids { + if id == &to_fake { + // Hardcoded values + result.push(Legend { + id: to_fake.clone(), + swap: 62749, + heal: 62719, + elite: 62942, + utilities: vec![62832, 62962, 62878], + }); + } else { + missing_ids.push(id.clone()); + } + } + result.extend(self.get_multiple_cached("legends", "legends/", &missing_ids)?); + Ok(result) } /// Loads the image from the given URL. diff --git a/src/render.rs b/src/render.rs index 0a10eab..67e8619 100644 --- a/src/render.rs +++ b/src/render.rs @@ -156,13 +156,13 @@ impl<'r> Renderer<'r> { .iter() .filter_map(|l| l.api_id()) .collect::<Vec<_>>(); - let api_legends = self.api.get_legends(&legend_ids)?; let mut buffer = ImageBuffer::from_pixel( - api_legends.len() as u32 * self.options.legend_size, + legend_ids.len() as u32 * self.options.legend_size, self.options.legend_size, self.options.background_color, ); - for (i, legend) in api_legends.iter().enumerate() { + for (i, legend) in legend_ids.into_iter().enumerate() { + let legend = self.api.get_legends(&[legend])?.into_iter().next().unwrap(); let swapper = self .api .get_skills(&[legend.swap])? |