Dev Log: The Case of the Mischievous Upgrade System 🕵️‍♂️


Chapter 1: The Unruly Bugs

Two puzzling issues surfaced in my game’s upgrade system:

  1. The damage aura ability kept showing up twice, defying its max quantity of 1.
  2. The anvil count upgrade appeared without the prerequisite anvil ability, as if skipping the line.

These behaviors pointed to deeper problems in the upgrade manager’s logic, but identifying the root cause wasn’t going to be simple.

Chapter 2: A Night of Speculation

After an evening out with colleagues and a couple of beers, I went to bed—but my thoughts wouldn’t let go of the upgrade manager, particularly the new damage aura ability. What could be causing these strange behaviors?

The next morning, I powered through my usual tasks and went straight to debugging. With a strong coffee in hand and my dog snoozing by my feet, I was ready to dig deep into the issue.

Chapter 3: The Debugging Process

The upgrade manager was designed to handle abilities with weights, dependencies, and quantity limits, but something wasn’t adding up. Here’s how the investigation unfolded:

Step 1: Renaming the Offenders

I suspected a problem with how names were processed. To rule this out, I standardized the names:

  • Lowercase “axe” became proper case “Axe.”
  • Result? No improvement.

Step 2: Switching to IDs

Next, I replaced names with unique resource IDs:

  • Refactored the system to rely on IDs.
  • Improved weight management and dependency tracking.
  • Result? Still no luck.

Step 3: Adjusting Weights Dynamically

To refine the upgrade logic further, I introduced dynamic weight adjustments:

  • Prioritized unacquired abilities.
  • Penalized upgrades that appeared too often.
  • Result? The core issue persisted.

While these steps improved the system’s robustness, they didn’t solve the fundamental problem.

Chapter 4: The Eureka Moment

Then it hit me—I remembered duplicating the anvil.tres file to create the new damage_aura ability. In my excitement to push the new ability to itch.io for testing, I had rushed the process. Just to be sure, I checked the resource file to confirm I hadn’t overlooked renaming everything.

Sure enough, the ID for anvil.tres was still set to "damage_aura", causing:

  • Confused logic: Both abilities shared an ID, making the system think they were the same.
  • Broken dependencies: Dependencies and weights became meaningless because the system couldn’t tell the abilities apart.
  • Weird behaviors: Selecting one upgrade triggered both, and they showed up when they shouldn’t.

Fixing the ID resolved everything instantly.

Chapter 5: Lessons Learned

This debugging session was a humbling reminder of a few key lessons:

  1. Start simple. A tiny mistake in data can cause seemingly unrelated issues.
  2. Take your time. Rushing to push updates, no matter how exciting, can lead to errors.
  3. Check the foundations. Verifying configurations first can save hours of debugging.
  4. Unique IDs are sacred. They’re the backbone of clear, maintainable systems.
  5. Debugging is a marathon. Coffee, patience, and a calm mindset (preferably with a dog nearby) are your best tools.

Final Thought

Development isn’t always smooth sailing, but even mistakes can lead to improvements. The upgrade manager is now more robust, and I’ve got another lesson to apply in the future.

Until next time, happy coding! 🎮

Files

game_updated.zip Play in browser
14 hours ago

Leave a comment

Log in with itch.io to leave a comment.