-
Notifications
You must be signed in to change notification settings - Fork 714
Fix incorrect display of ability to upgrade enemy units #2308
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
Conversation
WalkthroughAdds an ownership check to canUpgradeUnit in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as UI / Controller
participant Player as PlayerImpl
participant Unit as Unit
UI->>Player: request canUpgradeUnit(unit)
Player->>Unit: unit.owner()
alt owner mismatch
rect rgb(255,250,204)
Note right of Player: ownership check fails
Player-->>UI: return false
end
else owner matches
Player->>Unit: check deleted/upgradable/disabled
alt any check fails
Player-->>UI: return false
else all checks pass
Player-->>UI: return true
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/core/game/PlayerImpl.ts(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: 🧪 CI
src/core/game/PlayerImpl.ts
[warning] 1-1: Code style issues found in the file. Run 'npx prettier --write' to fix.
[error] 1-1: Prettier formatting check failed. Process completed with exit code 1. Run 'npx prettier --write' to fix code style issues.
🔇 Additional comments (1)
src/core/game/PlayerImpl.ts (1)
905-907: Ownership check correctly prevents upgrading enemy units.The logic is sound and directly fixes the reported issue. The guard ensures only units owned by the current player can be upgraded, preventing the UI from showing enemy buildings as upgradeable when Ctrl+clicked.
|
Heya! Just to let you know that a milestone should be added. Thanks |
|
@kkissdev I don't think I have the ability to set milestones, tags or anything like that. Or at least I don't see the option here on github. |
|
Ah, I see. |
|
Please fix the prettier issue, we use spaces and not tabs. |
|
I may or may not have forgotten to push from my local branch |
bf46ba4 to
ed0f899
Compare
jrouillard
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👑
Description:
Fixes #2135.
Adds an owner check to canUpgradeUnit to prevent enemy units from seemingly being able to be upgraded when Ctrl+clicked on
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
Lavodan