jake
4 years ago
12 changed files with 894 additions and 57 deletions
-
3src/entity/item/mod.rs
-
107src/ship/items/manager.rs
-
23src/ship/packet/builder/message.rs
-
96src/ship/packet/handler/direct_message.rs
-
2src/ship/room.rs
-
46src/ship/ship.rs
-
71src/ship/shops/armor.rs
-
20src/ship/shops/mod.rs
-
74src/ship/shops/tool.rs
-
53src/ship/shops/weapon.rs
-
7tests/common.rs
-
449tests/test_shops.rs
@ -1,7 +1,21 @@ |
|||||
pub mod weapon;
|
|
||||
pub mod tool;
|
|
||||
pub mod armor;
|
|
||||
|
mod weapon;
|
||||
|
mod tool;
|
||||
|
mod armor;
|
||||
|
|
||||
|
use crate::entity::item::ItemDetail;
|
||||
|
|
||||
pub trait ShopItem {
|
pub trait ShopItem {
|
||||
fn price(&self) -> usize;
|
fn price(&self) -> usize;
|
||||
|
fn as_bytes(&self) -> [u8; 12];
|
||||
|
fn as_item(&self) -> ItemDetail;
|
||||
|
}
|
||||
|
|
||||
|
pub enum ShopType {
|
||||
|
Weapon,
|
||||
|
Tool,
|
||||
|
Armor
|
||||
}
|
}
|
||||
|
|
||||
|
pub use weapon::{WeaponShop, WeaponShopItem};
|
||||
|
pub use tool::{ToolShop, ToolShopItem};
|
||||
|
pub use armor::{ArmorShop, ArmorShopItem};
|
@ -0,0 +1,449 @@ |
|||||
|
use elseware::common::serverstate::{ClientId, ServerState};
|
||||
|
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
||||
|
use elseware::entity::item;
|
||||
|
use elseware::ship::ship::{ShipServerState, RecvShipPacket, SendShipPacket};
|
||||
|
use elseware::ship::room::Difficulty;
|
||||
|
|
||||
|
use libpso::packet::ship::*;
|
||||
|
use libpso::packet::messages::*;
|
||||
|
|
||||
|
#[path = "common.rs"]
|
||||
|
mod common;
|
||||
|
use common::*;
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_opens_weapon_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 1
|
||||
|
})))).await.unwrap().collect::<Vec<_>>();
|
||||
|
|
||||
|
assert_eq!(packets.len(), 1);
|
||||
|
match &packets[0].1 {
|
||||
|
SendShipPacket::Message(Message {msg: GameMessage::ShopList(shop_list)}) => {
|
||||
|
assert_eq!(shop_list.items.len(), 16)
|
||||
|
}
|
||||
|
_ => panic!("")
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_opens_tool_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 0
|
||||
|
})))).await.unwrap().collect::<Vec<_>>();
|
||||
|
|
||||
|
assert_eq!(packets.len(), 1);
|
||||
|
match &packets[0].1 {
|
||||
|
SendShipPacket::Message(Message {msg: GameMessage::ShopList(shop_list)}) => {
|
||||
|
assert_eq!(shop_list.items.len(), 18)
|
||||
|
}
|
||||
|
_ => panic!("")
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_opens_armor_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 2
|
||||
|
})))).await.unwrap().collect::<Vec<_>>();
|
||||
|
|
||||
|
assert_eq!(packets.len(), 1);
|
||||
|
match &packets[0].1 {
|
||||
|
SendShipPacket::Message(Message {msg: GameMessage::ShopList(shop_list)}) => {
|
||||
|
assert_eq!(shop_list.items.len(), 21)
|
||||
|
}
|
||||
|
_ => panic!("")
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_buys_from_weapon_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 1
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 1,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert!(c1.meseta < 999999);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 1);
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_buys_from_tool_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 0,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert!(c1.meseta < 999999);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 1);
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_buys_multiple_from_tool_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 0,
|
||||
|
shop_index: 0,
|
||||
|
amount: 5,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert!(c1.meseta < 999999);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 5);
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_buys_from_armor_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 2
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 2,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert!(c1.meseta < 999999);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 1);
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_sells_to_shop() {
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_other_clients_see_purchase() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).await;
|
||||
|
|
||||
|
let mut ship = ShipServerState::builder()
|
||||
|
.gateway(entity_gateway.clone())
|
||||
|
.build();
|
||||
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
||||
|
join_lobby(&mut ship, ClientId(1)).await;
|
||||
|
join_lobby(&mut ship, ClientId(2)).await;
|
||||
|
create_room_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
join_room(&mut ship, ClientId(2), 0).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 1
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 1,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().collect::<Vec<_>>();
|
||||
|
|
||||
|
assert_eq!(packets.len(), 1);
|
||||
|
assert_eq!(packets[0].0, ClientId(2));
|
||||
|
match &packets[0].1 {
|
||||
|
SendShipPacket::Message(Message{msg: GameMessage::CreateItem(_)}) => {},
|
||||
|
_ => panic!(""),
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_other_clients_see_stacked_purchase() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (_user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).await;
|
||||
|
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: 0,
|
||||
|
equipped: false,
|
||||
|
}
|
||||
|
}).await;
|
||||
|
|
||||
|
let mut ship = ShipServerState::builder()
|
||||
|
.gateway(entity_gateway.clone())
|
||||
|
.build();
|
||||
|
log_in_char(&mut ship, ClientId(1), "a1", "a").await;
|
||||
|
log_in_char(&mut ship, ClientId(2), "a2", "a").await;
|
||||
|
join_lobby(&mut ship, ClientId(1)).await;
|
||||
|
join_lobby(&mut ship, ClientId(2)).await;
|
||||
|
create_room_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
join_room(&mut ship, ClientId(2), 0).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 1
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 1,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().collect::<Vec<_>>();
|
||||
|
|
||||
|
assert_eq!(packets.len(), 1);
|
||||
|
assert_eq!(packets[0].0, ClientId(2));
|
||||
|
match &packets[0].1 {
|
||||
|
SendShipPacket::Message(Message{msg: GameMessage::CreateItem(_)}) => {},
|
||||
|
_ => panic!(""),
|
||||
|
}
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_buying_item_without_enough_mseseta() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 1
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
let packets = ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 1,
|
||||
|
shop_index: 0,
|
||||
|
amount: 1,
|
||||
|
unknown1: 0,
|
||||
|
})))).await;
|
||||
|
|
||||
|
assert!(packets.is_err());
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert_eq!(c1.meseta, 0);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 0);
|
||||
|
}
|
||||
|
|
||||
|
#[async_std::test]
|
||||
|
async fn test_player_double_buys_from_tool_shop() {
|
||||
|
let mut entity_gateway = InMemoryGateway::new();
|
||||
|
|
||||
|
let (user1, mut char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
|
||||
|
char1.exp = 80000000;
|
||||
|
char1.meseta = 999999;
|
||||
|
entity_gateway.save_character(&char1).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_with_difficulty(&mut ship, ClientId(1), "room", "", Difficulty::Ultimate).await;
|
||||
|
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::ShopRequest(ShopRequest {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
shop_type: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10000,
|
||||
|
shop_type: 0,
|
||||
|
shop_index: 0,
|
||||
|
amount: 3,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10001,
|
||||
|
shop_type: 0,
|
||||
|
shop_index: 1,
|
||||
|
amount: 2,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
ship.handle(ClientId(1), &RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::BuyItem(BuyItem {
|
||||
|
client: 255,
|
||||
|
target: 255,
|
||||
|
item_id: 0x10002,
|
||||
|
shop_type: 0,
|
||||
|
shop_index: 0,
|
||||
|
amount: 4,
|
||||
|
unknown1: 0,
|
||||
|
})))).await.unwrap().for_each(drop);
|
||||
|
|
||||
|
let characters1 = entity_gateway.get_characters_by_user(&user1).await;
|
||||
|
let c1 = characters1.get(0).as_ref().unwrap().as_ref().unwrap();
|
||||
|
assert!(c1.meseta < 999999);
|
||||
|
let p1_items = entity_gateway.get_items_by_character(&char1).await;
|
||||
|
assert_eq!(p1_items.len(), 10);
|
||||
|
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue