| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src/battle')
| -rw-r--r-- | src/battle/src/Comm/Send.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Struct/Character.elm | 41 | ||||
| -rw-r--r-- | src/battle/src/Struct/Model.elm | 16 | ||||
| -rw-r--r-- | src/battle/src/Struct/ServerReply.elm | 2 | ||||
| -rw-r--r-- | src/battle/src/Update/HandleServerReply.elm | 27 | ||||
| -rw-r--r-- | src/battle/src/View/Character.elm | 16 | ||||
| -rw-r--r-- | src/battle/src/View/Map/Character.elm | 9 | 
7 files changed, 81 insertions, 32 deletions
| diff --git a/src/battle/src/Comm/Send.elm b/src/battle/src/Comm/Send.elm index d577e58..ae648cb 100644 --- a/src/battle/src/Comm/Send.elm +++ b/src/battle/src/Comm/Send.elm @@ -8,6 +8,7 @@ import Json.Encode  -- Battle ----------------------------------------------------------------------  import Comm.AddArmor +import Comm.AddPortrait  import Comm.AddChar  import Comm.AddTile  import Comm.AddWeapon @@ -32,6 +33,7 @@ internal_decoder reply_type =        "add_tile" -> (Comm.AddTile.decode)        "add_armor" -> (Comm.AddArmor.decode)        "add_char" -> (Comm.AddChar.decode) +      "add_portrait" -> (Comm.AddPortrait.decode)        "add_weapon" -> (Comm.AddWeapon.decode)        "set_map" -> (Comm.SetMap.decode)        "turn_results" -> (Comm.TurnResults.decode) diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index 322d67a..9259ec5 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -7,10 +7,8 @@ module Struct.Character exposing        get_player_ix,        get_name,        get_rank, -      get_icon_id, -      get_portrait_id, +      get_portrait,        get_armor, -      get_armor_variation,        get_current_health,        get_current_omnimods,        get_sane_current_health, @@ -37,6 +35,7 @@ import Json.Decode.Pipeline  -- Map -------------------------------------------------------------------  import Struct.Armor +import Struct.Portrait  import Struct.Attributes  import Struct.Location  import Struct.Omnimods @@ -52,7 +51,6 @@ type alias PartiallyDecoded =        ix : Int,        nam : String,        rnk : String, -      ico : String,        prt : String,        lc : Struct.Location.Type,        hea : Int, @@ -76,8 +74,7 @@ type alias Type =        ix : Int,        name : String,        rank : Rank, -      icon : String, -      portrait : String, +      portrait : Struct.Portrait.Type,        location : Struct.Location.Type,        health : Int,        player_ix : Int, @@ -96,7 +93,8 @@ type alias TypeAndEquipmentRef =        char : Type,        main_weapon_ref : String,        secondary_weapon_ref : String, -      armor_ref : String +      armor_ref : String, +      portrait_ref : String     }  -------------------------------------------------------------------------------- @@ -114,14 +112,14 @@ finish_decoding add_char =     let        weapon_set = (Struct.WeaponSet.new Struct.Weapon.none Struct.Weapon.none)        armor = Struct.Armor.none +      portrait = Struct.Portrait.none        default_attributes = (Struct.Attributes.default)        almost_char =           {              ix = add_char.ix,              name = add_char.nam,              rank = (str_to_rank add_char.rnk), -            icon = add_char.ico, -            portrait = add_char.prt, +            portrait = portrait,              location = add_char.lc,              health = add_char.hea,              attributes = default_attributes, @@ -139,7 +137,8 @@ finish_decoding add_char =           char = almost_char,           main_weapon_ref = add_char.awp,           secondary_weapon_ref = add_char.swp, -         armor_ref = add_char.ar +         armor_ref = add_char.ar, +         portrait_ref = add_char.prt        }  -------------------------------------------------------------------------------- @@ -157,12 +156,6 @@ get_rank c = c.rank  get_player_ix : Type -> Int  get_player_ix c = c.player_ix -get_icon_id : Type -> String -get_icon_id c = c.icon - -get_portrait_id : Type -> String -get_portrait_id c = c.portrait -  get_current_health : Type -> Int  get_current_health c = c.health @@ -208,13 +201,8 @@ get_weapons char = char.weapons  get_armor : Type -> Struct.Armor.Type  get_armor char = char.armor -get_armor_variation : Type -> String -get_armor_variation char = -   case char.portrait of -      -- Currently hardcoded to match crows from characters.css -      "11" -> "1" -      "4" -> "1" -      _ -> "0" +get_portrait : Type -> Struct.Portrait.Type +get_portrait char = char.portrait  set_weapons : Struct.WeaponSet.Type -> Type -> Type  set_weapons weapons char = @@ -231,7 +219,6 @@ decoder =           |> (Json.Decode.Pipeline.required "ix" Json.Decode.int)           |> (Json.Decode.Pipeline.required "nam" Json.Decode.string)           |> (Json.Decode.Pipeline.required "rnk" Json.Decode.string) -         |> (Json.Decode.Pipeline.required "ico" Json.Decode.string)           |> (Json.Decode.Pipeline.required "prt" Json.Decode.string)           |> (Json.Decode.Pipeline.required "lc" Struct.Location.decoder)           |> (Json.Decode.Pipeline.required "hea" Json.Decode.int) @@ -294,13 +281,14 @@ refresh_omnimods tile_omnimods_fun char =  fill_missing_equipment_and_omnimods : (        (Struct.Location.Type -> Struct.Omnimods.Type) -> +      Struct.Portrait.Type ->        Struct.Weapon.Type ->        Struct.Weapon.Type ->        Struct.Armor.Type ->        Type ->        Type     ) -fill_missing_equipment_and_omnimods tile_omnimods_fun awp swp ar char = +fill_missing_equipment_and_omnimods tile_omnimods_fun pt awp swp ar char =     (set_current_health        -- We just changed the omnimods, but already had the right health value        char.health @@ -308,7 +296,8 @@ fill_missing_equipment_and_omnimods tile_omnimods_fun awp swp ar char =           (tile_omnimods_fun)           {char |              weapons = (Struct.WeaponSet.new awp swp), -            armor = ar +            armor = ar, +            portrait = pt           }        )     ) diff --git a/src/battle/src/Struct/Model.elm b/src/battle/src/Struct/Model.elm index 8722066..0512249 100644 --- a/src/battle/src/Struct/Model.elm +++ b/src/battle/src/Struct/Model.elm @@ -7,6 +7,7 @@ module Struct.Model exposing        update_character_fun,        add_weapon,        add_armor, +      add_portrait,        add_tile,        invalidate,        initialize_animator, @@ -35,6 +36,7 @@ import Struct.HelpRequest  import Struct.Location  import Struct.Map  import Struct.Omnimods +import Struct.Portrait  import Struct.Tile  import Struct.TurnResult  import Struct.TurnResultAnimator @@ -55,6 +57,7 @@ type alias Type =        characters: (Array.Array Struct.Character.Type),        weapons: (Dict.Dict Struct.Weapon.Ref Struct.Weapon.Type),        armors: (Dict.Dict Struct.Armor.Ref Struct.Armor.Type), +      portraits: (Dict.Dict Struct.Portrait.Ref Struct.Portrait.Type),        tiles: (Dict.Dict Struct.Tile.Ref Struct.Tile.Type),        error: (Maybe Struct.Error.Type),        player_id: String, @@ -90,6 +93,7 @@ new flags =              characters = (Array.empty),              weapons = (Dict.empty),              armors = (Dict.empty), +            portraits = (Dict.empty),              tiles = (Dict.empty),              error = Nothing,              battle_id = "", @@ -150,6 +154,17 @@ add_armor ar model =           )     } +add_portrait : Struct.Portrait.Type -> Type -> Type +add_portrait pt model = +   {model | +      portraits = +         (Dict.insert +            (Struct.Portrait.get_id pt) +            pt +            model.portraits +         ) +   } +  add_tile : Struct.Tile.Type -> Type -> Type  add_tile tl model =     {model | @@ -182,6 +197,7 @@ full_debug_reset model =        characters = (Array.empty),        weapons = (Dict.empty),        armors = (Dict.empty), +      portraits = (Dict.empty),        tiles = (Dict.empty),        error = Nothing,        ui = (Struct.UI.default), diff --git a/src/battle/src/Struct/ServerReply.elm b/src/battle/src/Struct/ServerReply.elm index 25a0b2f..59531aa 100644 --- a/src/battle/src/Struct/ServerReply.elm +++ b/src/battle/src/Struct/ServerReply.elm @@ -4,6 +4,7 @@ module Struct.ServerReply exposing (Type(..))  -- Battle ----------------------------------------------------------------------  import Struct.Armor +import Struct.Portrait  import Struct.Map  import Struct.Character  import Struct.Tile @@ -18,6 +19,7 @@ type Type =     Okay     | Disconnected     | AddArmor Struct.Armor.Type +   | AddPortrait Struct.Portrait.Type     | AddWeapon Struct.Weapon.Type     | AddCharacter Struct.Character.TypeAndEquipmentRef     | AddTile Struct.Tile.Type diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index f552d98..503831d 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -24,11 +24,12 @@ import Util.Http  import Constants.IO  import Struct.Armor -import Struct.Map  import Struct.Character  import Struct.Error  import Struct.Event +import Struct.Map  import Struct.Model +import Struct.Portrait  import Struct.ServerReply  import Struct.Tile  import Struct.TurnResult @@ -55,6 +56,16 @@ armor_getter model ref =        (Just w) -> w        Nothing -> Struct.Armor.none +portrait_getter : ( +      Struct.Model.Type -> +      Struct.Portrait.Ref -> +      Struct.Portrait.Type +   ) +portrait_getter model ref = +   case (Dict.get ref model.portraits) of +      (Just w) -> w +      Nothing -> Struct.Portrait.none +  -----------  disconnected : ( @@ -91,6 +102,15 @@ add_armor ar current_state =     let (model, cmds) = current_state in        ((Struct.Model.add_armor ar model), cmds) +add_portrait : ( +      Struct.Portrait.Type -> +      (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> +      (Struct.Model.Type, (List (Cmd Struct.Event.Type))) +   ) +add_portrait pt current_state = +   let (model, cmds) = current_state in +      ((Struct.Model.add_portrait pt model), cmds) +  add_tile : (        Struct.Tile.Type ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> @@ -120,11 +140,13 @@ add_character char_and_refs current_state =        awp = (weapon_getter model char_and_refs.main_weapon_ref)        swp = (weapon_getter model char_and_refs.secondary_weapon_ref)        ar = (armor_getter model char_and_refs.armor_ref) +      pt = (portrait_getter model char_and_refs.portrait_ref)     in        (           (Struct.Model.add_character              (Struct.Character.fill_missing_equipment_and_omnimods                 (Struct.Model.tile_omnimods_fun model) +               pt                 awp                 swp                 ar @@ -207,6 +229,9 @@ apply_command command current_state =        (Struct.ServerReply.AddArmor ar) ->           (add_armor ar current_state) +      (Struct.ServerReply.AddPortrait pt) -> +         (add_portrait pt current_state) +        (Struct.ServerReply.AddTile tl) ->           (add_tile tl current_state) diff --git a/src/battle/src/View/Character.elm b/src/battle/src/View/Character.elm index 9916723..49de74b 100644 --- a/src/battle/src/View/Character.elm +++ b/src/battle/src/View/Character.elm @@ -19,6 +19,7 @@ import Struct.Character  import Struct.CharacterTurn  import Struct.Event  import Struct.Model +import Struct.Portrait  import Struct.UI  -------------------------------------------------------------------------------- @@ -112,7 +113,13 @@ get_icon_head_html char =        [           (Html.Attributes.class "character-icon-head"),           (Html.Attributes.class -            ("asset-character-icon-" ++ (Struct.Character.get_icon_id char)) +            ( +               "asset-character-icon-" +               ++ +               (Struct.Portrait.get_icon_id +                  (Struct.Character.get_portrait char) +               ) +            )           )        ]        [ @@ -156,7 +163,7 @@ get_portrait_body_html char =           (Html.Attributes.class              (                 "asset-character-portrait-" -               ++ (Struct.Character.get_portrait_id char) +               ++ (Struct.Portrait.get_id (Struct.Character.get_portrait char))              )           )        ] @@ -179,7 +186,10 @@ get_portrait_armor_html char =           (Html.Attributes.class              (                 "asset-armor-variation-" -               ++ (Struct.Character.get_armor_variation char) +               ++ +               (Struct.Portrait.get_body_id +                  (Struct.Character.get_portrait char) +               )              )           )        ] diff --git a/src/battle/src/View/Map/Character.elm b/src/battle/src/View/Map/Character.elm index d7934d3..af41050 100644 --- a/src/battle/src/View/Map/Character.elm +++ b/src/battle/src/View/Map/Character.elm @@ -5,7 +5,7 @@ import Html  import Html.Attributes  import Html.Events --- Map  ------------------------------------------------------------------ +-- Battle ----------------------------------------------------------------------  import Constants.UI  import Util.Html @@ -14,6 +14,7 @@ import Struct.Character  import Struct.CharacterTurn  import Struct.Event  import Struct.Model +import Struct.Portrait  import Struct.TurnResult  import Struct.TurnResultAnimator  import Struct.UI @@ -145,7 +146,11 @@ get_head_html char =        [           (Html.Attributes.class "character-icon-head"),           (Html.Attributes.class -            ("asset-character-icon-" ++ (Struct.Character.get_icon_id char)) +            ("asset-character-icon-" ++ +               (Struct.Portrait.get_icon_id +                  (Struct.Character.get_portrait char) +               ) +            )           )        ]        [ | 


