allow non-16x16 rooms

This commit is contained in:
Max Bradbury 2020-04-28 19:30:18 +01:00
parent b2f601e778
commit 76eca72699
2 changed files with 24 additions and 2 deletions

View File

@ -152,6 +152,28 @@ fn is_string_numeric(str: String) -> bool {
return true;
}
pub trait Quote {
fn quote(&self) -> String;
}
impl Quote for String {
#[inline]
fn quote(&self) -> String {
format!("\"\"\"\n{}\n\"\"\"", self).to_string()
}
}
pub trait Unquote {
fn unquote(&self) -> String;
}
impl Unquote for String {
#[inline]
fn unquote(&self) -> String {
self.trim_matches('\"').trim_matches('\n').to_string()
}
}
#[cfg(test)]
mod test {
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string};

View File

@ -110,7 +110,7 @@ impl From<String> for Room {
}
let lines = &lines[1..];
let dimension = lines.len(); // x or y, e.g. `16` for 16x16
let mut tiles: Vec<String> = Vec::new();
for line in lines.into_iter() {
@ -120,7 +120,7 @@ impl From<String> for Room {
.collect();
if ! comma_separated { line = line[1..].to_owned(); }
let line = line[..16].to_owned();
let line = line[..dimension].to_owned();
for tile_id in line {
tiles.push(tile_id.to_string());