Skip to content

Commit ecee47d

Browse files
committed
lecture: add code snippet to challenges (Optional)
closes #930
1 parent 3bdb85f commit ecee47d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lecture/java-modern/optional.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ challenges: |
146146
ac.get().resetCurrentAmmunition();
147147
}
148148
}
149+
150+
// "classic" (original code, cf. https://github.com/Dungeon-CampusMinden/Dungeon/pull/1828)
151+
if (Game.hero().isPresent()) {
152+
AmmunitionComponent ac =
153+
Game.hero()
154+
.get()
155+
.fetch(AmmunitionComponent.class)
156+
.orElseThrow(
157+
() ->
158+
MissingComponentException.build(
159+
Game.hero().get(), AmmunitionComponent.class));
160+
ac.setCurrentAmmunition(0);
161+
}
149162
```
150163
-->
151164

0 commit comments

Comments
 (0)