Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Created July 4, 2016 21:10
Show Gist options
  • Save vgaltes/c7050947af0670cef422d19861689417 to your computer and use it in GitHub Desktop.
Save vgaltes/c7050947af0670cef422d19861689417 to your computer and use it in GitHub Desktop.
let rec applyRules value rules characterFrom playerTo distance =
match rules with
| [] -> value
| x::xs ->
let result = x characterFrom playerTo distance value
match result with
| None -> 0
| Some v -> applyRules v xs characterFrom playerTo distance
let interactWith characterFrom characterTo action distance =
match action with
| Attack amount ->
let damage = applyRules amount attackRules characterFrom characterTo distance
{characterTo with Health = characterto.Health - damage}
| Heal amount ->
let healing = applyRules amount healRules characterFrom characterTo distance
{characterTo with Health = characterto.Health + healing}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment