|
|
@ -2,6 +2,7 @@ use elseware::common::serverstate::{ClientId, ServerState}; |
|
|
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|
|
|
use elseware::entity::item;
|
|
|
|
use elseware::ship::ship::{ShipServerState, RecvShipPacket};
|
|
|
|
use elseware::entity::character::TechLevel;
|
|
|
|
//use elseware::ship::items::{ClientItemId, ActiveItemEntityId, HeldItemType, FloorItemType};
|
|
|
|
|
|
|
|
use libpso::packet::ship::*;
|
|
|
@ -304,6 +305,92 @@ async fn test_jackolantern() { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_use_barta_1() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
|
|
/*
|
|
|
|
let mut p1_inv = Vec::new();
|
|
|
|
for tool in vec![item::tool::ToolType::PowerMaterial, item::tool::ToolType::].into_iter() {
|
|
|
|
let mut item = Vec::new();
|
|
|
|
for _ in 0..5usize {
|
|
|
|
item.push(entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::Tool(
|
|
|
|
item::tool::Tool {
|
|
|
|
tool: tool
|
|
|
|
}
|
|
|
|
),
|
|
|
|
}).await.unwrap());
|
|
|
|
}
|
|
|
|
p1_inv.push(item::InventoryItemEntity::Stacked(item));
|
|
|
|
}*/
|
|
|
|
let inv = vec![
|
|
|
|
entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::TechniqueDisk(
|
|
|
|
item::tech::TechniqueDisk {
|
|
|
|
tech: item::tech::Technique::Foie,
|
|
|
|
level: 3,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
).await.unwrap(),
|
|
|
|
entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::TechniqueDisk(
|
|
|
|
item::tech::TechniqueDisk {
|
|
|
|
tech: item::tech::Technique::Barta,
|
|
|
|
level: 4,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
).await.unwrap(),
|
|
|
|
entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::TechniqueDisk(
|
|
|
|
item::tech::TechniqueDisk {
|
|
|
|
tech: item::tech::Technique::Zonde,
|
|
|
|
level: 5,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
).await.unwrap()
|
|
|
|
];
|
|
|
|
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inv)).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();
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), RecvShipPacket::Message(Message::new(GameMessage::PlayerUseItem(PlayerUseItem {
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
item_id: 0x10002,
|
|
|
|
})))).await.unwrap();
|
|
|
|
|
|
|
|
let characters = entity_gateway.get_characters_by_user(&user1).await.unwrap();
|
|
|
|
let char = characters[0].as_ref().unwrap();
|
|
|
|
|
|
|
|
assert_eq!(char.techs.techs.len(), 2);
|
|
|
|
assert_eq!(char.techs.techs.get(&item::tech::Technique::Foie).unwrap(), &TechLevel(3));
|
|
|
|
assert_eq!(char.techs.techs.get(&item::tech::Technique::Zonde).unwrap(), &TechLevel(5));
|
|
|
|
assert!(char.techs.techs.get(&item::tech::Technique::Barta).is_none());
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: tests for ALL ITEMS WOW
|
|
|
|
|
|
|
|
/*
|
|
|
|