|
|
/* TODO:
1. test to check if sjs/lame/limiter drop with Some() kill counter enabled
2. test to make sure other items drop with None kill counter
3. test kill counters get incremented per kill
4. test unsealing item: - client item id does not change
- unsealed item no longer has kill counter
5. test reject unsealing item if not enough kills (can this even happen?)
*/
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::{SectionID};
use elseware::ship::room::{Difficulty};
use elseware::ship::map::area::{MapArea};
use elseware::ship::monster::{MonsterType};
use libpso::packet::ship::*;
use libpso::packet::messages::*;
#[path = "common.rs"]
mod common;
use common::*;
#[async_std::test]
async fn test_item_drops_with_kill_counter() {
let mut entity_gateway = InMemoryGateway::default();
let (_user1, _char1) = new_user_character_with_sid(&mut entity_gateway, "a1", "a", SectionID::Skyly).await;
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_ep2_room_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
// ship.handle(ClientId(1), &RecvShipPacket()).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerWarpingToFloor(PlayerWarpingToFloor{
// client: 0,
// target: 0,
// area: 9, // seaside
// data: 0,
// })))).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerWarping(PlayerWarping{
// client: 0,
// target: 0,
// })))).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerLoadedIn(PlayerLoadedIn{
// client: 0,
// target: 0,
// unknown1: [0,0],
// rotation: 0,
// area: 9,
// room: 1,
// x: 100.0,
// y: 10.0,
// z: -20.0,
// })))).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerChangedMap2(PlayerChangedMap2{
// client: 0,
// target: 0,
// map_area: 9,
// _unknown1: 0,
// })))).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSpawnedIntoArea(PlayerSpawnedIntoArea{
// client: 0,
// target: 0,
// })))).await.unwrap().for_each(drop);
// ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDoneChangingMap(PlayerDoneChangingMap{
// client: 0,
// target: 0,
// })))).await.unwrap().for_each(drop);
let room = ship.blocks.0[0].rooms[0].as_mut().unwrap();
room.toggle_redbox_mode(); // enable redbox mode for sjs
println!("room redbox mode: {:?}", room.redbox);
println!("room.mode: {:?}", room.mode);
println!("killing gigue for sjs!");
let gigue_id = room.maps.get_enemy_id_by_monster_type(MonsterType::GiGue).unwrap();
println!("found gigue id: {:?}!", gigue_id);
let pkts = ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::RequestItem(RequestItem {
client: 0,
target: 0,
map_area: 9, // seaside
pt_index: 55, // gigue ?
enemy_id: gigue_id,
x: 0.0,
y: 0.0,
z: 0.0,
}))))
.await
.unwrap()
.collect::<Vec<_>>(); // this should return 1 packet (ItemDrop)?
println!("packets returned: {:?}", pkts);
assert!(false);
}
// #[async_std::test]
// async fn test_all_equipped_kill_counters_increase_per_kill() {
// let mut entity_gateway = InMemoryGateway::default();
// let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
// }
// #[async_std::test]
// async fn test_non_equipped_kill_counter_does_not_increase() {
// let mut entity_gateway = InMemoryGateway::default();
// let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
// }
// #[async_std::test]
// async fn test_kill_counter_increase_only_for_final_hit() { // don't share kills among players
// let mut entity_gateway = InMemoryGateway::default();
// let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
// }
|