Browse Source

lvl value in level up pkt is 0-based

pull/127/head
jake 2 years ago
parent
commit
fe472eaae2
  1. 2
      src/ship/packet/handler/message.rs
  2. 4
      tests/test_exp_gain.rs

2
src/ship/packet/handler/message.rs

@ -59,7 +59,7 @@ where
let (_, before_stats) = LEVEL_TABLE.get_stats_from_exp(char_class, exp); let (_, before_stats) = LEVEL_TABLE.get_stats_from_exp(char_class, exp);
let (after_level, after_stats) = LEVEL_TABLE.get_stats_from_exp(char_class, exp + exp_gain); let (after_level, after_stats) = LEVEL_TABLE.get_stats_from_exp(char_class, exp + exp_gain);
let level_up_pkt = builder::message::character_leveled_up(area_client, after_level, before_stats, after_stats);
let level_up_pkt = builder::message::character_leveled_up(area_client, after_level-1, before_stats, after_stats);
exp_pkts.extend(clients_in_area.into_iter() exp_pkts.extend(clients_in_area.into_iter()
.map(move |c| { .map(move |c| {
(c.client, SendShipPacket::Message(Message::new(GameMessage::PlayerLevelUp(level_up_pkt.clone())))) (c.client, SendShipPacket::Message(Message::new(GameMessage::PlayerLevelUp(level_up_pkt.clone()))))

4
tests/test_exp_gain.rs

@ -81,7 +81,7 @@ async fn test_character_levels_up() {
last_hitter: 1, last_hitter: 1,
})))).await.unwrap(); })))).await.unwrap();
assert!(matches!(levelup_pkt[1].1, SendShipPacket::Message(Message {msg: GameMessage::PlayerLevelUp(PlayerLevelUp {lvl: 2, ..})})));
assert!(matches!(levelup_pkt[1].1, SendShipPacket::Message(Message {msg: GameMessage::PlayerLevelUp(PlayerLevelUp {lvl: 1, ..})})));
let leveltable = CharacterLevelTable::default(); let leveltable = CharacterLevelTable::default();
ship.clients.with(ClientId(1), |client| Box::pin(async move { ship.clients.with(ClientId(1), |client| Box::pin(async move {
@ -118,7 +118,7 @@ async fn test_character_levels_up_multiple_times() {
last_hitter: 1, last_hitter: 1,
})))).await.unwrap(); })))).await.unwrap();
assert!(matches!(levelup_pkt[1].1, SendShipPacket::Message(Message {msg: GameMessage::PlayerLevelUp(PlayerLevelUp {lvl: 8, ..})})));
assert!(matches!(levelup_pkt[1].1, SendShipPacket::Message(Message {msg: GameMessage::PlayerLevelUp(PlayerLevelUp {lvl: 7, ..})})));
ship.clients.with(ClientId(1), |client| Box::pin(async move { ship.clients.with(ClientId(1), |client| Box::pin(async move {
assert!(3000 == client.character.exp); assert!(3000 == client.character.exp);

Loading…
Cancel
Save