jake
2 years ago
4 changed files with 223 additions and 20 deletions
-
76src/ship/drops/mod.rs
-
70src/ship/drops/rare_drop_table.rs
-
1src/ship/packet/handler/direct_message.rs
-
76tests/test_item_drop.rs
@ -0,0 +1,76 @@ |
|||
use elseware::common::serverstate::{ClientId, ServerState};
|
|||
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|||
use elseware::entity::character::SectionID;
|
|||
use elseware::common::leveltable::CharacterLevelTable;
|
|||
use elseware::ship::ship::{ShipServerState, SendShipPacket, RecvShipPacket};
|
|||
use elseware::ship::room::{Episode, Difficulty};
|
|||
use elseware::ship::monster::MonsterType;
|
|||
use elseware::ship::location::RoomId;
|
|||
use elseware::ship::drops::{DropTable, MonsterDropStats, MonsterDropType};
|
|||
use elseware::ship::drops::rare_drop_table::{RareDropTable, RareDropRate, RareDropItem};
|
|||
use elseware::ship::map::{Maps, MapVariant, MapArea, MapVariantMode, MapEnemy};
|
|||
use elseware::entity::item::weapon::WeaponType;
|
|||
|
|||
use libpso::packet::ship::*;
|
|||
use libpso::packet::messages::*;
|
|||
|
|||
#[path = "common.rs"]
|
|||
mod common;
|
|||
use common::*;
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_enemy_drops_item() {
|
|||
let mut entity_gateway = InMemoryGateway::default();
|
|||
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|||
|
|||
let mut ship = Box::new(ShipServerState::builder()
|
|||
.gateway(entity_gateway.clone())
|
|||
.map_builder(Box::new(|_room_mode, _event| {
|
|||
Maps::new(
|
|||
vec![MapVariant::new(MapArea::Forest2, MapVariantMode::Online)],
|
|||
vec![Some(MapEnemy::new(MonsterType::Hildebear, MapArea::Forest2))],
|
|||
Vec::new(),
|
|||
)
|
|||
}))
|
|||
.drop_table_builder(Box::new(|episode, difficulty, section_id| {
|
|||
DropTable::builder()
|
|||
.monster_stat(MonsterType::Hildebear, MonsterDropStats {
|
|||
dar: 100,
|
|||
drop_type: MonsterDropType::Weapon,
|
|||
min_meseta: 0,
|
|||
max_meseta: 0,
|
|||
})
|
|||
.rare_table(RareDropTable::builder()
|
|||
.rate(MonsterType::Hildebear, RareDropRate {
|
|||
rate: 1.0,
|
|||
item: RareDropItem::Weapon(WeaponType::DarkFlow)
|
|||
})
|
|||
.build(episode, difficulty, section_id))
|
|||
.build(episode, difficulty, section_id)
|
|||
}))
|
|||
.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;
|
|||
|
|||
let pkt = ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::RequestItem(RequestItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
map_area: 2,
|
|||
pt_index: 0,
|
|||
enemy_id: 0,
|
|||
x: 0.0,
|
|||
z: 0.0,
|
|||
y: 0.0,
|
|||
})))).await.unwrap();
|
|||
|
|||
match &pkt[0].1 {
|
|||
SendShipPacket::Message(Message{msg: GameMessage::ItemDrop(item_drop)}) => {
|
|||
assert_eq!(item_drop.item_id, 0x810001);
|
|||
assert_eq!(item_drop.item_bytes[1], 0x9D);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
|
|||
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue