more structs and hashmaps

This commit is contained in:
Max Bradbury 2020-04-05 21:02:45 +01:00
parent 2f9a4f7fe3
commit b7ff7c951c
1 changed files with 26 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use std::fmt;
use std::collections::HashMap;
#[derive(Eq, PartialEq)]
struct Colour {
@ -27,7 +28,7 @@ struct Tile {
animation_frames: Vec<Image>,
}
#[derive(Eq, PartialEq)]
#[derive(Eq, PartialEq, Hash)]
struct Position {
room: String, // id. is room id int or base36 string?
x: u8,
@ -49,6 +50,7 @@ struct Sprite {
position: Position,
}
/// avatar is a "sprite" in the game data but with a specific ID
#[derive(Eq, PartialEq)]
struct Avatar {
animation_frames: Vec<Image>,
@ -63,6 +65,29 @@ struct Item {
dialogue: Option<Dialogue>,
}
#[derive(Eq, PartialEq)]
struct Exit {
/// destination
room: String, /// id
position: Position,
}
// same as a dialogue basically
#[derive(Eq, PartialEq)]
struct Ending {
contents: String,
}
#[derive(Eq, PartialEq)]
struct Room {
id: String,
palette: String, /// id
name: Option<String>,
items: HashMap<Position, Item>,
exits: HashMap<Position, Exit>,
endings: HashMap<Position, Ending>,
}
#[derive(PartialEq)]
struct Game {
name: String,