replace tile ID with string
This commit is contained in:
10
src/tile.rs
10
src/tile.rs
@@ -3,7 +3,7 @@ use crate::image::animation_frames_from_string;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Tile {
|
||||
pub id: u64,
|
||||
pub id: String,
|
||||
pub name: Option<String>,
|
||||
pub wall: Option<bool>, // this is "optional" in that a tile can have `WAL true|false` or neither
|
||||
pub animation_frames: Vec<Image>,
|
||||
@@ -40,7 +40,7 @@ impl From<String> for Tile {
|
||||
fn from(string: String) -> Tile {
|
||||
let mut lines: Vec<&str> = string.lines().collect();
|
||||
|
||||
let id = from_base36(&lines[0].replace("TIL ", ""));
|
||||
let id = lines[0].replace("TIL ", "");
|
||||
|
||||
let mut wall = None;
|
||||
let mut name = None;
|
||||
@@ -80,7 +80,7 @@ impl ToString for Tile {
|
||||
fn to_string(&self) -> String {
|
||||
format!(
|
||||
"TIL {}\n{}{}{}{}",
|
||||
self.id.to_base36(),
|
||||
self.id,
|
||||
self.animation_frames.to_string(),
|
||||
self.name_line(),
|
||||
self.wall_line(),
|
||||
@@ -100,7 +100,7 @@ mod test {
|
||||
let output = Tile::from(include_str!("test-resources/tile").to_string());
|
||||
|
||||
let expected = Tile {
|
||||
id: 35,
|
||||
id: "z".to_string(),
|
||||
name: Some("concrete 1".to_string()),
|
||||
wall: Some(true),
|
||||
animation_frames: vec![Image {
|
||||
@@ -115,7 +115,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_tile_to_string() {
|
||||
let output = Tile {
|
||||
id: 262,
|
||||
id: "7a".to_string(),
|
||||
name: Some("chequers".to_string()),
|
||||
wall: None,
|
||||
animation_frames: vec![
|
||||
|
||||
Reference in New Issue
Block a user