You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
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::*;
|
|
|
|
#[async_std::test]
|
|
async fn test_mag_feed() {
|
|
let mut entity_gateway = InMemoryGateway::new();
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
|
|
|
entity_gateway.create_item(
|
|
item::NewItemEntity {
|
|
item: item::ItemDetail::Mag(
|
|
item::mag::Mag::baby_mag(0)
|
|
),
|
|
location: item::ItemLocation::Inventory {
|
|
character_id: char1.id,
|
|
slot: 0,
|
|
equipped: true,
|
|
}
|
|
}).await;
|
|
for _ in 0..7 {
|
|
entity_gateway.create_item(
|
|
item::NewItemEntity {
|
|
item: item::ItemDetail::Tool(
|
|
item::tool::Tool {
|
|
tool: item::tool::ToolType::Monomate,
|
|
}
|
|
),
|
|
location: item::ItemLocation::Inventory {
|
|
character_id: char1.id,
|
|
slot: 1,
|
|
equipped: false,
|
|
}
|
|
}).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;
|
|
create_room(&mut ship, ClientId(1), "room", "").await;
|
|
|
|
for _ in 0..7 {
|
|
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerFeedMag(PlayerFeedMag {
|
|
client: 0,
|
|
target: 0,
|
|
mag_id: 0x10000,
|
|
item_id: 0x10001,
|
|
})))).await.unwrap().for_each(drop);
|
|
}
|
|
|
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
|
let mag = p1_items.get(0).unwrap();
|
|
match &mag.item {
|
|
item::ItemDetail::Mag(mag) => {
|
|
assert!(mag.level() == 7);
|
|
assert!(mag.def() == 5);
|
|
assert!(mag.pow() == 2);
|
|
assert!(mag.dex() == 0);
|
|
assert!(mag.mind() == 0);
|
|
}
|
|
_ => panic!()
|
|
}
|
|
}
|