Game

Struct Game 

Source
pub struct Game {
Show 15 fields pub name: String, pub version: Option<Version>, pub room_format: Option<RoomFormat>, pub font: Font, pub custom_font: Option<String>, pub text_direction: TextDirection, pub palettes: Vec<Palette>, pub rooms: Vec<Room>, pub tiles: Vec<Tile>, pub sprites: Vec<Sprite>, pub items: Vec<Item>, pub dialogues: Vec<Dialogue>, pub endings: Vec<Ending>, pub variables: Vec<Variable>, pub font_data: Option<String>, /* private fields */
}

Fields§

§name: String§version: Option<Version>§room_format: Option<RoomFormat>§font: Font§custom_font: Option<String>§text_direction: TextDirection§palettes: Vec<Palette>§rooms: Vec<Room>§tiles: Vec<Tile>§sprites: Vec<Sprite>§items: Vec<Item>§dialogues: Vec<Dialogue>§endings: Vec<Ending>§variables: Vec<Variable>§font_data: Option<String>

Implementations§

Source§

impl Game

Source

pub fn from(string: String) -> Result<(Game, Vec<Error>), NotFound>

Source

pub fn get_sprite_by_id(&self, id: String) -> Result<&Sprite, NotFound>

todo refactor this into “get T by ID”, taking a Vec and an ID name?

Source

pub fn get_tile_by_id(&self, id: String) -> Result<&Tile, NotFound>

Source

pub fn get_room_by_id(&self, id: String) -> Result<&Room, NotFound>

Source

pub fn get_avatar(&self) -> Result<&Sprite, NotFound>

Source

pub fn get_tiles_by_ids(&self, ids: Vec<String>) -> Vec<&Tile>

Source

pub fn get_tiles_for_room(&self, id: String) -> Result<Vec<&Tile>, NotFound>

Source

pub fn merge(&mut self, game: &Game)

Source§

impl Game

Source

pub fn palette_ids(&self) -> Vec<String>

Source

pub fn tile_ids(&self) -> Vec<String>

Source

pub fn sprite_ids(&self) -> Vec<String>

Source

pub fn room_ids(&self) -> Vec<String>

Source

pub fn item_ids(&self) -> Vec<String>

Source

pub fn dialogue_ids(&self) -> Vec<String>

Source

pub fn ending_ids(&self) -> Vec<String>

Source

pub fn variable_ids(&self) -> Vec<String>

Source

pub fn new_palette_id(&self) -> String

Source

pub fn new_tile_id(&self) -> String

first available tile ID. e.g. if current tile IDs are [0, 2, 3] the result will be 1 if current tile IDs are [0, 1, 2] the result will be 3

Source

pub fn new_sprite_id(&self) -> String

Source

pub fn new_room_id(&self) -> String

Source

pub fn new_item_id(&self) -> String

Source

pub fn new_dialogue_id(&self) -> String

Source

pub fn new_ending_id(&self) -> String

Source

pub fn new_variable_id(&self) -> String

Source

pub fn get_palette(&self, id: &str) -> Option<&Palette>

Source

pub fn get_tile_id(&self, matching_tile: &Tile) -> Option<String>

todo refactor?

Source

pub fn find_tile_with_animation(&self, animation: &[Image]) -> Option<&Tile>

Source

pub fn add_palette(&mut self, palette: Palette) -> String

adds a palette safely and returns the ID

Source

pub fn add_tile(&mut self, tile: Tile) -> String

adds a tile safely and returns the ID

Source

pub fn add_sprite(&mut self, sprite: Sprite) -> String

adds a sprite safely and returns the ID

Source

pub fn add_item(&mut self, item: Item) -> String

adds an item safely and returns the ID

Source

pub fn add_dialogue(&mut self, dialogue: Dialogue) -> String

adds a dialogue safely and returns the ID

Source

pub fn add_ending(&mut self, ending: Ending) -> String

adds an ending safely and returns the ID

Source

pub fn add_room(&mut self, room: Room) -> String

Safely adds a room and returns the room ID (a new ID will be generated if clashing) You will need to be mindful that the room’s palette, tile, exit and ending IDs will be valid after adding.

Source

pub fn add_variable(&mut self, variable: Variable) -> String

Source

pub fn dedupe_tiles(&mut self)

todo I think I need a generic dedupe(&mut self, Vec<T>) function it would have to take a closure for comparing a given T (see the background_tile below) and a closure for what to do with the changed IDs

Source

pub fn version(&self) -> Version

older bitsy games do not specify a version, but we can infer 1.0

Source

pub fn room_format(&self) -> RoomFormat

older bitsy games do not specify a room format, but we can infer 0

Trait Implementations§

Source§

impl Clone for Game

Source§

fn clone(&self) -> Game

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Game

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Game

Source§

fn eq(&self, other: &Game) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for Game

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl StructuralPartialEq for Game

Auto Trait Implementations§

§

impl Freeze for Game

§

impl RefUnwindSafe for Game

§

impl Send for Game

§

impl Sync for Game

§

impl Unpin for Game

§

impl UnwindSafe for Game

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.