pub struct Game<C = StringMap> {
pub inner: GameInner,
pub context: C,
pub tags: GameTags,
/* private fields */
}Expand description
Wraps GameInner with customizable a context used to represent the game-specific state.
The context is exposed to your pages, allowing you to interact with your game state within them.
§Example
use ifengine::{GameError, View};
use story::chap1;
let game = ifengine::Game!(chap1::p1);
let view = match game.view() {
Ok(view: View) => view,
Err(e: GameError) => {
panic!("Unhandled err: {e}");
}
};
ui.render(view, &mut game);
§Additional
When processing for rendering, you can use the inner field directly.
Fields§
§inner: GameInner§context: CImplementations§
Source§impl<C: GameContext> Game<C>
impl<C: GameContext> Game<C>
Source§impl<C: GameContext> Game<C>
impl<C: GameContext> Game<C>
Source§impl<C: GameContext> Game<C>
impl<C: GameContext> Game<C>
Sourcepub fn simulate<F>(&self, visitor: F) -> Simulation
pub fn simulate<F>(&self, visitor: F) -> Simulation
The user must ensure that all cycles must be modelled by tunnels. We guarantee to never visit the same tunnel from the same location twice, but the presence of other loops will result in failure to halt. Although certain types of elements generated from proc_macros Panics if current game state is not a view F:
Methods from Deref<Target = GameInner>§
pub fn handle_choice(&mut self, key: InternalKey, index: u8)
pub fn handle_action(&mut self, action: Action) -> Result<(), GameError>
pub fn fresh(&self) -> bool
Trait Implementations§
Source§impl<C: GameContext> Deref for Game<C>
impl<C: GameContext> Deref for Game<C>
Source§impl<C: GameContext> DerefMut for Game<C>
impl<C: GameContext> DerefMut for Game<C>
Source§impl<'de, C> Deserialize<'de> for Game<C>where
C: Deserialize<'de>,
impl<'de, C> Deserialize<'de> for Game<C>where
C: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<C> Freeze for Game<C>where
C: Freeze,
impl<C = HashMap<String, String>> !RefUnwindSafe for Game<C>
impl<C> Send for Game<C>where
C: Send,
impl<C> Sync for Game<C>where
C: Sync,
impl<C> Unpin for Game<C>where
C: Unpin,
impl<C = HashMap<String, String>> !UnwindSafe for Game<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more