|
|
@ -667,17 +667,79 @@ async fn test_exp_steal_multihit_penalty() { |
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_exp_steal_doesnt_exceed_100p() {
|
|
|
|
assert!(false)
|
|
|
|
async fn test_cannot_steal_exp_from_boss() {
|
|
|
|
let mut entity_gateway = InMemoryGateway::default();
|
|
|
|
|
|
|
|
let (_user1, char1) = new_user_character(&mut entity_gateway, "a1", "a", 1).await;
|
|
|
|
|
|
|
|
let mut p1_inv = Vec::new();
|
|
|
|
p1_inv.push(entity_gateway.create_item(
|
|
|
|
item::NewItemEntity {
|
|
|
|
item: item::ItemDetail::Weapon(
|
|
|
|
item::weapon::Weapon {
|
|
|
|
weapon: item::weapon::WeaponType::Raygun,
|
|
|
|
grind: 5,
|
|
|
|
special: Some(item::weapon::WeaponSpecial::Kings),
|
|
|
|
attrs: [Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Hit, value: 100}),
|
|
|
|
Some(item::weapon::WeaponAttribute{attr: item::weapon::Attribute::Dark, value: 30}),
|
|
|
|
None,],
|
|
|
|
tekked: true,
|
|
|
|
}
|
|
|
|
),
|
|
|
|
}).await.unwrap());
|
|
|
|
|
|
|
|
let equipped = item::EquippedEntity {
|
|
|
|
weapon: Some(p1_inv[0].id),
|
|
|
|
armor: None,
|
|
|
|
shield: None,
|
|
|
|
unit: [None; 4],
|
|
|
|
mag: None,
|
|
|
|
};
|
|
|
|
entity_gateway.set_character_equips(&char1.id, &equipped).await.unwrap();
|
|
|
|
entity_gateway.set_character_inventory(&char1.id, &item::InventoryEntity::new(p1_inv)).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;
|
|
|
|
|
|
|
|
let enemy_id = {
|
|
|
|
let room = ship.blocks.0[0].rooms[0].as_ref().unwrap();
|
|
|
|
let enemy_id = (0..).filter_map(|i| {
|
|
|
|
room.maps.enemy_by_id(i).ok().and_then(|enemy| {
|
|
|
|
if enemy.monster == MonsterType::Dragon {
|
|
|
|
Some(i)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).next().unwrap();
|
|
|
|
enemy_id
|
|
|
|
};
|
|
|
|
|
|
|
|
ship.handle(ClientId(1), &RecvShipPacket::Message(Message::new(GameMessage::ExperienceSteal(ExperienceSteal{
|
|
|
|
client: 0,
|
|
|
|
target: 0,
|
|
|
|
client2: enemy_id as u8,
|
|
|
|
target2: 16,
|
|
|
|
enemy_id: enemy_id as u16,
|
|
|
|
})))).await.unwrap().for_each(drop);
|
|
|
|
|
|
|
|
let c1 = ship.clients.get(&ClientId(1)).unwrap();
|
|
|
|
assert!(c1.character.exp == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_each_client_can_steal_full_exp_from_same_enemy() {
|
|
|
|
async fn test_exp_steal_doesnt_exceed_100p() {
|
|
|
|
assert!(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_std::test]
|
|
|
|
async fn test_cannot_steal_exp_from_boss() {
|
|
|
|
async fn test_each_client_can_steal_full_exp_from_same_enemy() {
|
|
|
|
assert!(false)
|
|
|
|
}
|
|
|
|
|