feat: Added Map

- Implemented Map
- Partially implemented CLI interaction with map
- Added load_map test
This commit is contained in:
Alexey 2025-12-03 17:01:40 +03:00
commit b9f75e426c
6 changed files with 371 additions and 25 deletions

View file

@ -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);
}