| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/battlemap/src/Character.elm | 5 | ||||
| -rw-r--r-- | src/battlemap/src/Event.elm | 1 | ||||
| -rw-r--r-- | src/battlemap/src/Model.elm | 1 | ||||
| -rw-r--r-- | src/battlemap/src/Model/SelectCharacter.elm | 10 | ||||
| -rw-r--r-- | src/battlemap/src/Shim/Model.elm | 67 | ||||
| -rw-r--r-- | src/battlemap/src/Update.elm | 13 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap.elm | 6 | ||||
| -rw-r--r-- | src/battlemap/src/View/Footer/TabMenu/Settings.elm | 8 | ||||
| -rw-r--r-- | src/battlemap/www/index.html | 11 | 
9 files changed, 93 insertions, 29 deletions
| diff --git a/src/battlemap/src/Character.elm b/src/battlemap/src/Character.elm index 1b4d1a1..839c788 100644 --- a/src/battlemap/src/Character.elm +++ b/src/battlemap/src/Character.elm @@ -3,6 +3,7 @@ module Character exposing        Type,        Ref,        get_ref, +      get_team,        get_icon_id,        get_location,        set_location, @@ -19,6 +20,7 @@ type alias Type =        icon : String,        portrait : String,        location : Battlemap.Location.Type, +      team : Int,        movement_points : Int,        atk_dist : Int     } @@ -28,6 +30,9 @@ type alias Ref = String  get_ref : Type -> Ref  get_ref c = c.id +get_team : Type -> Int +get_team c = c.team +  get_icon_id : Type -> String  get_icon_id c = c.icon diff --git a/src/battlemap/src/Event.elm b/src/battlemap/src/Event.elm index c56f8cf..6b48d68 100644 --- a/src/battlemap/src/Event.elm +++ b/src/battlemap/src/Event.elm @@ -14,3 +14,4 @@ type Type =     | TurnEnded     | ScaleChangeRequested Float     | TabSelected UI.Tab +   | DebugTeamSwitchRequest diff --git a/src/battlemap/src/Model.elm b/src/battlemap/src/Model.elm index e463b2f..8f932aa 100644 --- a/src/battlemap/src/Model.elm +++ b/src/battlemap/src/Model.elm @@ -31,6 +31,7 @@ type alias Type =        battlemap: Battlemap.Type,        characters: (Dict.Dict Character.Ref Character.Type),        error: (Maybe Error.Type), +      controlled_team: Int,        ui: UI.Type     } diff --git a/src/battlemap/src/Model/SelectCharacter.elm b/src/battlemap/src/Model/SelectCharacter.elm index 3e6369d..b624ef9 100644 --- a/src/battlemap/src/Model/SelectCharacter.elm +++ b/src/battlemap/src/Model/SelectCharacter.elm @@ -13,6 +13,8 @@ make_it_so : Model.Type -> Character.Ref -> Model.Type  make_it_so model char_id =     case (Dict.get char_id model.characters) of        (Just char) -> +         if ((Character.get_team char) == model.controlled_team) +         then              {model |                 state = (Model.MovingCharacterWithClick char_id),                 battlemap = @@ -24,6 +26,14 @@ make_it_so model char_id =                       model.battlemap                    )              } +         else +            (Model.invalidate +               model +               (Error.new +                  Error.IllegalAction +                  "SelectCharacter: Wrong team. Attack is not implemented." +               ) +            )        Nothing ->           (Model.invalidate diff --git a/src/battlemap/src/Shim/Model.elm b/src/battlemap/src/Shim/Model.elm index 1e63301..37ef614 100644 --- a/src/battlemap/src/Shim/Model.elm +++ b/src/battlemap/src/Shim/Model.elm @@ -14,41 +14,58 @@ generate =        state = Model.Default,        error = Nothing,        battlemap = (Shim.Battlemap.generate), +      controlled_team = 0,        characters =           (Dict.insert -            "2" +            "3"              { -               id = "2", -               name = "Char2", -               icon = "Icon2", -               portrait = "Portrait2", -               location = {x = 0, y = 1}, -               movement_points = 5, -               atk_dist = 1 +               id = "3", +               name = "Char3", +               icon = "Icon3", +               team = 1, +               portrait = "Portrait3", +               location = {x = 3, y = 2}, +               movement_points = 2, +               atk_dist = 4              }              (Dict.insert -               "1" +               "2"                 { -                  id = "1", -                  name = "Char1", -                  icon = "Icon1", -                  portrait = "Portrait1", -                  location = {x = 1, y = 0}, -                  movement_points = 4, -                  atk_dist = 2 +                  id = "2", +                  name = "Char2", +                  icon = "Icon2", +                  team = 1, +                  portrait = "Portrait2", +                  location = {x = 2, y = 2}, +                  movement_points = 3, +                  atk_dist = 3                 }                 (Dict.insert -                  "0" +                  "1"                    { -                     id = "0", -                     name = "Char0", -                     icon = "Icon0", -                     portrait = "Portrait0", -                     location = {x = 0, y = 0}, -                     movement_points = 3, -                     atk_dist = 1 +                     id = "1", +                     name = "Char1", +                     icon = "Icon1", +                     team = 0, +                     portrait = "Portrait1", +                     location = {x = 1, y = 0}, +                     movement_points = 4, +                     atk_dist = 2                    } -                  Dict.empty +                  (Dict.insert +                     "0" +                     { +                        id = "0", +                        name = "Char0", +                        icon = "Icon0", +                        team = 0, +                        portrait = "Portrait0", +                        location = {x = 0, y = 0}, +                        movement_points = 5, +                        atk_dist = 1 +                     } +                     Dict.empty +                  )                 )              )           ), diff --git a/src/battlemap/src/Update.elm b/src/battlemap/src/Update.elm index 60d1f25..c62100d 100644 --- a/src/battlemap/src/Update.elm +++ b/src/battlemap/src/Update.elm @@ -37,3 +37,16 @@ update event model =        (Event.TabSelected tab) ->              ({model | ui = (UI.set_displayed_tab model.ui tab)}, Cmd.none) + +      (Event.DebugTeamSwitchRequest) -> +         if (model.controlled_team == 0) +         then +            ( +               (Model.reset {model | controlled_team = 1} model.characters), +               Cmd.none +            ) +         else +            ( +               (Model.reset {model | controlled_team = 0} model.characters), +               Cmd.none +            ) diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm index 450a392..beac2ab 100644 --- a/src/battlemap/src/View/Battlemap.elm +++ b/src/battlemap/src/View/Battlemap.elm @@ -39,6 +39,12 @@ char_on_map char =              (Html.Attributes.class                 ("asset-character-icon-" ++ (Character.get_icon_id char))              ), +            (Html.Attributes.class +               ( +                  "battlemap-character-team-" +                  ++ (toString (Character.get_team char)) +               ) +            ),              (Html.Events.onClick                 (Event.CharacterSelected (Character.get_ref char))              ), diff --git a/src/battlemap/src/View/Footer/TabMenu/Settings.elm b/src/battlemap/src/View/Footer/TabMenu/Settings.elm index f11fde0..07115e7 100644 --- a/src/battlemap/src/View/Footer/TabMenu/Settings.elm +++ b/src/battlemap/src/View/Footer/TabMenu/Settings.elm @@ -37,6 +37,12 @@ get_html model =        [           (scale_button (0.75) "Zoom -"),           (scale_button 0 "Zoom Reset"), -         (scale_button (1.15) "Zoom +") +         (scale_button (1.15) "Zoom +"), +         (Html.button +            [ +               (Html.Events.onClick Event.DebugTeamSwitchRequest) +            ] +            [ (Html.text "[DEBUG] Switch team") ] +         )        ]     ) diff --git a/src/battlemap/www/index.html b/src/battlemap/www/index.html index 1c4969d..cad620b 100644 --- a/src/battlemap/www/index.html +++ b/src/battlemap/www/index.html @@ -83,17 +83,22 @@        .asset-character-icon-Icon0        { -         background-color: cyan; +         background-color: Aqua;        }        .asset-character-icon-Icon1        { -         background-color: blue; +         background-color: Aquamarine;        }        .asset-character-icon-Icon2        { -         background-color: darkblue; +         background-color: Purple; +      } + +      .asset-character-icon-Icon3 +      { +         background-color: RebeccaPurple;        }        .battlemap-marker-icon | 


