BibliothecaDAO / eternum

onchain eternal game
https://alpha-eternum.realms.world
MIT License
46 stars 34 forks source link

feat: add unforeseen cases to combat flow #934

Closed edisontim closed 3 months ago

edisontim commented 3 months ago

PR Type

Enhancement, Bug fix


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
17 files
BattleManager.ts
Update battleActive method to use current tick                     

client/src/dojo/modelManager/BattleManager.ts
  • Modified battleActive method to accept currentTick parameter.
  • Changed logic to determine if a battle is active based on elapsed
    time.
  • +3/-2     
    useBattles.tsx
    Add ongoing battle check in useBattlesByPosition                 

    client/src/hooks/helpers/useBattles.tsx - Added check for ongoing battle based on army health.
    +3/-1     
    useStructures.tsx
    Update Realm and FullStructure types                                         

    client/src/hooks/helpers/useStructures.tsx
  • Updated Realm and FullStructure types.
  • Removed name from FullStructure.
  • Added protector to Realm.
  • +15/-9   
    types.ts
    Update BattleViewInfo type to use new structures                 

    client/src/hooks/store/types.ts - Updated `BattleViewInfo` type to use `Realm` and `Structure`.
    +2/-2     
    useUIStore.tsx
    Update setBattleView method for new structures                     

    client/src/hooks/store/useUIStore.tsx - Updated `setBattleView` method to use `Realm` and `Structure`.
    +3/-3     
    StructureCard.tsx
    Update combat button logic in StructureCard                           

    client/src/ui/components/hyperstructures/StructureCard.tsx - Updated combat button logic to use `Realm` and `Structure`.
    +3/-3     
    ArmyChip.tsx
    Add conditional check for army health display                       

    client/src/ui/components/military/ArmyChip.tsx - Added conditional check for army health display.
    +4/-2     
    BattleLabel.tsx
    Update onClick logic in BattleLabel                                           

    client/src/ui/components/worldmap/armies/BattleLabel.tsx - Updated `onClick` logic to handle `Realm` and `Structure`.
    +19/-6   
    HexagonInformationPanel.tsx
    Add conditional check for displaying enemies                         

    client/src/ui/components/worldmap/hexagon/HexagonInformationPanel.tsx - Added conditional check for displaying enemies.
    +1/-1     
    BattleActions.tsx
    Refactor battle action handlers for new structures             

    client/src/ui/modules/military/battle-view/BattleActions.tsx
  • Refactored battle action handlers.
  • Updated to use Realm and Structure.
  • +148/-151
    BattleProgressBar.tsx
    Update health display logic in BattleProgressBar                 

    client/src/ui/modules/military/battle-view/BattleProgressBar.tsx - Updated health display logic.
    +53/-57 
    BattleView.tsx
    Refactor BattleView to use new components                               

    client/src/ui/modules/military/battle-view/BattleView.tsx
  • Refactored to use OngoingBattle and NoOngoingBattle components.
  • Updated to handle Realm and Structure.
  • +35/-79 
    EntityAvatar.tsx
    Update EntityAvatar to use new structures                               

    client/src/ui/modules/military/battle-view/EntityAvatar.tsx - Updated to use `Realm` and `Structure`.
    +2/-2     
    NoOngoingBattle.tsx
    Add NoOngoingBattle component                                                       

    client/src/ui/modules/military/battle-view/NoOngoingBattle.tsx - Added new component for handling no ongoing battle state.
    +83/-0   
    OngoingBattle.tsx
    Add OngoingBattle component                                                           

    client/src/ui/modules/military/battle-view/OngoingBattle.tsx - Added new component for handling ongoing battle state.
    +104/-0 
    Troops.tsx
    Update no defending army message                                                 

    client/src/ui/modules/military/battle-view/Troops.tsx - Updated message for no defending army.
    +2/-2     
    contracts.cairo
    Add entity_id to battle_position in combat system               

    contracts/src/systems/combat/contracts.cairo - Added `entity_id` to `battle_position`.
    +1/-0     
    Miscellaneous
    1 files
    Battle.tsx
    Remove console log from Battle component                                 

    client/src/ui/components/military/Battle.tsx - Removed unnecessary console log.
    +0/-2     
    Formatting
    3 files
    EntitiesArmyTable.tsx
    Add spacing in EntitiesArmyTable for readability                 

    client/src/ui/components/military/EntitiesArmyTable.tsx - Added spacing for better readability.
    +1/-0     
    TopMiddleNavigation.tsx
    Reorganize imports in TopMiddleNavigation                               

    client/src/ui/modules/navigation/TopMiddleNavigation.tsx - Reorganized imports for better readability.
    +10/-13 
    index.ts
    Reorganize imports in provider index                                         

    sdk/packages/eternum/src/provider/index.ts - Reorganized imports for better readability.
    +2/-2     
    Configuration changes
    2 files
    manifest.json
    Update manifest with new block number and class hashes     

    contracts/manifests/dev/manifest.json - Updated block number and class hashes. - Removed loyalty model.
    +3/-234 
    manifest.toml
    Update manifest with new block number and class hashes     

    contracts/manifests/dev/manifest.toml - Updated block number and class hashes. - Removed loyalty model.
    +3/-20   

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 3 months ago

    The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

    Name Status Preview Comments Updated (UTC)
    eternum โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Jun 14, 2024 7:37pm
    github-actions[bot] commented 3 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review [1-5] 4
    ๐Ÿงช Relevant tests No
    ๐Ÿ”’ Security concerns No
    โšก Key issues to review Possible Bug:
    The `battleActive` method in `BattleManager.ts` now uses `currentTick` to calculate `timeSinceLastUpdate`, but it's unclear how `getElapsedTime` is implemented. This could potentially lead to incorrect calculations if not handled properly.
    Refactoring Concern:
    The `useBattlesByPosition` function in `useBattles.tsx` now directly checks for ongoing battles by comparing health values, which might not account for other conditions that could affect battle status.
    Data Structure Changes:
    The removal of `name` from `FullStructure` and addition of `protector` in `Realm` in `useStructures.tsx` could lead to issues where other parts of the codebase expect the `name` property to exist or do not handle the new `protector` property correctly.
    Consistency Issue:
    The `BattleViewInfo` type in `types.ts` has been modified to use `Realm` or `Structure` instead of `FullStructure`, which could lead to inconsistencies in how battle information is processed and displayed across different components.
    github-actions[bot] commented 3 months ago

    Failed to generate code suggestions for PR