[code-simplifier] Code quality improvements#154
Conversation
|
@claude[agent] resolve conflicts in this branch |
|
@norrietaylor I've opened a new pull request, #155, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
This PR applies a set of small, mechanical code-simplification improvements across core gameplay scripts (player health/combat, level management, and collectibles) based on prior “Code Simplifier” analysis.
Changes:
- Simplifies health bounds logic by using
Mathf.Clampfor both damage and healing. - Replaces a magic-number “attack type” integer with a strongly-typed
AttackKindenum while keeping the Animator-facing API as anint. - Removes an unused serialized level-name field configuration and replaces a hardcoded
"Player"tag literal with a local constant.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Unity/Assets/Scripts/Player/PlayerHealth.cs | Uses Mathf.Clamp to enforce health bounds in a single expression for damage/heal. |
| Unity/Assets/Scripts/Player/PlayerCombat.cs | Introduces AttackKind enum and updates combat state tracking while preserving AttackType int for Animator. |
| Unity/Assets/Scripts/Levels/LevelManager.cs | Removes unused [SerializeField]/header from _currentLevelName (now set from active scene at runtime). |
| Unity/Assets/Scripts/Collectibles/Collectible.cs | Replaces hardcoded "Player" tag string with a class constant for maintainability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Collectible.cs: replace hardcoded Player string with a named constant - PlayerHealth.cs: use Mathf.Clamp instead of two separate clamp operations - LevelManager.cs: remove [SerializeField] from _currentLevelName (always overwritten in Start) - PlayerCombat.cs: replace magic int attack type with AttackKind enum for type safety Fixes #73 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
549c30f to
91fb610
Compare
|
@claude this branch is failing the unity test suite |
|
Claude finished @norrietaylor's task in 1m 44s —— View job Fixed Unity Test Suite Failure
Root cause: The PR changed |
…mator The AttackType property on PlayerCombat was changed from int to AttackKind enum, but PlayerAnimator.SetInteger requires an int. Cast to int to fix the compilation error. Co-authored-by: Norrie Taylor <norrietaylor@users.noreply.github.com>
Applies code simplifications from the Code Simplifier analysis that failed to create a PR automatically (issue #73).
Generated with Claude Code