allow non-16x16 rooms
This commit is contained in:
parent
b2f601e778
commit
76eca72699
22
src/lib.rs
22
src/lib.rs
|
@ -152,6 +152,28 @@ fn is_string_numeric(str: String) -> bool {
|
||||||
return true;
|
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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string};
|
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string};
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl From<String> for Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
let lines = &lines[1..];
|
let lines = &lines[1..];
|
||||||
|
let dimension = lines.len(); // x or y, e.g. `16` for 16x16
|
||||||
let mut tiles: Vec<String> = Vec::new();
|
let mut tiles: Vec<String> = Vec::new();
|
||||||
|
|
||||||
for line in lines.into_iter() {
|
for line in lines.into_iter() {
|
||||||
|
@ -120,7 +120,7 @@ impl From<String> for Room {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if ! comma_separated { line = line[1..].to_owned(); }
|
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 {
|
for tile_id in line {
|
||||||
tiles.push(tile_id.to_string());
|
tiles.push(tile_id.to_string());
|
||||||
|
|
Loading…
Reference in New Issue