Skip to content

Instantly share code, notes, and snippets.

@DarkFenX
Created May 26, 2020 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkFenX/f0a0779368ac12a874b286d487c6a03b to your computer and use it in GitHub Desktop.
Save DarkFenX/f0a0779368ac12a874b286d487c6a03b to your computer and use it in GitHub Desktop.
#[derive(Debug, serde::Deserialize)]
pub(super) struct ItemFighterAbilData {
#[serde(rename = "abilityID")]
pub(super) abil_id: ReeInt,
#[serde(rename = "cooldownSeconds")]
pub(super) cooldown: Option<ReeFloat>,
pub(super) charges: Option<ItemFighterAbilChargeData>,
}
#[derive(Debug, serde::Deserialize)]
pub(super) struct ItemFighterAbilChargeData {
#[serde(rename = "chargeCount")]
pub(super) count: ReeInt,
#[serde(rename = "rearmTimeSeconds")]
pub(super) rearm_time: ReeFloat,
}
...
fn fsd_merge(self, id: ReeInt) -> Vec<dh::ItemFighterAbilRel> {
let mut vec = Vec::new();
for abil_data in vec![self.abil0, self.abil1, self.abil2].into_iter() {
if let Some(abil_data) = abil_data {
vec.push(dh::ItemFighterAbilRel::new(
id,
abil_data.abil_id,
abil_data.cooldown,
abil_data.charges.and_then(|v| Some(v.count)),
abil_data.charges.and_then(|v| Some(v.rearm_time)),
))
}
}
vec
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment