| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 17:16:28 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-26 17:16:28 +0100 | 
| commit | 0a39977b8047382c8e311e40ac2adf3f34c61d7a (patch) | |
| tree | e16842bda771355d61c69e34fad263fbe8e6c1bf /src/battlemap | |
| parent | 3a2c3e43f956d5452b30f724f9d0ca29b2b18e26 (diff) | |
Got it to work, I think.
Diffstat (limited to 'src/battlemap')
| -rw-r--r-- | src/battlemap/src/Send/CharacterTurn.elm | 24 | ||||
| -rw-r--r-- | src/battlemap/src/Send/LoadBattlemap.elm | 7 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Character.elm | 14 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Model.elm | 2 | ||||
| -rw-r--r-- | src/battlemap/src/Update/HandleServerReply/AddChar.elm | 64 | ||||
| -rw-r--r-- | src/battlemap/src/Update/HandleServerReply/SetMap.elm | 20 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SwitchTeam.elm | 4 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap/Character.elm | 6 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/TabMenu/Status.elm | 4 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm | 26 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/Targets.elm | 4 | 
11 files changed, 92 insertions, 83 deletions
| diff --git a/src/battlemap/src/Send/CharacterTurn.elm b/src/battlemap/src/Send/CharacterTurn.elm index 86d197e..30f778c 100644 --- a/src/battlemap/src/Send/CharacterTurn.elm +++ b/src/battlemap/src/Send/CharacterTurn.elm @@ -30,16 +30,15 @@ try_encoding model =           (Just              (Json.Encode.object                 [ -                  ("session_token", (Json.Encode.string "0")), -                  ("player_id", (Json.Encode.string model.player_id)), -                  ("battlemap_id", (Json.Encode.string "0")), -                  ("instance_id", (Json.Encode.string "0")), +                  ("stk", (Json.Encode.string "0")), +                  ("pid", (Json.Encode.string model.player_id)), +                  ("bmi", (Json.Encode.string "0")),                    ( -                     "char_id", +                     "cix",                       (Json.Encode.string (Struct.Character.get_ref char))                    ),                    ( -                     "path", +                     "p",                       (Json.Encode.list                          (List.map                             ( @@ -54,11 +53,14 @@ try_encoding model =                       )                    ),                    ( -                     "targets_id", -                     (Json.Encode.list -                        (List.map -                           (Json.Encode.string) -                           (Struct.CharacterTurn.get_targets model.char_turn) +                     "tix", +                     (Json.Encode.string +                        ( +                           case +                              (Struct.CharacterTurn.get_targets model.char_turn) +                           of +                              [a] -> a +                              _ -> "-1"                          )                       )                    ) diff --git a/src/battlemap/src/Send/LoadBattlemap.elm b/src/battlemap/src/Send/LoadBattlemap.elm index f1857dc..0bd8342 100644 --- a/src/battlemap/src/Send/LoadBattlemap.elm +++ b/src/battlemap/src/Send/LoadBattlemap.elm @@ -23,10 +23,9 @@ try_encoding model =     (Just        (Json.Encode.object           [ -            ("session_token", (Json.Encode.string "0")), -            ("player_id", (Json.Encode.string model.player_id)), -            ("battlemap_id", (Json.Encode.string "0")), -            ("instance_id", (Json.Encode.string "0")) +            ("stk", (Json.Encode.string "0")), +            ("pid", (Json.Encode.string model.player_id)), +            ("bmi", (Json.Encode.string "0"))           ]        )     ) diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm index f2085d6..46ac8b2 100644 --- a/src/battlemap/src/Struct/Character.elm +++ b/src/battlemap/src/Struct/Character.elm @@ -4,7 +4,7 @@ module Struct.Character exposing        Ref,        new,        get_ref, -      get_team, +      get_player_id,        get_icon_id,        get_portrait_id,        get_current_health, @@ -35,7 +35,7 @@ type alias Type =        portrait : String,        location : Struct.Location.Type,        health : Int, -      team : Int, +      player_id : String,        enabled : Bool,        attributes : Struct.Attributes.Type,        statistics : Struct.Statistics.Type, @@ -58,7 +58,7 @@ new : (        String -> -- portrait        Struct.Location.Type -> -- location        Int -> -- health -      Int -> -- team +      String -> -- player_id        Bool -> -- enabled        Struct.Attributes.Type ->        Struct.WeaponSet.Type -> @@ -67,7 +67,7 @@ new : (  new     id name icon portrait     location health -   team enabled +   player_id enabled     attributes weapons =     {        id = id, @@ -82,7 +82,7 @@ new              attributes              weapons           ), -      team = team, +      player_id = player_id,        enabled = enabled,        weapons = weapons     } @@ -90,8 +90,8 @@ new  get_ref : Type -> Ref  get_ref c = c.id -get_team : Type -> Int -get_team c = c.team +get_player_id : Type -> String +get_player_id c = c.player_id  get_icon_id : Type -> String  get_icon_id c = c.icon diff --git a/src/battlemap/src/Struct/Model.elm b/src/battlemap/src/Struct/Model.elm index fc13655..2adaeba 100644 --- a/src/battlemap/src/Struct/Model.elm +++ b/src/battlemap/src/Struct/Model.elm @@ -30,7 +30,6 @@ type alias Type =        characters: (Dict.Dict Struct.Character.Ref Struct.Character.Type),        weapons: (Dict.Dict Struct.Weapon.Ref Struct.Weapon.Type),        error: (Maybe Struct.Error.Type), -      controlled_team: Int,        player_id: String,        ui: Struct.UI.Type,        char_turn: Struct.CharacterTurn.Type @@ -50,7 +49,6 @@ new =        characters = (Dict.empty),        weapons = (Data.Weapons.generate_dict),        error = Nothing, -      controlled_team = 0,        player_id = "0",        ui = (Struct.UI.default),        char_turn = (Struct.CharacterTurn.new) diff --git a/src/battlemap/src/Update/HandleServerReply/AddChar.elm b/src/battlemap/src/Update/HandleServerReply/AddChar.elm index 071be3a..382e68a 100644 --- a/src/battlemap/src/Update/HandleServerReply/AddChar.elm +++ b/src/battlemap/src/Update/HandleServerReply/AddChar.elm @@ -30,18 +30,18 @@ type alias CharAtt =  type alias CharData =     { -      id : String, -      name : String, -      icon : String, -      portrait : String, -      loc_x : Int, -      loc_y : Int, -      health : Int, -      team : Int, -      enabled : Bool, +      ix : Int, +      nam : String, +      ico : String, +      prt : String, +      lcx : Int, +      lcy : Int, +      hea : Int, +      pla : String, +      ena : Bool,        att : CharAtt, -      wp_0 : Int, -      wp_1 : Int +      awp : Int, +      swp : Int     }  -------------------------------------------------------------------------------- @@ -63,18 +63,18 @@ char_decoder : (Json.Decode.Decoder CharData)  char_decoder =     (Json.Decode.Pipeline.decode        CharData -      |> (Json.Decode.Pipeline.required "id" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "name" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "icon" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "portrait" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "loc_x" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "loc_y" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "health" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "team" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "enabled" Json.Decode.bool) +      |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "ico" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "prt" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "lcx" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "lcy" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "hea" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "pla" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "ena" Json.Decode.bool)        |> (Json.Decode.Pipeline.required "att" attributes_decoder) -      |> (Json.Decode.Pipeline.required "wp_0" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "wp_1" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "awp" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "swp" Json.Decode.int)     )  -------------------------------------------------------------------------------- @@ -92,14 +92,14 @@ apply_to model serialized_char =           (Struct.Model.add_character              model              (Struct.Character.new -               char_data.id -               char_data.name -               char_data.icon -               char_data.portrait -               {x = char_data.loc_x, y = char_data.loc_y} -               char_data.health -               char_data.team -               char_data.enabled +               (toString char_data.ix) +               char_data.nam +               char_data.ico +               char_data.prt +               {x = char_data.lcx, y = char_data.lcy} +               char_data.hea +               char_data.pla +               char_data.ena                 (Struct.Attributes.new                    char_data.att.con                    char_data.att.dex @@ -111,8 +111,8 @@ apply_to model serialized_char =                 (                    case                       ( -                        (Dict.get char_data.wp_0 model.weapons), -                        (Dict.get char_data.wp_1 model.weapons) +                        (Dict.get char_data.awp model.weapons), +                        (Dict.get char_data.swp model.weapons)                       )                    of                       ((Just wp_0), (Just wp_1)) -> diff --git a/src/battlemap/src/Update/HandleServerReply/SetMap.elm b/src/battlemap/src/Update/HandleServerReply/SetMap.elm index e7c993d..88eed11 100644 --- a/src/battlemap/src/Update/HandleServerReply/SetMap.elm +++ b/src/battlemap/src/Update/HandleServerReply/SetMap.elm @@ -16,9 +16,9 @@ import Struct.Tile  --------------------------------------------------------------------------------  type alias MapData =     { -      width : Int, -      height : Int, -      content : (List Int) +      w : Int, +      h : Int, +      t : (List Int)     }  -------------------------------------------------------------------------------- @@ -41,10 +41,10 @@ apply_to model serialized_map =     case        (Json.Decode.decodeString           (Json.Decode.map3 MapData -            (Json.Decode.field "width" Json.Decode.int) -            (Json.Decode.field "height" Json.Decode.int) +            (Json.Decode.field "w" Json.Decode.int) +            (Json.Decode.field "h" Json.Decode.int)              (Json.Decode.field -               "content" +               "t"                 (Json.Decode.list Json.Decode.int)              )           ) @@ -56,11 +56,11 @@ apply_to model serialized_map =              {model |                 battlemap =                    (Struct.Battlemap.new -                     map_data.width -                     map_data.height +                     map_data.w +                     map_data.h                       (List.indexedMap -                        (deserialize_tile map_data.width) -                        map_data.content +                        (deserialize_tile map_data.w) +                        map_data.t                       )                    )              } diff --git a/src/battlemap/src/Update/SwitchTeam.elm b/src/battlemap/src/Update/SwitchTeam.elm index 09319f3..ec54369 100644 --- a/src/battlemap/src/Update/SwitchTeam.elm +++ b/src/battlemap/src/Update/SwitchTeam.elm @@ -17,12 +17,11 @@ apply_to : (        (Struct.Model.Type, (Cmd Struct.Event.Type))     )  apply_to model = -   if (model.controlled_team == 0) +   if (model.player_id == "0")     then        (           (Struct.Model.reset              {model | -               controlled_team = 1,                 player_id = "1"              }              model.characters @@ -33,7 +32,6 @@ apply_to model =        (           (Struct.Model.reset              {model | -               controlled_team = 0,                 player_id = "0"              }              model.characters diff --git a/src/battlemap/src/View/Battlemap/Character.elm b/src/battlemap/src/View/Battlemap/Character.elm index 714e0a5..80be31f 100644 --- a/src/battlemap/src/View/Battlemap/Character.elm +++ b/src/battlemap/src/View/Battlemap/Character.elm @@ -39,12 +39,6 @@ get_html char =              (Html.Attributes.class                 ("asset-character-icon-" ++ (Struct.Character.get_icon_id char))              ), -            (Html.Attributes.class -               ( -                  "battlemap-character-team-" -                  ++ (toString (Struct.Character.get_team char)) -               ) -            ),              (Html.Attributes.class "clickable"),              (Html.Events.onClick                 (Struct.Event.CharacterSelected (Struct.Character.get_ref char)) diff --git a/src/battlemap/src/View/SideBar/TabMenu/Status.elm b/src/battlemap/src/View/SideBar/TabMenu/Status.elm index 6503e51..1eb3e5e 100644 --- a/src/battlemap/src/View/SideBar/TabMenu/Status.elm +++ b/src/battlemap/src/View/SideBar/TabMenu/Status.elm @@ -34,8 +34,8 @@ get_char_info_html model char_ref =              (                 "Focusing "                 ++ char.name -               ++ " (Team " -               ++ (toString (Struct.Character.get_team char)) +               ++ " (Player " +               ++ (Struct.Character.get_player_id char)                 ++ "): "                 ++                 (toString diff --git a/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm b/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm index 6620ecc..cb48108 100644 --- a/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm +++ b/src/battlemap/src/View/SideBar/TabMenu/Status/CharacterInfo.elm @@ -273,14 +273,32 @@ get_html model char =              [              ]              [ -               (Html.dt [] [(Html.text "Team")]), +               (Html.dt [] [(Html.text "Location")]), +               (Html.dd +                  [] +                  ( +                     let +                        location = (Struct.Character.get_location char) +                     in +                        [ +                           (Html.text +                              ( +                                 (toString location.x) +                                 ++ +                                 ", " +                                 ++ +                                 (toString location.y) +                              ) +                           ) +                        ] +                  ) +               ), +               (Html.dt [] [(Html.text "Player")]),                 (Html.dd                    []                    [                       (Html.text -                        (toString -                           (Struct.Character.get_team char) -                        ) +                        (Struct.Character.get_player_id char)                       )                    ]                 ), diff --git a/src/battlemap/src/View/SideBar/Targets.elm b/src/battlemap/src/View/SideBar/Targets.elm index 4cda8d2..9594eca 100644 --- a/src/battlemap/src/View/SideBar/Targets.elm +++ b/src/battlemap/src/View/SideBar/Targets.elm @@ -30,8 +30,8 @@ get_target_info_html model char_ref =              (                 "Attacking "                 ++ char.name -               ++ " (Team " -               ++ (toString (Struct.Character.get_team char)) +               ++ " (player " +               ++ (Struct.Character.get_player_id char)                 ++ "): "                 ++                 (toString | 


