andy
4 years ago
2 changed files with 104 additions and 0 deletions
@ -0,0 +1,101 @@ |
|||
use elseware::common::serverstate::{ClientId, ServerState};
|
|||
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|||
use elseware::entity::item;
|
|||
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
|
|||
|
|||
use libpso::packet::ship::*;
|
|||
use libpso::packet::messages::*;
|
|||
|
|||
#[path = "common.rs"]
|
|||
mod common;
|
|||
use common::*;
|
|||
|
|||
// unwrap presents
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_weapon() {
|
|||
let mut entity_gateway = InMemoryGateway::new();
|
|||
|
|||
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|||
|
|||
let wrapped_item = entity_gateway.create_item(
|
|||
item::NewItemEntity {
|
|||
item: item::ItemDetail::Weapon(item::weapon::Weapon {
|
|||
weapon: item::weapon::WeaponType::Saber,
|
|||
special: Some(item::weapon::WeaponSpecial::Burning),
|
|||
grind: 5,
|
|||
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Machine, value: 20}),
|
|||
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 30}),
|
|||
None],
|
|||
tekked: false,
|
|||
wrapping: Some(item::WrappingPaper::Red_Green),
|
|||
}),
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
println!("created item: {:?}", wrapped_item);
|
|||
|
|||
let mut inventory = Vec::<item::ItemEntity>::new();
|
|||
inventory.push(wrapped_item.into());
|
|||
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
|
|||
|
|||
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;
|
|||
|
|||
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerUseItem(PlayerUseItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
item_id: 0x10000,
|
|||
})))).await.unwrap().for_each(drop);
|
|||
|
|||
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
|
|||
|
|||
inventory_items.items[0].with_individual(|item| {
|
|||
match &item.item {
|
|||
item::ItemDetail::Weapon(weapon) => {
|
|||
assert!(weapon.as_bytes() == [0x00, 0x01, 0x00, 0x05, 0x9A, 0x00, 0x03, 0x14, 0x05, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}).unwrap();
|
|||
}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_armor() {}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_shield() {}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_unit() {}
|
|||
|
|||
// mag cells are covered in test_mags.rs
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_mag() {}
|
|||
|
|||
// TODO: implement wrapping packet (gallons shop quest)
|
|||
// wrap presents
|
|||
#[async_std::test]
|
|||
async fn test_wrap_weapon() {}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_wrap_armor() {}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_wrap_shield() {}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_wrap_unit() {}
|
|||
|
|||
// mag cells are covered in test_mags.rs
|
|||
#[async_std::test]
|
|||
async fn test_wrap_mag() {}
|
|||
|
|||
|
|||
// item combinations?
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue