Created
July 4, 2016 21:15
-
-
Save vgaltes/a64c9e36fcc21ea19800fe90dd406eb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let interactWith characterFrom playerTo action distance = | |
let calculateDamage characterFrom playerTo action distance = | |
match action with | |
| Attack amount -> | |
match playerTo with | |
| Character c -> | |
let damage = calculateHealthDifference amount attackRules characterFrom c distance | |
let damage' = applyEnvironmentalRules damage environmentalAttackRules characterFrom distance | |
applyLimitRules damage' attackLimitRules c.Health | |
| Thing t -> | |
let damage = applyEnvironmentalRules amount environmentalAttackRules characterFrom distance | |
applyLimitRules damage attackLimitRules t.Health | |
| Heal amount -> | |
match playerTo with | |
| Character c -> | |
let healing = calculateHealthDifference amount healRules characterFrom c distance | |
applyLimitRules healing healLimitRules c.Health | |
| Thing t -> 0 | |
let damage = calculateDamage characterFrom playerTo action distance | |
match action with | |
| Attack _ -> | |
match playerTo with | |
| Character c -> Player.Character {c with Health = c.Health - damage} | |
| Thing t -> Player.Thing {t with Health = t.Health - damage} | |
| Heal _ -> | |
match playerTo with | |
| Character c -> Player.Character {c with Health = c.Health + damage} | |
| Thing t -> Player.Thing t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment