Skip to content

Instantly share code, notes, and snippets.

@mattraykowski
Created April 24, 2018 18:31
Show Gist options
  • Save mattraykowski/94ce1d75a4e3c55f05c91cb06a8df3aa to your computer and use it in GitHub Desktop.
Save mattraykowski/94ce1d75a4e3c55f05c91cb06a8df3aa to your computer and use it in GitHub Desktop.
module Data.CharacterSheet exposing (Die(..), Attributes, CharacterSheet, setName, setProfession, setAgilityDie)
type Die
= D4
| D6
| D8
| D10
| D12
type alias Attributes =
{ agility : Die
, smarts : Die
, spirit : Die
, strength : Die
, vigor : Die
}
type alias CharacterSheet =
{ name : String
, profession : String
, attributes : Attributes
}
setName : String -> CharacterSheet -> CharacterSheet
setName name characterSheet =
{ characterSheet | name = name }
setProfession : String -> CharacterSheet -> CharacterSheet
setProfession profession characterSheet =
{ characterSheet | profession = profession }
setAgilityDie : Die -> CharacterSheet -> CharacterSheet
setAgilityDie die characterSheet =
let
oldAttributes =
characterSheet.attributes
in
{ characterSheet | attributes = { oldAttributes | agility = die } }
setSmartsDie : Die -> CharacterSheet -> CharacterSheet
setSmartsDie die characterSheet =
let
oldAttributes =
characterSheet.attributes
in
{ characterSheet | attributes = { oldAttributes | smarts = die } }
setSpiritDie : Die -> CharacterSheet -> CharacterSheet
setSpiritDie die characterSheet =
let
oldAttributes =
characterSheet.attributes
in
{ characterSheet | attributes = { oldAttributes | spirit = die } }
setStrengthDie : Die -> CharacterSheet -> CharacterSheet
setStrengthDie die characterSheet =
let
oldAttributes =
characterSheet.attributes
in
{ characterSheet | attributes = { oldAttributes | strength = die } }
setVigorDie : Die -> CharacterSheet -> CharacterSheet
setVigorDie die characterSheet =
let
oldAttributes =
characterSheet.attributes
in
{ characterSheet | attributes = { oldAttributes | vigor = die } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment