From fe472eaae218c3812ac9d6b906495e5592e3c21d Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 29 Jan 2023 16:34:29 -0700 Subject: [PATCH] lvl value in level up pkt is 0-based --- src/ship/packet/handler/message.rs | 2 +- tests/test_exp_gain.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 36c97d6..f4e4d69 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -59,7 +59,7 @@ where 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 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() .map(move |c| { (c.client, SendShipPacket::Message(Message::new(GameMessage::PlayerLevelUp(level_up_pkt.clone())))) diff --git a/tests/test_exp_gain.rs b/tests/test_exp_gain.rs index 465f949..0317e9d 100644 --- a/tests/test_exp_gain.rs +++ b/tests/test_exp_gain.rs @@ -81,7 +81,7 @@ async fn test_character_levels_up() { last_hitter: 1, })))).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(); 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, })))).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 { assert!(3000 == client.character.exp);