Browse Source
Merge pull request 'bunch of small fixes' (#127) from make_actually_work into master
Merge pull request 'bunch of small fixes' (#127) from make_actually_work into master
Reviewed-on: #127pull/129/head
jake
2 years ago
55 changed files with 1140 additions and 686 deletions
-
6Cargo.lock
-
2Cargo.toml
-
6src/bin/main.rs
-
31src/common/mainloop/client.rs
-
96src/entity/character.rs
-
9src/entity/gateway/entitygateway.rs
-
17src/entity/gateway/inmemory.rs
-
9src/entity/gateway/postgres/migrations/V0004__meseta.sql
-
4src/entity/gateway/postgres/migrations/V0005__trade.sql
-
3src/entity/gateway/postgres/migrations/V0007__player_keyconfig.sql
-
5src/entity/gateway/postgres/migrations/V0008__playtime_not_null.sql
-
3src/entity/gateway/postgres/migrations/V0009__no_player_keyconfig.sql
-
2src/entity/gateway/postgres/migrations/V0010__char_create_timestamp.sql
-
18src/entity/gateway/postgres/models.rs
-
67src/entity/gateway/postgres/postgres.rs
-
2src/entity/item/mag.rs
-
4src/lib.rs
-
16src/login/character.rs
-
2src/login/login.rs
-
6src/patch/patch.rs
-
6src/ship/client.rs
-
88src/ship/drops/mod.rs
-
90src/ship/drops/rare_drop_table.rs
-
90src/ship/items/actions.rs
-
76src/ship/items/apply_item.rs
-
20src/ship/items/bank.rs
-
6src/ship/items/floor.rs
-
42src/ship/items/inventory.rs
-
32src/ship/items/state.rs
-
40src/ship/items/tasks.rs
-
26src/ship/location.rs
-
11src/ship/map/enemy.rs
-
134src/ship/map/maps.rs
-
6src/ship/map/mod.rs
-
11src/ship/packet/builder/lobby.rs
-
13src/ship/packet/builder/room.rs
-
2src/ship/packet/handler/auth.rs
-
10src/ship/packet/handler/communication.rs
-
53src/ship/packet/handler/direct_message.rs
-
16src/ship/packet/handler/lobby.rs
-
36src/ship/packet/handler/message.rs
-
41src/ship/packet/handler/quest.rs
-
41src/ship/packet/handler/room.rs
-
18src/ship/packet/handler/settings.rs
-
26src/ship/packet/handler/trade.rs
-
65src/ship/room.rs
-
44src/ship/ship.rs
-
3tests/common.rs
-
29tests/test_character.rs
-
133tests/test_exp_gain.rs
-
210tests/test_item_drop.rs
-
87tests/test_item_use.rs
-
2tests/test_rooms.rs
-
3tests/test_shops.rs
-
6tests/test_trade.rs
@ -1,5 +1,5 @@ |
|||
create table trades ( |
|||
id serial primary key not null, |
|||
character1 integer references character (id) not null, |
|||
character2 integer references character (id) not null, |
|||
character1 integer references player_character (id) not null, |
|||
character2 integer references player_character (id) not null |
|||
); |
@ -0,0 +1,3 @@ |
|||
alter table player_character |
|||
add keyboard_config bytea not null, |
|||
add gamepad_config bytea not null; |
@ -0,0 +1,5 @@ |
|||
alter table player_character |
|||
drop column playtime; |
|||
|
|||
alter table player_character |
|||
add playtime integer not null; |
@ -0,0 +1,3 @@ |
|||
alter table player_character |
|||
drop column keyboard_config, |
|||
drop column gamepad_config; |
@ -0,0 +1,2 @@ |
|||
alter table player_character |
|||
add created_at timestamptz default current_timestamp not null; |
@ -0,0 +1,210 @@ |
|||
use elseware::common::serverstate::{ClientId, ServerState};
|
|||
use elseware::entity::gateway::{EntityGateway, InMemoryGateway};
|
|||
use elseware::entity::character::SectionID;
|
|||
use elseware::common::leveltable::CharacterLevelTable;
|
|||
use elseware::ship::ship::{ShipServerState, SendShipPacket, RecvShipPacket};
|
|||
use elseware::ship::room::{Episode, Difficulty};
|
|||
use elseware::ship::monster::MonsterType;
|
|||
use elseware::ship::location::RoomId;
|
|||
use elseware::ship::drops::{DropTable, MonsterDropStats, MonsterDropType};
|
|||
use elseware::ship::drops::rare_drop_table::{RareDropTable, RareDropRate, RareDropItem};
|
|||
use elseware::ship::map::{Maps, MapVariant, MapArea, MapVariantMode, MapEnemy};
|
|||
use elseware::entity::item::weapon::WeaponType;
|
|||
|
|||
use libpso::packet::ship::*;
|
|||
use libpso::packet::messages::*;
|
|||
|
|||
#[path = "common.rs"]
|
|||
mod common;
|
|||
use common::*;
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_enemy_drops_item() {
|
|||
let mut entity_gateway = InMemoryGateway::default();
|
|||
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|||
|
|||
let mut ship = Box::new(ShipServerState::builder()
|
|||
.gateway(entity_gateway.clone())
|
|||
.map_builder(Box::new(|_room_mode, _event| {
|
|||
Maps::new(
|
|||
vec![MapVariant::new(MapArea::Forest2, MapVariantMode::Online)],
|
|||
vec![Some(MapEnemy::new(MonsterType::Hildebear, MapArea::Forest2))],
|
|||
Vec::new(),
|
|||
)
|
|||
}))
|
|||
.drop_table_builder(Box::new(|episode, difficulty, section_id| {
|
|||
DropTable::builder()
|
|||
.monster_stat(MonsterType::Hildebear, MonsterDropStats {
|
|||
dar: 100,
|
|||
drop_type: MonsterDropType::Weapon,
|
|||
min_meseta: 0,
|
|||
max_meseta: 0,
|
|||
})
|
|||
.rare_table(RareDropTable::builder()
|
|||
.rate(MonsterType::Hildebear, RareDropRate {
|
|||
rate: 1.0,
|
|||
item: RareDropItem::Weapon(WeaponType::DarkFlow)
|
|||
})
|
|||
.build(episode, difficulty, section_id))
|
|||
.build(episode, difficulty, section_id)
|
|||
}))
|
|||
.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;
|
|||
|
|||
let pkt = ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::RequestItem(RequestItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
map_area: 2,
|
|||
pt_index: 0,
|
|||
enemy_id: 0,
|
|||
x: 0.0,
|
|||
z: 0.0,
|
|||
y: 0.0,
|
|||
})))).await.unwrap();
|
|||
|
|||
match &pkt[0].1 {
|
|||
SendShipPacket::Message(Message{msg: GameMessage::ItemDrop(item_drop)}) => {
|
|||
assert_eq!(item_drop.item_id, 0x810001);
|
|||
assert_eq!(item_drop.item_bytes[1], 0x9D);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_enemy_drops_item_for_two_players() {
|
|||
let mut entity_gateway = InMemoryGateway::default();
|
|||
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|||
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
|
|||
|
|||
let mut ship = Box::new(ShipServerState::builder()
|
|||
.gateway(entity_gateway.clone())
|
|||
.map_builder(Box::new(|_room_mode, _event| {
|
|||
Maps::new(
|
|||
vec![MapVariant::new(MapArea::Forest2, MapVariantMode::Online)],
|
|||
vec![Some(MapEnemy::new(MonsterType::Hildebear, MapArea::Forest2))],
|
|||
Vec::new(),
|
|||
)
|
|||
}))
|
|||
.drop_table_builder(Box::new(|episode, difficulty, section_id| {
|
|||
DropTable::builder()
|
|||
.monster_stat(MonsterType::Hildebear, MonsterDropStats {
|
|||
dar: 100,
|
|||
drop_type: MonsterDropType::Weapon,
|
|||
min_meseta: 0,
|
|||
max_meseta: 0,
|
|||
})
|
|||
.rare_table(RareDropTable::builder()
|
|||
.rate(MonsterType::Hildebear, RareDropRate {
|
|||
rate: 1.0,
|
|||
item: RareDropItem::Weapon(WeaponType::DarkFlow)
|
|||
})
|
|||
.build(episode, difficulty, section_id))
|
|||
.build(episode, difficulty, section_id)
|
|||
}))
|
|||
.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(&mut ship, ClientId(1), "room", "").await;
|
|||
join_room(&mut ship, ClientId(2), 0).await;
|
|||
|
|||
let pkt = ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::RequestItem(RequestItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
map_area: 2,
|
|||
pt_index: 0,
|
|||
enemy_id: 0,
|
|||
x: 0.0,
|
|||
z: 0.0,
|
|||
y: 0.0,
|
|||
})))).await.unwrap();
|
|||
|
|||
assert_eq!(pkt[0].0, ClientId(1));
|
|||
match &pkt[0].1 {
|
|||
SendShipPacket::Message(Message{msg: GameMessage::ItemDrop(item_drop)}) => {
|
|||
assert_eq!(item_drop.item_id, 0x810001);
|
|||
assert_eq!(item_drop.item_bytes[1], 0x9D);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
assert_eq!(pkt[1].0, ClientId(2));
|
|||
match &pkt[1].1 {
|
|||
SendShipPacket::Message(Message{msg: GameMessage::ItemDrop(item_drop)}) => {
|
|||
assert_eq!(item_drop.item_id, 0x810002);
|
|||
assert_eq!(item_drop.item_bytes[1], 0x9D);
|
|||
},
|
|||
_ => panic!(),
|
|||
}
|
|||
}
|
|||
|
|||
#[async_std::test]
|
|||
async fn test_enemy_drops_item_for_two_players_and_pick_up() {
|
|||
let mut entity_gateway = InMemoryGateway::default();
|
|||
let (_user1, _char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|||
let (_user2, _char2) = new_user_character(&mut entity_gateway, "a2", "a", 1).await;
|
|||
|
|||
let mut ship = Box::new(ShipServerState::builder()
|
|||
.gateway(entity_gateway.clone())
|
|||
.map_builder(Box::new(|_room_mode, _event| {
|
|||
Maps::new(
|
|||
vec![MapVariant::new(MapArea::Forest2, MapVariantMode::Online)],
|
|||
vec![Some(MapEnemy::new(MonsterType::Hildebear, MapArea::Forest2))],
|
|||
Vec::new(),
|
|||
)
|
|||
}))
|
|||
.drop_table_builder(Box::new(|episode, difficulty, section_id| {
|
|||
DropTable::builder()
|
|||
.monster_stat(MonsterType::Hildebear, MonsterDropStats {
|
|||
dar: 100,
|
|||
drop_type: MonsterDropType::Weapon,
|
|||
min_meseta: 0,
|
|||
max_meseta: 0,
|
|||
})
|
|||
.rare_table(RareDropTable::builder()
|
|||
.rate(MonsterType::Hildebear, RareDropRate {
|
|||
rate: 1.0,
|
|||
item: RareDropItem::Weapon(WeaponType::DarkFlow)
|
|||
})
|
|||
.build(episode, difficulty, section_id))
|
|||
.build(episode, difficulty, section_id)
|
|||
}))
|
|||
.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(&mut ship, ClientId(1), "room", "").await;
|
|||
join_room(&mut ship, ClientId(2), 0).await;
|
|||
|
|||
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::RequestItem(RequestItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
map_area: 2,
|
|||
pt_index: 0,
|
|||
enemy_id: 0,
|
|||
x: 0.0,
|
|||
z: 0.0,
|
|||
y: 0.0,
|
|||
})))).await.unwrap();
|
|||
|
|||
ship.handle(ClientId(2), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
item_id: 0x810002,
|
|||
map_area: 0,
|
|||
unknown: [0; 3]
|
|||
})))).await.unwrap();
|
|||
|
|||
ship.handle(ClientId(1), RecvShipPacket::DirectMessage(DirectMessage::new(0, GameMessage::PickupItem(PickupItem {
|
|||
client: 0,
|
|||
target: 0,
|
|||
item_id: 0x810001,
|
|||
map_area: 0,
|
|||
unknown: [0; 3]
|
|||
})))).await.unwrap();
|
|||
|
|||
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue