Browse Source
Merge pull request 'save_options' (#225) from save_options into master
Merge pull request 'save_options' (#225) from save_options into master
Reviewed-by: jake <jake@sharnoth.com>pbs
jake
4 years ago
7 changed files with 64 additions and 0 deletions
-
3src/entity/character.rs
-
1src/entity/gateway/inmemory.rs
-
11src/ship/character.rs
-
1src/ship/packet/handler/lobby.rs
-
12src/ship/packet/handler/settings.rs
-
5src/ship/ship.rs
-
31tests/test_character.rs
@ -0,0 +1,31 @@ |
|||||
|
use elseware::common::serverstate::{ClientId, ServerState};
|
||||
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
||||
|
use elseware::ship::ship::{ShipServerState, RecvShipPacket};
|
||||
|
|
||||
|
use libpso::packet::ship::*;
|
||||
|
|
||||
|
#[path = "common.rs"]
|
||||
|
mod common;
|
||||
|
use common::*;
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_save_options<EG: EntityGateway>(ship: &mut ShipServerState<EG>, id: ClientId, options: u32) {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
|
||||
|
let mut ship = ShipServerState::builder()
|
||||
|
.gateway(entity_gateway.clone())
|
||||
|
.build();
|
||||
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
|
join_lobby(&mut ship, ClientId(1)).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::SaveOptions(SaveOptions{
|
||||
|
options: 12345,
|
||||
|
})).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let char = characters[0].as_ref().unwrap();
|
||||
|
|
||||
|
assert!(char.option_flags == 12345);
|
||||
|
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue