Commit b033aab2 authored by Rahix's avatar Rahix 🦀
Browse files

heaven: Assign a random shift and display its info

Generate a random shift for the player when entering the heaven.
Display all meta-data for this shift in the GUI.
parent dc2ba21f
use crate::angel_shifts;
use crate::colors;
use crate::components;
use crate::gamestate;
......@@ -13,6 +14,7 @@ pub struct HeavenState {
node_schedule: legion::Schedule,
player: components::Player,
assigned_shift: angel_shifts::AngelShift,
}
impl HeavenState {
......@@ -32,12 +34,28 @@ impl HeavenState {
.unwrap()
.set_inner_html(&format!("{}", 30 - player.collected_hours));
// Assign a random shift
let assigned_shift = angel_shifts::generate_random_shift(&mut rand::thread_rng());
// Display the shift info
let shift_meta = assigned_shift.metadata();
utils::get_element_by_id::<web_sys::Element>("heaven-shift-title")
.unwrap()
.set_inner_html(&shift_meta.title);
utils::get_element_by_id::<web_sys::Element>("heaven-shift-description")
.unwrap()
.set_inner_html(&shift_meta.description);
utils::get_element_by_id::<web_sys::Element>("heaven-shift-hours")
.unwrap()
.set_inner_html(&format!("{}", shift_meta.hours));
HeavenState {
gui_svg: utils::get_element_by_id("heaven-ui").unwrap(),
node_world,
resources,
node_schedule,
player,
assigned_shift,
}
}
}
......
......@@ -45,7 +45,7 @@ impl gamestate::State for LevelLoadingState {
let handle = init.get_handle();
let player = self.player.clone();
wasm_bindgen_futures::spawn_local(async move {
let level = svg_loader::SvgLevel::load_from_svg_file("resources/testlevel.svg")
let level = svg_loader::SvgLevel::load_from_svg_file("resources/levels/assembly-hall-1.svg")
.await
.unwrap();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment