diff --git a/elm-package.json b/elm-package.json index f824099..6b7be16 100644 --- a/elm-package.json +++ b/elm-package.json @@ -13,7 +13,8 @@ "elm-lang/keyboard": "1.0.0 <= v < 2.0.0", "elm-lang/mouse": "1.0.0 <= v < 2.0.0", "elm-lang/svg": "1.1.0 <= v < 2.0.0", - "elm-lang/window": "1.0.0 <= v < 2.0.0" + "elm-lang/window": "1.0.0 <= v < 2.0.0", + "toastal/either": "2.0.0 <= v < 3.0.0" }, "elm-version": "0.17.1 <= v < 0.18.0" } diff --git a/src/Model.elm b/src/Model.elm index 28a88d4..b46f8d9 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -24,6 +24,7 @@ import Svg.Attributes exposing (..) import Tabletop exposing (Position, Inch, posX, posY) import Utilities exposing (textNode, onClickWithoutPropagation) import Uuid exposing (Uuid, uuid) +import Weapons exposing (Weapon, knife) type alias Model = @@ -37,6 +38,7 @@ type alias Model = , id : Id , fighterType : FighterType , name : String + , equipment : List Weapon } @@ -186,6 +188,7 @@ init role = , id = Uuid.scheme , fighterType = role , name = "Mac McMadd" + , equipment = [ knife ] } diff --git a/src/Weapons.elm b/src/Weapons.elm index 6514c8d..2262746 100644 --- a/src/Weapons.elm +++ b/src/Weapons.elm @@ -1,6 +1,7 @@ module Weapons exposing (..) import Tabletop exposing (Inch) +import Either exposing (Either(..)) type Weapon @@ -15,37 +16,47 @@ type Weapon type alias Profile = { range : Range , toHit : ( Maybe Modifier, Maybe Modifier ) - , strength : Int + , strength : Either Modifier Int , damage : Int - , saveModifier : Maybe Modifier + , saveModifier : Modifier , ammoRoll : Maybe Int } type Range = Close - | Ranged Short Long + | Template + | Ranged ShortRange LongRange -type alias Short = +type alias ShortRange = ( Inch, Inch ) -type alias Long = +type alias LongRange = ( Inch, Inch ) +{-| For some attributes, like Strength or To Hit, they are a modifier +applied to either the wielders strength or to dice rolls. + +-} type alias Modifier = Int -> Int +asUser : Modifier +asUser = + (+) 0 + + knife : Weapon knife = Combat { range = Close , toHit = ( Nothing, Nothing ) - , strength = 1 + , strength = Left asUser , damage = 1 - , saveModifier = Nothing + , saveModifier = asUser , ammoRoll = Nothing }