Skip to content

Comments

Feat: create battle system implementation#156

Merged
coxmars merged 1 commit intoAkatsukiLabs:mainfrom
manlikeHB:feat/battle-system
Jun 29, 2025
Merged

Feat: create battle system implementation#156
coxmars merged 1 commit intoAkatsukiLabs:mainfrom
manlikeHB:feat/battle-system

Conversation

@manlikeHB
Copy link
Contributor

@manlikeHB manlikeHB commented Jun 28, 2025

Create Battle System Implementation

📝 Summary

This PR implements a complete Battle system to handle battle creation, attack processing, turn management, and battle resolution. The implementation includes proper interface definition, comprehensive validation, achievement integration, and a full test suite.

Related Issues

Type of Change

  • 📝 Documentation (updates to README, docs, or comments)
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 👌 Enhancement (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)

🔄 Changes Made

  • New Battle System: Complete implementation of IBattle interface with four core methods:

    • create_battle() - Creates battles between players with validation
    • join_battle() - Activates waiting battles when both players are ready
    • attack() - Processes turn-based combat using existing store logic
    • end_battle() - Manually ends battles with winner declaration
  • Battle Lifecycle Management: Proper state transitions (Waiting → Active → Finished).

  • Achievement Integration: Automatic progression of battle-related achievements (FirstBlood, Warrior, Veteran, Champion, Legend).

  • Event System: Comprehensive event emission for battle tracking

  • Comprehensive Test Suite: 13 tests covering all functionality and edge cases

  • Version Alignment: Updated .tool-versions dojo version from 1.1.1 to 1.2.1 to match Scarb.toml specification

Implementation Details

System Architecture:

  • Uses StoreTrait for all model interactions (battles, players, beasts)
  • Integrates with existing process_attack() method for combat logic
  • Leverages achievement system with proper progression tracking

Key Features:

  • Turn-based Combat: Automatic turn switching with validation
  • Player Validation: Robust existence checks using assert_exists() pattern
  • Beast Requirement: Ensures players have beasts before battle activation
  • Error Handling: Comprehensive validation with descriptive error messages
  • Event Emission: Real-time battle state tracking via Dojo events

Achievement System:

  • Automatic progression based on battle wins (1, 5, 15, 30, 50 victories)
  • Extracted achievement logic into reusable progress_achievements() function
  • Integrated with existing achievement component

Technical Notes

🔧 Tests Results

Test Coverage

  • Unit Tests
  • Integration Tests
  • Manual Testing

Evidence

Screenshot 2025-06-28 at 5 44 59 PM

Testing Notes

🔜 Next Steps

@manlikeHB
Copy link
Contributor Author

Hi @coxmars, PR ready for review.

@coxmars coxmars merged commit 57b5aa3 into AkatsukiLabs:main Jun 29, 2025
1 check failed
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.

📝 [FEAT]: Create Battle System Implementation

2 participants