dedupe optional line for room
This commit is contained in:
parent
6dc9bbcc2d
commit
5d76798ace
10
src/room.rs
10
src/room.rs
|
@ -1,4 +1,4 @@
|
|||
use crate::{Exit, ExitInstance, Instance, mock, Position, from_base36, ToBase36};
|
||||
use crate::{Exit, ExitInstance, Instance, mock, Position, from_base36, ToBase36, optional_data_line};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct Room {
|
||||
|
@ -11,6 +11,12 @@ pub struct Room {
|
|||
pub endings: Vec<Instance>,
|
||||
}
|
||||
|
||||
impl Room {
|
||||
fn name_line(&self) -> String {
|
||||
optional_data_line("NAME", self.name.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Room {
|
||||
fn from(string: String) -> Room {
|
||||
// todo handle room_format?
|
||||
|
@ -125,7 +131,7 @@ impl ToString for Room {
|
|||
"ROOM {}\n{}{}{}{}{}\nPAL {}",
|
||||
self.id.to_base36(),
|
||||
tiles,
|
||||
if self.name.as_ref().is_some() { format!("\nNAME {}", self.name.as_ref().unwrap()) } else { "".to_string() },
|
||||
self.name_line(),
|
||||
items,
|
||||
exits,
|
||||
endings,
|
||||
|
|
Loading…
Reference in New Issue