Browse Source

fix tests that care about rooms

pbs
jake 4 years ago
parent
commit
11fecd5bda
  1. 10
      src/ship/ship.rs
  2. 8
      tests/test_exp_gain.rs

10
src/ship/ship.rs

@ -263,7 +263,7 @@ impl ClientState {
settings: settings,
character: character,
session: session,
block: 1,
block: 0,
item_drop_location: None,
done_loading_quest: false,
area: None,
@ -379,9 +379,9 @@ impl<EG: EntityGateway> ShipServerStateBuilder<EG> {
}
struct Block {
pub struct Block {
client_location: Box<ClientLocation>,
rooms: Box<Rooms>,
pub rooms: Box<Rooms>,
}
impl Default for Block {
@ -393,7 +393,7 @@ impl Default for Block {
}
}
struct Blocks(Vec<Block>);
pub struct Blocks(pub Vec<Block>);
impl Blocks {
fn with_client(&mut self, id: ClientId, clients: &Clients) -> Result<&mut Block, ShipError> {
@ -410,7 +410,7 @@ pub struct ShipServerState<EG: EntityGateway> {
item_manager: items::ItemManager,
quests: quests::QuestList,
shops: Box<ItemShops>,
blocks: Blocks,
pub blocks: Blocks,
ip: Ipv4Addr,
port: u16,

8
tests/test_exp_gain.rs

@ -25,7 +25,7 @@ async fn test_character_gains_exp() {
create_room(&mut ship, ClientId(1), "room", "").await;
let (enemy_id, exp) = {
let room = ship.rooms[0].as_ref().unwrap();
let room = ship.blocks.0[0].rooms[0].as_ref().unwrap();
let (enemy_id, map_enemy) = (0..).filter_map(|i| {
room.maps.enemy_by_id(i).map(|enemy| {
(i, enemy)
@ -64,7 +64,7 @@ async fn test_character_levels_up() {
create_room(&mut ship, ClientId(1), "room", "").await;
let enemy_id = {
let room = ship.rooms[0].as_ref().unwrap();
let room = ship.blocks.0[0].rooms[0].as_ref().unwrap();
(0..).filter_map(|i| {
room.maps.enemy_by_id(i).map(|_| {
i
@ -102,7 +102,7 @@ async fn test_character_levels_up_multiple_times() {
create_room(&mut ship, ClientId(1), "room", "").await;
let (enemy_id, exp) = {
let room = ship.rooms[0].as_ref().unwrap();
let room = ship.blocks.0[0].rooms[0].as_ref().unwrap();
let (enemy_id, map_enemy) = (0..).filter_map(|i| {
room.maps.enemy_by_id(i).ok().and_then(|enemy| {
if enemy.monster == MonsterType::DarkFalz2 {
@ -152,7 +152,7 @@ async fn test_one_character_gets_full_exp_and_other_attacker_gets_partial() {
join_room(&mut ship, ClientId(2), 0).await;
let (enemy_id, exp) = {
let room = ship.rooms[0].as_ref().unwrap();
let room = ship.blocks.0[0].rooms[0].as_ref().unwrap();
let (enemy_id, map_enemy) = (0..).filter_map(|i| {
room.maps.enemy_by_id(i).ok().and_then(|enemy| {
if enemy.monster == MonsterType::DarkFalz2 {

Loading…
Cancel
Save