Compare commits
merge into: jake:master
jake:andy/add-patch-log-dir
jake:andy/clamp-mag-feed
jake:andy/directories
jake:andy/map-objects
jake:andy/update-rust
jake:expsteal
jake:fuckin_andy_making_me_do_this_now
jake:kill_counters
jake:map_objects
jake:master
jake:morfin/test
jake:move_stuff_to_libpso
jake:pbs
jake:presents
jake:sendgc
jake:set_char_exp
jake:teams
jake:techs
jake:traps
jake:unitxt
pull from: jake:presents
jake:andy/add-patch-log-dir
jake:andy/clamp-mag-feed
jake:andy/directories
jake:andy/map-objects
jake:andy/update-rust
jake:expsteal
jake:fuckin_andy_making_me_do_this_now
jake:kill_counters
jake:map_objects
jake:master
jake:morfin/test
jake:move_stuff_to_libpso
jake:pbs
jake:presents
jake:sendgc
jake:set_char_exp
jake:teams
jake:techs
jake:traps
jake:unitxt
14 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
andy | c8b9564009 |
random formatting and ordering changes
|
4 years ago |
andy | b6cc50360a |
TOOD -> TODO
|
4 years ago |
andy | a238ae3846 |
add remaining modifiers for item types and fix presents?
|
4 years ago |
andy | b29bb473d5 |
more tests for unwrapping equips
|
4 years ago |
andy | 9e8e10d434 |
finally added a present test. rename item_actions to menu_actions
|
4 years ago |
andy | e774b9c950 |
oops forgot mags
|
4 years ago |
andy | fc84db5393 |
put armors in presents. apply modifiers for armors, shields, units, mags. remove prints
|
4 years ago |
andy | ba0b827c24 |
modifiers are for the boys
|
4 years ago |
andy | 637e182224 |
andy stop touching things pls
|
4 years ago |
andy | 98b2ebfdd8 |
wrap everything except armours
|
4 years ago |
andy | 7e9b989078 |
holy shit unwrapping presents finally works for weapons
|
4 years ago |
andy | c9160f177d |
fix tests
|
4 years ago |
andy | a77b9874ff |
initial present stuff
|
4 years ago |
andy | fe0f7ba41e |
initial wrapping stuff
|
4 years ago |
46 changed files with 1542 additions and 339 deletions
-
13data/quests.toml
-
77src/bin/main.rs
-
27src/entity/gateway/entitygateway.rs
-
136src/entity/gateway/inmemory.rs
-
26src/entity/gateway/postgres/migrations/V0001__initial.sql
-
277src/entity/gateway/postgres/models.rs
-
131src/entity/gateway/postgres/postgres.rs
-
30src/entity/item/armor.rs
-
37src/entity/item/esweapon.rs
-
58src/entity/item/mag.rs
-
73src/entity/item/mod.rs
-
28src/entity/item/shield.rs
-
21src/entity/item/tech.rs
-
26src/entity/item/tool.rs
-
31src/entity/item/unit.rs
-
48src/entity/item/weapon.rs
-
4src/login/character.rs
-
5src/ship/drops/generic_armor.rs
-
5src/ship/drops/generic_shield.rs
-
2src/ship/drops/generic_unit.rs
-
5src/ship/drops/generic_weapon.rs
-
5src/ship/drops/rare_drop_table.rs
-
6src/ship/drops/tech_table.rs
-
3src/ship/drops/tool_table.rs
-
123src/ship/items/inventory.rs
-
256src/ship/items/manager.rs
-
2src/ship/map/area.rs
-
8src/ship/map/enemy.rs
-
4src/ship/map/maps.rs
-
2src/ship/map/object.rs
-
2src/ship/map/variant.rs
-
2src/ship/packet/builder/message.rs
-
11src/ship/packet/handler/message.rs
-
2src/ship/packet/handler/quest.rs
-
2src/ship/ship.rs
-
3src/ship/shops/armor.rs
-
15src/ship/shops/tool.rs
-
1src/ship/shops/weapon.rs
-
35tests/test_bank.rs
-
289tests/test_item_modifiers.rs
-
18tests/test_item_pickup.rs
-
13tests/test_item_use.rs
-
3tests/test_mags.rs
-
9tests/test_menu_actions.rs
-
2tests/test_rooms.rs
-
5tests/test_shops.rs
@ -0,0 +1,289 @@ |
|||
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::RedGreen),
|
|||
}),
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
assert!(wrapped_item.item.as_client_bytes() == [0x00,0x01,0x00,0x05,0xDA,0x05,0x03,0x14,0x05,0x1E,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
|
|||
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() {
|
|||
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::Armor(item::armor::Armor {
|
|||
armor: item::armor::ArmorType::PerfectFrame,
|
|||
dfp: 3u8,
|
|||
evp: 2u8,
|
|||
slots: 4u8,
|
|||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
|||
}),
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
// slots should be untouched when wrapped regardless of wrapping paper colour
|
|||
assert!(wrapped_item.item.as_client_bytes() == [0x01,0x01,0x10,0x00,0x40,0x04,0x03,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
|
|||
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::Armor(armor) => {
|
|||
assert!(armor.as_bytes() == [0x01,0x01,0x10,0x00,0x00,0x04,0x03,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}).unwrap();
|
|||
}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_shield() {
|
|||
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::Shield(item::shield::Shield {
|
|||
shield: item::shield::ShieldType::CoreShield,
|
|||
dfp: 2u8,
|
|||
evp: 3u8,
|
|||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
|||
}),
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
assert!(wrapped_item.item.as_client_bytes() == [0x01,0x02,0x02,0x00,0x40,0x05,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
|
|||
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::Shield(shield) => {
|
|||
assert!(shield.as_bytes() == [0x01,0x02,0x02,0x00,0x00,0x00,0x02,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}).unwrap();
|
|||
}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_unit() {
|
|||
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::Unit(item::unit::Unit {
|
|||
unit: item::unit::UnitType::KnightPower,
|
|||
modifier: Some(item::unit::UnitModifier::MinusMinus),
|
|||
wrapping: Some(item::WrappingPaper::RedGreen), // 5
|
|||
}),
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
assert!(wrapped_item.item.as_client_bytes() == [0x01,0x03,0x00,0x00,0x40,0x05,0xFE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
|
|||
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::Unit(unit) => {
|
|||
assert!(unit.as_bytes() == [0x01,0x03,0x00,0x00,0x00,0x00,0xFE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}).unwrap();
|
|||
}
|
|||
|
|||
// mag cells are covered in test_mags.rs
|
|||
#[async_std::test]
|
|||
async fn test_unwrap_mag() {
|
|||
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::Mag(item::mag::Mag::wrapped_baby_mag(12)), //turquoise
|
|||
location: item::ItemLocation::Inventory{
|
|||
character_id: char1.id,
|
|||
}
|
|||
}).await.unwrap();
|
|||
|
|||
assert!(wrapped_item.item.as_client_bytes() == [0x02,0x00,0x00,0x00,0xF4,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x40,0x0C]); // item maker is wrong?
|
|||
|
|||
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::Mag(mag) => {
|
|||
assert!(mag.as_bytes() == [0x02,0x00,0x00,0x00,0xF4,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x0C]);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}).unwrap();
|
|||
}
|
|||
|
|||
// TODO: implement wrapping packet (message 0xD6) (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?
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue