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.

131 lines
4.6 KiB

  1. /* TODO:
  2. 1. test to check if sjs/lame/limiter drop with Some() kill counter enabled
  3. 2. test to make sure other items drop with None kill counter
  4. 3. test kill counters get incremented per kill
  5. 4. test unsealing item:
  6. - client item id does not change
  7. - unsealed item no longer has kill counter
  8. 5. test reject unsealing item if not enough kills (can this even happen?)
  9. */
  10. use elseware::common::serverstate::{ClientId, ServerState};
  11. use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
  12. use elseware::entity::item;
  13. use elseware::ship::ship::{ShipServerState, RecvShipPacket};
  14. use elseware::entity::character::{SectionID};
  15. use elseware::ship::room::{Difficulty};
  16. use elseware::ship::map::area::{MapArea};
  17. use elseware::ship::monster::{MonsterType};
  18. use libpso::packet::ship::*;
  19. use libpso::packet::messages::*;
  20. #[path = "common.rs"]
  21. mod common;
  22. use common::*;
  23. #[async_std::test]
  24. async fn test_item_drops_with_kill_counter() {
  25. let mut entity_gateway = InMemoryGateway::default();
  26. let (_user1, _char1) = new_user_character_with_sid(&mut entity_gateway, "a1", "a", SectionID::Skyly).await;
  27. let mut ship = Box::new(ShipServerState::builder()
  28. .gateway(entity_gateway.clone())
  29. .build());
  30. log_in_char(&mut ship, ClientId(1), "a1", "a").await;
  31. join_lobby(&mut ship, ClientId(1)).await;
  32. create_ep2_room_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
  33. // ship.handle(ClientId(1), &RecvShipPacket()).await.unwrap().for_each(drop);
  34. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerWarpingToFloor(PlayerWarpingToFloor{
  35. // client: 0,
  36. // target: 0,
  37. // area: 9, // seaside
  38. // data: 0,
  39. // })))).await.unwrap().for_each(drop);
  40. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerWarping(PlayerWarping{
  41. // client: 0,
  42. // target: 0,
  43. // })))).await.unwrap().for_each(drop);
  44. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerLoadedIn(PlayerLoadedIn{
  45. // client: 0,
  46. // target: 0,
  47. // unknown1: [0,0],
  48. // rotation: 0,
  49. // area: 9,
  50. // room: 1,
  51. // x: 100.0,
  52. // y: 10.0,
  53. // z: -20.0,
  54. // })))).await.unwrap().for_each(drop);
  55. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerChangedMap2(PlayerChangedMap2{
  56. // client: 0,
  57. // target: 0,
  58. // map_area: 9,
  59. // _unknown1: 0,
  60. // })))).await.unwrap().for_each(drop);
  61. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerSpawnedIntoArea(PlayerSpawnedIntoArea{
  62. // client: 0,
  63. // target: 0,
  64. // })))).await.unwrap().for_each(drop);
  65. // ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerDoneChangingMap(PlayerDoneChangingMap{
  66. // client: 0,
  67. // target: 0,
  68. // })))).await.unwrap().for_each(drop);
  69. let room = ship.blocks.0[0].rooms[0].as_mut().unwrap();
  70. room.toggle_redbox_mode(); // enable redbox mode for sjs
  71. println!("room redbox mode: {:?}", room.redbox);
  72. println!("room.mode: {:?}", room.mode);
  73. println!("killing gigue for sjs!");
  74. let gigue_id = room.maps.get_enemy_id_by_monster_type(MonsterType::GiGue).unwrap();
  75. println!("found gigue id: {:?}!", gigue_id);
  76. let pkts = ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::RequestItem(RequestItem {
  77. client: 0,
  78. target: 0,
  79. map_area: 9, // seaside
  80. pt_index: 55, // gigue ?
  81. enemy_id: gigue_id,
  82. x: 0.0,
  83. y: 0.0,
  84. z: 0.0,
  85. }))))
  86. .await
  87. .unwrap()
  88. .collect::<Vec<_>>(); // this should return 1 packet (ItemDrop)?
  89. println!("packets returned: {:?}", pkts);
  90. assert!(false);
  91. }
  92. // #[async_std::test]
  93. // async fn test_all_equipped_kill_counters_increase_per_kill() {
  94. // let mut entity_gateway = InMemoryGateway::default();
  95. // let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
  96. // }
  97. // #[async_std::test]
  98. // async fn test_non_equipped_kill_counter_does_not_increase() {
  99. // let mut entity_gateway = InMemoryGateway::default();
  100. // let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
  101. // }
  102. // #[async_std::test]
  103. // async fn test_kill_counter_increase_only_for_final_hit() { // don't share kills among players
  104. // let mut entity_gateway = InMemoryGateway::default();
  105. // let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
  106. // }