Browse Source

finally added a present test. rename item_actions to menu_actions

presents
andy 4 years ago
parent
commit
9e8e10d434
  1. 101
      tests/test_item_modifiers.rs
  2. 3
      tests/test_menu_actions.rs

101
tests/test_item_modifiers.rs

@ -0,0 +1,101 @@
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::*;
// unwrap presents
#[async_std::test]
async fn test_unwrap_weapon() {
let mut entity_gateway = InMemoryGateway::new();
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a").await;
let wrapped_item = entity_gateway.create_item(
item::NewItemEntity {
item: item::ItemDetail::Weapon(item::weapon::Weapon {
weapon: item::weapon::WeaponType::Saber,
special: Some(item::weapon::WeaponSpecial::Burning),
grind: 5,
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Machine, value: 20}),
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 30}),
None],
tekked: false,
wrapping: Some(item::WrappingPaper::Red_Green),
}),
location: item::ItemLocation::Inventory{
character_id: char1.id,
}
}).await.unwrap();
println!("created item: {:?}", wrapped_item);
let mut inventory = Vec::<item::ItemEntity>::new();
inventory.push(wrapped_item.into());
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(inventory)).await.unwrap();
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_room(&mut ship, ClientId(1), "room", "").await;
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::PlayerUseItem(PlayerUseItem {
client: 0,
target: 0,
item_id: 0x10000,
})))).await.unwrap().for_each(drop);
let inventory_items = entity_gateway.get_character_inventory(&char1.id).await.unwrap();
inventory_items.items[0].with_individual(|item| {
match &item.item {
item::ItemDetail::Weapon(weapon) => {
assert!(weapon.as_bytes() == [0x00, 0x01, 0x00, 0x05, 0x9A, 0x00, 0x03, 0x14, 0x05, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
},
_ => panic!(),
}
}).unwrap();
}
#[async_std::test]
async fn test_unwrap_armor() {}
#[async_std::test]
async fn test_unwrap_shield() {}
#[async_std::test]
async fn test_unwrap_unit() {}
// mag cells are covered in test_mags.rs
#[async_std::test]
async fn test_unwrap_mag() {}
// TODO: implement wrapping packet (gallons shop quest)
// wrap presents
#[async_std::test]
async fn test_wrap_weapon() {}
#[async_std::test]
async fn test_wrap_armor() {}
#[async_std::test]
async fn test_wrap_shield() {}
#[async_std::test]
async fn test_wrap_unit() {}
// mag cells are covered in test_mags.rs
#[async_std::test]
async fn test_wrap_mag() {}
// item combinations?

3
tests/test_item_actions.rs → tests/test_menu_actions.rs

@ -25,6 +25,7 @@ async fn test_equip_unit_from_equip_menu() {
dfp: 0,
evp: 0,
slots: 4,
wrapping: None,
}),
location: item::ItemLocation::Inventory {
character_id: char1.id,
@ -113,6 +114,7 @@ async fn test_unequip_armor_with_units() {
dfp: 0,
evp: 0,
slots: 4,
wrapping: None,
}),
location: item::ItemLocation::Inventory {
character_id: char1.id,
@ -192,6 +194,7 @@ async fn test_sort_items() {
dfp: 0,
evp: 0,
slots: 4,
wrapping: None,
}),
location: item::ItemLocation::Inventory {
character_id: char1.id,
Loading…
Cancel
Save