Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Combat and Game classes to establish clearer boundaries and reduce coupling between combat logic and game orchestration while preserving exact runtime behavior.
- Moved pure combat helpers from Game to Combat class under an anonymous namespace with minimal static entry points
- Created InternalGame helpers for block/reflect processing and string utilities within Game
- Changed
applyImbuementElementalDamagesignature from returning CombatDamage to in-place update with void return
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/game/game.hpp | Removed combat helper method declarations that moved to Combat class |
| src/game/game.cpp | Added InternalGame namespace helpers and refactored to use Combat static methods |
| src/creatures/combat/combat.hpp | Added static method declarations for moved combat helpers |
| src/creatures/combat/combat.cpp | Implemented moved combat helpers with anonymous namespace organization |
Comments suppressed due to low confidence (1)
src/game/game.cpp:1
- There appear to be duplicate calls to
player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)on lines 1933 and 1934. This will send the same cancel message twice to the player.
/**
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| void buildMessageAsSpectator( | ||
| const std::shared_ptr<Creature> &attacker, const std::shared_ptr<Creature> &target, const CombatDamage &damage, | ||
| const std::shared_ptr<Player> &targetPlayer, TextMessage &message, std::stringstream &ss, | ||
| const std::string &damageString, std::string &spectatorMessage | ||
| const std::shared_ptr<Player> &targetPlayer, TextMessage &message, const std::string &damageString, std::string &spectatorMessage | ||
| ) const; |
There was a problem hiding this comment.
The method signature shows removal of std::stringstream &ss parameter but this creates an inconsistency with the moved Combat methods which now use fmt::format internally. Consider updating the parameter list documentation or ensure all message building methods follow the same pattern.
| ); | ||
| static void applyImbuementElementalDamage( | ||
| const std::shared_ptr<Player> &attackerPlayer, | ||
| std::shared_ptr<Item> item, |
There was a problem hiding this comment.
The item parameter should be const std::shared_ptr<Item> &item for consistency with other parameters and to avoid unnecessary copying since the method doesn't modify the shared_ptr itself.
| std::shared_ptr<Item> item, | |
| const std::shared_ptr<Item> &item, |
0594172 to
c0a3998
Compare
Refactored combat logic in combat.cpp by introducing helper functions and a CombatEntities struct to simplify entity handling. Added new utility functions for hazard system, messaging, Wheel of Destiny effects, charm runes, and leech mechanics. Updated combat.hpp with new static methods and improved code organization. Enhanced Game::combatBlockHit in game.cpp with modular damage processing and reflection logic.
c0a3998 to
3b2cab2
Compare
|
|
This PR is stale because it has been open 45 days with no activity. |
|
This PR is stale because it has been open 45 days with no activity. |



Description
This refactor clarifies boundaries between Combat and Game, reduces coupling, and preserves behavior bit-for-bit.
Key changes:
Moved pure combat helpers into
src/creatures/combat/combat.cppunder an anonymous namespace, exposing only minimal static entry points onCombatwhereGameneeds them.Kept Game loop/infrastructure in
src/game/game.cpp; createdInternalGamehelpers for block/reflect processing, block effect dispatch, and small string utilities.Promoted
applyImbuementElementalDamageto the publicCombatinterface and changed signature to in-place update:CombatDamage applyImbuementElementalDamage(const std::shared_ptr<Player>&, std::shared_ptr<Item>, CombatDamage)void applyImbuementElementalDamage(const std::shared_ptr<Player>&, std::shared_ptr<Item>, CombatDamage&)Ensured successful compilation when building messages from Combat by adding
#include "server/network/protocol/protocolgame.hpp"whereverTextMessageis referenced from Combat headers.Migrated string building in moved code from
std::stringstreamtofmt::format/fmt::format_towhile keeping output text identical.Modularized damage processing and reflection logic, keeping public APIs stable and not changing formulas, order of calls, or logs.
Behaviour
Actual
TextMessagetype.Expected
Combat::entry points); Game has orchestration andInternalGamelow-level helpers.protocolgameinclude whenTextMessageis referenced.Fixes #issuenumber
N/A (structural refactor; behavior preserved)
Type of change
How Has This Been Tested
Validation focuses on parity and builds correctness:
Build
protocolgameinclude.Parity tests (no behavioral change)
InternalGamehelpers.Smoke runs
Ranged/melee/spell damage paths, with and without secondary damage.
Player↔Monster and Monster↔Player flows, including prey bonuses and party/impact trackers.
Test A: message snapshot parity (attacker/target/spectator)
Test B: hazard + reflection scenarios parity
Checklist