use crate::interactive_fiction::data::{ItemLocation, RuntimeState, Value};
use crate::interactive_fiction::engine::Engine;
pub fn player_has_light(engine: &Engine, state: &RuntimeState) -> bool {
state.item_locations.iter().any(|(item_id, location)| {
if !matches!(location, ItemLocation::Inventory) {
return false;
}
let Some(item) = engine.world().items.get(item_id) else {
return false;
};
if !item.properties.light_source {
return false;
}
let Some(flag) = item.properties.lit_flag.as_ref() else {
return false;
};
matches!(state.flags.get(flag), Some(Value::Bool(true)))
})
}