Skip to content

Commit

Permalink
feat: level & ascension for multipath
Browse files Browse the repository at this point in the history
  • Loading branch information
emmachase committed Aug 13, 2024
1 parent 70655d8 commit fa37bcd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ureq = { version = "2.10.1", features = ["json"] }

[dependencies.reliquary]
git = "https://github.com/IceDynamix/reliquary"
tag = "v3.0.0"
tag = "v3.1.0"

[profile.release]
opt-level = "z" # optimize for size
Expand Down
31 changes: 26 additions & 5 deletions src/export/fribbels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct OptimizerExporter {
relics: Vec<Relic>,
characters: Vec<Character>,
multipath_characters: Vec<Character>,
multipath_base_avatars: HashMap<u32, ProtoCharacter>,
}

impl OptimizerExporter {
Expand All @@ -69,15 +70,14 @@ impl OptimizerExporter {
relics: vec![],
characters: vec![],
multipath_characters: vec![],
multipath_base_avatars: HashMap::new(),
}
}

pub fn set_uid(&mut self, uid: u32) {
self.uid = Some(uid);
}

// TODO: add_multipath_avatars

pub fn add_inventory(&mut self, bag: GetBagScRsp) {
let mut relics: Vec<Relic> = bag.relic_list.iter()
.filter_map(|r| export_proto_relic(&self.database, r))
Expand All @@ -95,13 +95,18 @@ impl OptimizerExporter {
}

pub fn add_characters(&mut self, characters: GetAvatarDataScRsp) {
let mut characters: Vec<Character> = characters.avatar_list.iter()
.filter(|a| MultiPathAvatarType::from_i32(a.base_avatar_id as i32).is_none() ) // skip multipath characters
let (characters, multipath_characters) = characters.avatar_list.iter()
.partition::<Vec<_>, _>(|a| MultiPathAvatarType::from_i32(a.base_avatar_id as i32).is_none() );

let mut characters: Vec<Character> = characters.iter()
.filter_map(|char| export_proto_character(&self.database, char))
.collect();

info!(num=characters.len(), "found characters");
self.characters.append(&mut characters);

info!(num=multipath_characters.len(), "found multipath base avatars");
self.multipath_base_avatars.extend(multipath_characters.into_iter().map(|c| (c.base_avatar_id, c.clone())));
}

pub fn add_multipath_characters(&mut self, characters: GetMultiPathAvatarInfoScRsp) {
Expand All @@ -121,6 +126,18 @@ impl OptimizerExporter {
info!(num=characters.len(), "found multipath characters");
self.multipath_characters.append(&mut characters);
}

pub fn finalize_multipath_characters(&mut self) {
// Fetch level & ascension
for character in self.multipath_characters.iter_mut() {
if let Some(config) = self.database.multipath_avatar_config.get(&character.id.parse().unwrap()) {
if let Some(base_avatar) = self.multipath_base_avatars.get(&config.BaseAvatarID) {
character.level = base_avatar.level;
character.ascension = base_avatar.promotion;
}
}
}
}
}

impl Exporter for OptimizerExporter {
Expand Down Expand Up @@ -192,7 +209,7 @@ impl Exporter for OptimizerExporter {
}

#[instrument(skip_all)]
fn export(self) -> Self::Export {
fn export(mut self) -> Self::Export {
info!("exporting collected data");

if self.trailblazer.is_none() {
Expand All @@ -219,6 +236,8 @@ impl Exporter for OptimizerExporter {
warn!("characters were not recorded");
}

self.finalize_multipath_characters();

Export {
source: "reliquary_archiver",
build: env!("CARGO_PKG_VERSION"),
Expand All @@ -240,6 +259,7 @@ pub struct Database {
avatar_config: AvatarConfigMap,
avatar_skill_tree_config: AvatarSkillTreeConfigMap,
equipment_config: EquipmentConfigMap,
multipath_avatar_config: MultiplePathAvatarConfigMap,
relic_config: RelicConfigMap,
relic_set_config: RelicSetConfigMap,
relic_main_affix_config: RelicMainAffixConfigMap,
Expand All @@ -256,6 +276,7 @@ impl Database {
avatar_config: Self::load_online_config(),
avatar_skill_tree_config: Self::load_online_config(),
equipment_config: Self::load_online_config(),
multipath_avatar_config: Self::load_online_config(),
relic_config: Self::load_online_config(),
relic_set_config: Self::load_online_config(),
relic_main_affix_config: Self::load_online_config(),
Expand Down

0 comments on commit fa37bcd

Please sign in to comment.