skeleton stuff

This commit is contained in:
Max Bradbury 2020-06-18 13:56:50 +01:00
parent 1ce479afaa
commit e895f932a6
2 changed files with 45 additions and 0 deletions

View File

@ -187,6 +187,7 @@ impl Game {
} }
} }
// todo return a custom error instead
assert!(avatar.is_some()); assert!(avatar.is_some());
let avatar = avatar.unwrap(); let avatar = avatar.unwrap();
@ -213,6 +214,43 @@ impl Game {
} }
) )
} }
pub fn merge(game: Game) {
// ignore title, version, room format, room type, font, text direction
// maybe we need hashmaps of old->new IDs, for each type of ID?
// we need functions for "add sprite" etc. that return the newly generated valid ID
// for each new palette:
// check if a matching palette exists
// if yes, replace any room palette IDs with the extant palette ID
// check if palette ID clashes with an existing palette ID
// check if palette name clashes and if so, give a new name ("[name] 2" or something)
// for each tile:
// check if a matching tile exists
// if yes, replace room tile IDs with that of the extant tile
// if no, give a new unique tile ID and change room tile IDs to this
// ignore avatar (maybe convert to normal sprite instead?)
// for each item
// for each dialogue item
// for each ending
// for each variable
// for each room
// give room a new unique ID
// check room name - if duplicate, append "2" or something?
// convert tile/item IDs to new ones
// add room to game
// for each sprite
//
}
} }
impl ToString for Game { impl ToString for Game {
@ -293,6 +331,7 @@ impl Game {
/// first available tile ID. /// first available tile ID.
/// e.g. if current tile IDs are [0, 2, 3] the result will be `1` /// 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` /// if current tile IDs are [0, 1, 2] the result will be `3`
/// todo this needs to be a generic function that takes a vec of string IDs and returns a new base64 string ID
#[inline] #[inline]
pub fn new_tile_id(&self) -> u64 { pub fn new_tile_id(&self) -> u64 {
let mut new_id = 0; let mut new_id = 0;

View File

@ -156,6 +156,12 @@ fn is_string_numeric(str: String) -> bool {
return true; return true;
} }
/// e.g. pass all tile IDs into this to get a new non-conflicting tile ID
#[inline]
fn new_unique_id(ids: Vec<String>) -> String {
}
pub trait Quote { pub trait Quote {
fn quote(&self) -> String; fn quote(&self) -> String;
} }