GDQuest / GDQuest/learn-gdscript
L14.P2 Reducing damage at higher levels: check rejects correct solutions that don't reassign amount
- Dominant language
- GDScript
- Stars
- 2.8k
- Forks
- 235
- PR merge metrics
- No merged PRs in 30d
Description
**What happened?**
I solved the problem with a solution that worked and accomplished everything intended but did not pass the tests. Doing the multiplication by 0.5 at the subtraction rather than assigning the result back to `amount` fails despite a 10-damage attack still being reduced to 5 above level 2, with full damage below level 3. The second check, "Damage Amount Is Correct Value", passed.
**Where were you in the app?**
L14.P2 Reducing damage at higher levels
**What did you expect to happen?**
The test should accept the other solutions that work as intended instead of restricting to certain syntax.
**Your code**
```gdscript
var level = 3
var health = 100
var max_health = 100
func take_damage(amount):
if level > 2:
health -= amount * 0.5
else:
health -= amount
if health < 0:
health = 0
```
**Optional: screenshot or other details**
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the L14.P2 lesson and inspect the checks for the damage-reduction behavior, including "Damage Amount Is Correct Value". Reproduce the issue with the shown solution and update the validation so semantically equivalent damage handling passes; done when the valid solution is accepted without breaking the existing checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- godot
- Domain
- game-dev, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100