From 899527d3e7e5e520ac8cf4f021d1aa6bb6888faf Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 26 Jul 2021 01:21:29 +0000 Subject: [PATCH] basic test --- src/ship/map/enemy.rs | 2 +- tests/test_rooms.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ship/map/enemy.rs b/src/ship/map/enemy.rs index 6aed225..52092d4 100644 --- a/src/ship/map/enemy.rs +++ b/src/ship/map/enemy.rs @@ -78,7 +78,7 @@ pub enum MapEnemyError { // making this `pub type` doesn't allow `impl`s to be defined? #[derive(Clone, Debug, Serialize, Deserialize)] pub struct RareMonsterAppearTable { - appear_rate: HashMap, + pub appear_rate: HashMap, } impl RareMonsterAppearTable { diff --git a/tests/test_rooms.rs b/tests/test_rooms.rs index 45f8ace..61ec3c1 100644 --- a/tests/test_rooms.rs +++ b/tests/test_rooms.rs @@ -101,3 +101,23 @@ async fn test_item_ids_reset_when_rejoining_rooms() { _ => panic!(), } } + +#[async_std::test] +async fn test_load_rare_monster_default_appear_rates() { + let mut entity_gateway = InMemoryGateway::default(); + let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await; + let mut ship = Box::new(ShipServerState::builder() + .gateway(entity_gateway.clone()) + .build()); + log_in_char(&mut ship, ClientId(1), "a1", "a").await; + join_lobby(&mut ship, ClientId(1)).await; + create_room(&mut ship, ClientId(1), "room", "").await; + + // assume episode 1 + let room = ship.blocks.0[0].rooms[0].as_ref().unwrap(); + println!("rare monster table: {:?}", room.rare_monster_table); + let rates = &*room.rare_monster_table; + for (_monster, rate) in rates.clone().appear_rate { + assert_eq!(rate, 0.001953125f32); // 1/512 = 0.001953125 + } +} \ No newline at end of file