Skip to content

Conversation

@0x1NotMe
Copy link
Contributor

@0x1NotMe 0x1NotMe commented Jul 4, 2025

Summary

  • Fixed ability handler to properly load equipment and inventory data
  • Resolved issue where ability usage returned empty weapon/armor structs
  • Added comprehensive tests to verify the fix

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

  1. Handler.sol: Added equipment and inventory loading in _handleAbility function to match the behavior of _handleCombat

    • Added attacker = attacker.loadEquipment() after verifying character is alive
    • Added attacker.inventory = inventories[attacker.id] to load inventory data
    • Added defender = defender.loadEquipment() for defenders in offensive abilities
  2. Storage.sol: Fixed variable shadowing warning in _getKiller function

  3. Tests: Added two new test cases to verify equipment loading:

    • test_Ability_EquipmentAndInventoryLoading: Tests non-offensive abilities
    • test_Ability_OffensiveWithEquipmentLoading: Tests offensive abilities with targets

Test Results

All tests are passing, confirming that equipment and inventory data are now properly loaded during ability usage.

Closes

Fixes #20

@0x1NotMe 0x1NotMe requested a review from thogard785 July 4, 2025 04:52
@0x1NotMe 0x1NotMe force-pushed the fix/issue-20-ability-equipment-data branch from 4c1505d to e16f048 Compare July 4, 2025 04:54
- 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.
@0x1NotMe 0x1NotMe force-pushed the fix/issue-20-ability-equipment-data branch from e16f048 to 71254ba Compare July 6, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Ability usage returns empty equipment data despite valid equipment IDs

2 participants