-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor: move static Combat methods out of header #5072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -914,6 +914,38 @@ uint16_t AStarNodes::getMapWalkCost(AStarNode* node, const Position& neighborPos | |
| return MAP_NORMALWALKCOST; | ||
| } | ||
|
|
||
| constexpr ConditionType_t DamageToConditionType(CombatType_t type) | ||
|
||
| { | ||
| switch (type) { | ||
| case COMBAT_FIREDAMAGE: | ||
| return CONDITION_FIRE; | ||
|
|
||
| case COMBAT_ENERGYDAMAGE: | ||
| return CONDITION_ENERGY; | ||
|
|
||
| case COMBAT_DROWNDAMAGE: | ||
| return CONDITION_DROWN; | ||
|
|
||
| case COMBAT_EARTHDAMAGE: | ||
| return CONDITION_POISON; | ||
|
|
||
| case COMBAT_ICEDAMAGE: | ||
| return CONDITION_FREEZING; | ||
|
|
||
| case COMBAT_HOLYDAMAGE: | ||
| return CONDITION_DAZZLED; | ||
|
|
||
| case COMBAT_DEATHDAMAGE: | ||
| return CONDITION_CURSED; | ||
|
|
||
| case COMBAT_PHYSICALDAMAGE: | ||
| return CONDITION_BLEEDING; | ||
|
|
||
| default: | ||
| return CONDITION_NONE; | ||
| } | ||
| } | ||
|
|
||
| uint16_t AStarNodes::getTileWalkCost(const Creature& creature, const Tile* tile) | ||
| { | ||
| uint16_t cost = 0; | ||
|
|
@@ -925,7 +957,7 @@ uint16_t AStarNodes::getTileWalkCost(const Creature& creature, const Tile* tile) | |
| if (const MagicField* field = tile->getFieldItem()) { | ||
| CombatType_t combatType = field->getCombatType(); | ||
| const Monster* monster = creature.getMonster(); | ||
| if (!creature.isImmune(combatType) && !creature.hasCondition(Combat::DamageToConditionType(combatType)) && | ||
| if (!creature.isImmune(combatType) && !creature.hasCondition(DamageToConditionType(combatType)) && | ||
| (monster && !monster->canWalkOnFieldType(combatType))) { | ||
| cost += MAP_NORMALWALKCOST * 18; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function
ConditionToDamageTypeshould be placed in an anonymous namespace or be declared asstaticto follow the codebase's convention for file-local helper functions. This would prevent potential naming conflicts and clearly indicate that this function has internal linkage.