basic test
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
andy 2021-07-26 01:21:29 +00:00
parent 00cff46077
commit 899527d3e7
2 changed files with 21 additions and 1 deletions

View File

@ -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<MonsterType, f32>,
pub appear_rate: HashMap<MonsterType, f32>,
}
impl RareMonsterAppearTable {

View File

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