From e895f932a67b1809ddc97bffc393dee90e9bf105 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Thu, 18 Jun 2020 13:56:50 +0100 Subject: [PATCH] skeleton stuff --- src/game.rs | 39 +++++++++++++++++++++++++++++++++++++++ src/lib.rs | 6 ++++++ 2 files changed, 45 insertions(+) diff --git a/src/game.rs b/src/game.rs index 3bbebb6..83f9ab7 100644 --- a/src/game.rs +++ b/src/game.rs @@ -187,6 +187,7 @@ impl Game { } } + // todo return a custom error instead assert!(avatar.is_some()); 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 { @@ -293,6 +331,7 @@ impl Game { /// 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` + /// todo this needs to be a generic function that takes a vec of string IDs and returns a new base64 string ID #[inline] pub fn new_tile_id(&self) -> u64 { let mut new_id = 0; diff --git a/src/lib.rs b/src/lib.rs index de5ebc2..805ec41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,6 +156,12 @@ fn is_string_numeric(str: String) -> bool { 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 { + +} + pub trait Quote { fn quote(&self) -> String; }