Skip to content

Commit

Permalink
fixed credits summary
Browse files Browse the repository at this point in the history
  • Loading branch information
lordlou committed Jan 6, 2024
1 parent a344ba5 commit 955a67f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
44 changes: 41 additions & 3 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use game_data::{StartLocation, HubLocation, LinksDataGroup};
use patch::Rom;
use pyo3::{prelude::*, types::PyDict};
use rand::{SeedableRng, RngCore};
use randomize::{Randomization, SpoilerLog, escape_timer, randomize_doors, ItemPlacementStyle, ItemPriorityGroup, ItemMarkers, RandomizationState, ItemLocationState, FlagLocationState, SaveLocationState, MotherBrainFight};
use randomize::{Randomization, SpoilerLog, escape_timer, randomize_doors, ItemPlacementStyle, ItemPriorityGroup, ItemMarkers, RandomizationState, ItemLocationState, FlagLocationState, SaveLocationState, MotherBrainFight, SpoilerSummary, SpoilerItemSummary, SpoilerLocation, SpoilerFlagSummary};
use traverse::TraverseResult;
use crate::{
game_data::{GameData, Map, IndexedVec, Item, NodeId, RoomId, ObstacleMask},
Expand Down Expand Up @@ -1310,21 +1310,59 @@ fn create_gamedata(apworld_path: Option<String>) -> GameData {
apworld_path).unwrap()
}

fn create_summary(spoiler_summary_vec: Vec<(usize, String, String)>) -> Vec<SpoilerSummary> {
let mut result: Vec<SpoilerSummary> = Vec::new();
let mut current_step = 0;
for (step, item, location) in spoiler_summary_vec {
if step == current_step - 1 {
result[step].items.push(SpoilerItemSummary {
item: item,
location: SpoilerLocation {
area: location,
room: "".to_string(),
node: "".to_string(),
coords: (0, 0),
},
});
} else {
current_step += 1;
result.push(SpoilerSummary {
step: current_step,
items: vec![SpoilerItemSummary {
item: item,
location: SpoilerLocation {
area: location,
room: "".to_string(),
node: "".to_string(),
coords: (0, 0),
},
}],
flags: vec![SpoilerFlagSummary {
flag: "".to_string(),
}],
})
}
}
result
}

#[pyfunction]
fn patch_rom(
base_rom_path: String,
ap_randomizer: &APRandomizer,
item_placement_ids: Vec<usize>,
state: &RandomizationState
state: &RandomizationState,
spoiler_summary_vec: Vec<(usize, String, String)>
) -> Vec<u8> {
let rom_path = Path::new(&base_rom_path);
let base_rom = Rom::load(rom_path).unwrap();
let item_placement: Vec<Item> = item_placement_ids.iter().map(|v| Item::try_from(*v).unwrap()).collect::<Vec<_>>();
let randomizer = &ap_randomizer.randomizer;

let spoiler_escape = escape_timer::compute_escape_data(&randomizer.game_data, &randomizer.map, &randomizer.difficulty_tiers[0]).unwrap();
let summary = create_summary(spoiler_summary_vec);
let spoiler_log = SpoilerLog {
summary: Vec::new(),
summary: summary,
escape: spoiler_escape,
details: Vec::new(),
all_items: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion rust/src/randomize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3760,7 +3760,7 @@ pub struct SpoilerItemSummary {

#[derive(Serialize, Deserialize)]
pub struct SpoilerFlagSummary {
flag: String,
pub flag: String,
// area: String,
}

Expand Down

0 comments on commit 955a67f

Please sign in to comment.