Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions exercises/concept/role-playing-game/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Hints

- See the [F# language reference on Options][options] for more usage examples.
## 1. Introduce yourself

The `introduce` function must "unwrap" the value contained in `player.Name`.
Consider using the [`Options.defaultValue` function][defaultvalue] to convert `player.Name` to its "wrapped" value when it is `Some` or the required default value when it is `None`.

## 2. Implement the revive mechanic

The `revive` function must return either `Some <player>` or `None`, where `<player>` is a `Player` record possibly with some modified fields.

## 3. Implement the spell casting mechanic

- The [`max` function][max] can be used to ensure the health value does not go below 0.
Consider using a match expression to cover both the `Some` and `None` cases, as in the following example:

```fsharp
let exists (x: Option<int>) =
match x with
| Some n -> true
| None -> false
```

[options]: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/options
[max]: https://fsharp.github.io/fsharp-core-docs/reference/fsharp-core-operators.html#max
[defaultvalue]: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/options#converting-options-with-default-values