Fix #20: Load equipment and inventory data in ability handler#21
Open
Fix #20: Load equipment and inventory data in ability handler#21
Conversation
4c1505d to
e16f048
Compare
- Add equipment loading (loadEquipment()) in _handleAbility function - Add inventory loading from storage in _handleAbility function - Load defender equipment when processing offensive abilities - Fix variable shadowing warning in Storage.sol _getKiller function - Add comprehensive tests for equipment/inventory loading during abilities This ensures ability usage returns complete BattleNad structs with populated weapon, armor, and inventory data instead of empty values.
e16f048 to
71254ba
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem Description
When characters used abilities (e.g., "ChargeUp"), the returned BattleNad struct contained empty weapon and armor data, even though the character had valid equipment IDs. This was causing incomplete character data to be displayed during ability usage.
Changes Made
Handler.sol: Added equipment and inventory loading in
_handleAbilityfunction to match the behavior of_handleCombatattacker = attacker.loadEquipment()after verifying character is aliveattacker.inventory = inventories[attacker.id]to load inventory datadefender = defender.loadEquipment()for defenders in offensive abilitiesStorage.sol: Fixed variable shadowing warning in
_getKillerfunctionTests: Added two new test cases to verify equipment loading:
test_Ability_EquipmentAndInventoryLoading: Tests non-offensive abilitiestest_Ability_OffensiveWithEquipmentLoading: Tests offensive abilities with targetsTest Results
All tests are passing, confirming that equipment and inventory data are now properly loaded during ability usage.
Closes
Fixes #20