feat: Added Map
- Implemented Map - Partially implemented CLI interaction with map - Added load_map test
This commit is contained in:
parent
dc94f2060c
commit
b9f75e426c
6 changed files with 371 additions and 25 deletions
1
tests/io/map.toml
Normal file
1
tests/io/map.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use squad_quest::{account::Account, config::Config, quest::Quest};
|
||||
use squad_quest::{SquadObject, account::Account, config::Config, map::{Map, Room}, quest::Quest};
|
||||
|
||||
static CONFIG_PATH: &str = "./tests/main/config.toml";
|
||||
|
||||
|
|
@ -81,3 +81,50 @@ fn account_test() {
|
|||
|
||||
assert_eq!(*account, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_map() {
|
||||
let config = Config::load(CONFIG_PATH.into());
|
||||
|
||||
let room0 = Room {
|
||||
id: 0,
|
||||
children: vec![1, 2],
|
||||
value: 0,
|
||||
name: "Entrance".to_string(),
|
||||
description: Some("Enter the dungeon".to_string()),
|
||||
};
|
||||
|
||||
let room1 = Room {
|
||||
id: 1,
|
||||
children: vec![0, 3],
|
||||
value: 100,
|
||||
name: "Kitchen hall".to_string(),
|
||||
description: None,
|
||||
};
|
||||
|
||||
let room2 = Room {
|
||||
id: 2,
|
||||
children: vec![0],
|
||||
value: 250,
|
||||
name: "Room".to_string(),
|
||||
description: Some("Simple room with no furniture".to_string()),
|
||||
};
|
||||
|
||||
let room3 = Room {
|
||||
id: 3,
|
||||
children: vec![1],
|
||||
value: 175,
|
||||
name: "Kitchen".to_string(),
|
||||
description: Some("Knives are stored here".to_string()),
|
||||
};
|
||||
|
||||
let expected = Map {
|
||||
room: vec![room0, room1, room2, room3],
|
||||
};
|
||||
|
||||
let map_path = config.full_map_path();
|
||||
|
||||
let map = Map::load(map_path).unwrap();
|
||||
|
||||
assert_eq!(map.room, expected.room);
|
||||
}
|
||||
|
|
|
|||
26
tests/main/map.toml
Normal file
26
tests/main/map.toml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[[room]]
|
||||
id = 0
|
||||
children = [ 1, 2 ]
|
||||
value = 0
|
||||
name = "Entrance"
|
||||
description = "Enter the dungeon"
|
||||
|
||||
[[room]]
|
||||
id = 1
|
||||
children = [ 0, 3 ]
|
||||
value = 100
|
||||
name = "Kitchen hall"
|
||||
|
||||
[[room]]
|
||||
id = 2
|
||||
children = [ 0 ]
|
||||
value = 250
|
||||
name = "Room"
|
||||
description = "Simple room with no furniture"
|
||||
|
||||
[[room]]
|
||||
id = 3
|
||||
children = [ 1 ]
|
||||
value = 175
|
||||
name = "Kitchen"
|
||||
description = "Knives are stored here"
|
||||
Loading…
Add table
Add a link
Reference in a new issue