Skip to content

fix(crash): simplify attack handling logic #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andrewgazelka
Copy link
Member

  • Extract reusable functions for immunity checks and combat stats calculations
  • Add operator overloading via Add/Sub traits for Position and CombatStats
  • Reduce nesting depth in attack handling code
  • Update several dependencies including arboard and rand
  • Add 'add' and 'add_assign' features to derive_more dependency

- Extract reusable functions for immunity checks and combat stats calculations
- Add operator overloading via Add/Sub traits for Position and CombatStats
- Reduce nesting depth in attack handling code
- Update several dependencies including arboard and rand
- Add 'add' and 'add_assign' features to derive_more dependency
@Copilot Copilot AI review requested due to automatic review settings April 26, 2025 23:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the attack handling logic to simplify code paths and improve reusability while adding operator overloading for Position and CombatStats.

  • Extracts reusable functions for immunity checks and combat stats calculations.
  • Adds Add/Sub traits derivations for Position and updates derive_more dependency settings.
  • Reduces nesting depth in attack handling code and updates several dependencies.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
crates/hyperion/src/simulation/mod.rs Updated derives for Position to include operator overloads (Add/Sub).
Cargo.toml Updated derive_more features by adding add and add_assign options.
Files not reviewed (1)
  • justfile: Language not supported
Comments suppressed due to low confidence (1)

crates/hyperion/src/simulation/mod.rs:392

  • The Cargo.toml update enables the 'add_assign' feature but the Position struct does not derive AddAssign. Consider deriving AddAssign for Position if assignment addition operations are intended.
PartialEq, Add, Sub

@github-actions github-actions bot added the fix label Apr 26, 2025
Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  33.3 ns ...  33.2 ns ]      -0.24%
ray_intersection/aabb_size_1                       [  33.6 ns ...  33.6 ns ]      +0.14%
ray_intersection/aabb_size_10                      [  24.4 ns ...  24.4 ns ]      +0.21%
ray_intersection/ray_distance_1                    [  13.7 ns ...  13.8 ns ]      +0.31%
ray_intersection/ray_distance_5                    [  13.8 ns ...  13.8 ns ]      +0.12%
ray_intersection/ray_distance_20                   [  13.8 ns ...  13.9 ns ]      +0.34%
overlap/no_overlap                                 [  24.8 ns ...  24.8 ns ]      +0.11%
overlap/partial_overlap                            [  25.0 ns ...  25.3 ns ]      +1.05%
overlap/full_containment                           [  22.5 ns ...  22.5 ns ]      +0.25%
point_containment/inside                           [   4.9 ns ...   5.0 ns ]      +0.16%
point_containment/outside                          [   4.4 ns ...   4.4 ns ]      -0.03%
point_containment/boundary                         [   5.0 ns ...   5.0 ns ]      +0.22%

Comparing to 4c402d0

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 0% with 154 lines in your changes missing coverage. Please review.

Project coverage is 21.11%. Comparing base (4c402d0) to head (9bed850).

Files with missing lines Patch % Lines
events/tag/src/module/attack.rs 0.00% 154 Missing ⚠️
@@            Coverage Diff             @@
##             main     #887      +/-   ##
==========================================
+ Coverage   20.85%   21.11%   +0.26%     
==========================================
  Files         161      161              
  Lines       16867    16658     -209     
  Branches      468      468              
==========================================
  Hits         3518     3518              
+ Misses      13285    13076     -209     
  Partials       64       64              
Files with missing lines Coverage Δ
crates/hyperion/src/simulation/mod.rs 39.25% <ø> (ø)
events/tag/src/module/attack.rs 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  33.6 ns ...  33.7 ns ]      +0.16%
ray_intersection/aabb_size_1                       [  32.6 ns ...  32.7 ns ]      +0.18%
ray_intersection/aabb_size_10                      [  24.5 ns ...  24.4 ns ]      -0.19%
ray_intersection/ray_distance_1                    [  13.9 ns ...  13.9 ns ]      +0.17%
ray_intersection/ray_distance_5                    [  13.8 ns ...  13.8 ns ]      +0.01%
ray_intersection/ray_distance_20                   [  13.6 ns ...  13.6 ns ]      -0.10%
overlap/no_overlap                                 [  24.7 ns ...  24.8 ns ]      +0.20%
overlap/partial_overlap                            [  25.0 ns ...  24.9 ns ]      -0.20%
overlap/full_containment                           [  22.7 ns ...  22.7 ns ]      +0.02%
point_containment/inside                           [   5.0 ns ...   5.0 ns ]      +0.32%
point_containment/outside                          [   4.8 ns ...   4.8 ns ]      -0.72%
point_containment/boundary                         [   5.4 ns ...   5.5 ns ]      +1.46%

Comparing to 4c402d0

Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  33.2 ns ...  33.2 ns ]      -0.11%
ray_intersection/aabb_size_1                       [  33.2 ns ...  33.3 ns ]      +0.08%
ray_intersection/aabb_size_10                      [  24.5 ns ...  24.5 ns ]      -0.10%
ray_intersection/ray_distance_1                    [  13.8 ns ...  13.8 ns ]      -0.18%
ray_intersection/ray_distance_5                    [  13.8 ns ...  13.8 ns ]      +0.38%
ray_intersection/ray_distance_20                   [  13.8 ns ...  13.8 ns ]      +0.29%
overlap/no_overlap                                 [  24.8 ns ...  24.8 ns ]      -0.03%
overlap/partial_overlap                            [  25.1 ns ...  25.1 ns ]      -0.19%
overlap/full_containment                           [  22.5 ns ...  22.5 ns ]      +0.16%
point_containment/inside                           [   4.9 ns ...   4.9 ns ]      -0.14%
point_containment/outside                          [   4.4 ns ...   4.4 ns ]      -0.15%
point_containment/boundary                         [   4.9 ns ...   4.9 ns ]      -0.04%

Comparing to 4c402d0

Co-authored-by: TestingPlant <[email protected]>
Copy link

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  34.0 ns ...  34.0 ns ]      -0.15%
ray_intersection/aabb_size_1                       [  33.1 ns ...  33.2 ns ]      +0.31%
ray_intersection/aabb_size_10                      [  24.5 ns ...  24.5 ns ]      -0.18%
ray_intersection/ray_distance_1                    [  13.5 ns ...  13.5 ns ]      -0.03%
ray_intersection/ray_distance_5                    [  13.5 ns ...  13.5 ns ]      +0.15%
ray_intersection/ray_distance_20                   [  13.5 ns ...  13.6 ns ]      +0.17%
overlap/no_overlap                                 [  24.4 ns ...  24.4 ns ]      -0.02%
overlap/partial_overlap                            [  24.9 ns ...  24.8 ns ]      -0.20%
overlap/full_containment                           [  22.5 ns ...  22.5 ns ]      +0.20%
point_containment/inside                           [   4.9 ns ...   4.9 ns ]      -0.09%
point_containment/outside                          [   4.4 ns ...   4.4 ns ]      -0.12%
point_containment/boundary                         [   4.9 ns ...   4.9 ns ]      +0.38%

Comparing to 4c402d0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants