convert int IDs to strings
This commit is contained in:
14
src/exit.rs
14
src/exit.rs
@@ -54,7 +54,7 @@ impl ToString for Transition {
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Exit {
|
||||
/// destination
|
||||
pub room_id: u64,
|
||||
pub room_id: String,
|
||||
/// id
|
||||
pub position: Position,
|
||||
pub effect: Transition,
|
||||
@@ -67,7 +67,7 @@ impl FromStr for Exit {
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut parts = s.split_whitespace();
|
||||
let room_id = from_base36(parts.next().unwrap());
|
||||
let room_id = parts.next().unwrap().to_string();
|
||||
let position = Position::from_str(parts.next().unwrap());
|
||||
|
||||
if position.is_err() {
|
||||
@@ -92,7 +92,7 @@ impl fmt::Display for Exit {
|
||||
write!(
|
||||
f,
|
||||
"{} {}{}",
|
||||
self.room_id.to_base36(),
|
||||
self.room_id,
|
||||
self.position.to_string(),
|
||||
self.effect.to_string()
|
||||
)
|
||||
@@ -110,7 +110,7 @@ mod test {
|
||||
assert_eq!(
|
||||
Exit::from_str("a 12,13").unwrap(),
|
||||
Exit {
|
||||
room_id: 10,
|
||||
room_id: "a".to_string(),
|
||||
position: Position { x: 12, y: 13 },
|
||||
effect: Transition::None
|
||||
}
|
||||
@@ -122,7 +122,7 @@ mod test {
|
||||
assert_eq!(
|
||||
Exit::from_str("a 12,13 FX slide_u").unwrap(),
|
||||
Exit {
|
||||
room_id: 10,
|
||||
room_id: "a".to_string(),
|
||||
position: Position { x: 12, y: 13 },
|
||||
effect: Transition::SlideUp
|
||||
}
|
||||
@@ -133,7 +133,7 @@ mod test {
|
||||
fn test_exit_to_string() {
|
||||
assert_eq!(
|
||||
Exit {
|
||||
room_id: 8,
|
||||
room_id: "8".to_string(),
|
||||
position: Position { x: 5, y: 6 },
|
||||
effect: Transition::None
|
||||
}.to_string(),
|
||||
@@ -145,7 +145,7 @@ mod test {
|
||||
fn test_exit_to_string_with_fx() {
|
||||
assert_eq!(
|
||||
Exit {
|
||||
room_id: 8,
|
||||
room_id: "8".to_string(),
|
||||
position: Position { x: 5, y: 6 },
|
||||
effect: Transition::FadeToWhite
|
||||
}.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user