summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-01-24 12:53:47 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-01-24 12:53:47 +0100 |
commit | 5e50dc6efc50de1361fe93004701e943d786429f (patch) | |
tree | f949341a2c4b4dc5bde8b1aabe0e27a31e78ea3f | |
parent | 1755baf50913c822035b973b6cb499e7b78c91eb (diff) |
Now expects attributes to be sent by the server.
-rw-r--r-- | src/battlemap/src/Struct/Character.elm | 6 | ||||
-rw-r--r-- | src/battlemap/src/Update/HandleServerReply/AddChar.elm | 50 | ||||
-rw-r--r-- | src/battlemap/src/Update/SelectCharacter.elm | 7 |
3 files changed, 45 insertions, 18 deletions
diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm index a1d0597..7f40604 100644 --- a/src/battlemap/src/Struct/Character.elm +++ b/src/battlemap/src/Struct/Character.elm @@ -55,16 +55,16 @@ new : ( String -> -- portrait Struct.Location.Type -> -- location Int -> -- health - Struct.Attributes.Type -> Int -> -- team Bool -> -- enabled + Struct.Attributes.Type -> Type ) new id name icon portrait location health - attributes - team enabled = + team enabled + attributes = { id = id, name = name, diff --git a/src/battlemap/src/Update/HandleServerReply/AddChar.elm b/src/battlemap/src/Update/HandleServerReply/AddChar.elm index 517b942..ff554d5 100644 --- a/src/battlemap/src/Update/HandleServerReply/AddChar.elm +++ b/src/battlemap/src/Update/HandleServerReply/AddChar.elm @@ -5,6 +5,7 @@ import Json.Decode import Json.Decode.Pipeline -- Battlemap ------------------------------------------------------------------- +import Struct.Attributes import Struct.Character import Struct.Error import Struct.Model @@ -12,25 +13,45 @@ import Struct.Model -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +type alias CharAtt = + { + con : Int, + dex : Int, + int : Int, + min : Int, + spe : Int, + str : Int + } + type alias CharData = { id : String, name : String, icon : String, portrait : String, - health : Int, - max_health : Int, loc_x : Int, loc_y : Int, + health : Int, team : Int, - mov_pts : Int, - atk_rg : Int, - enabled : Bool + enabled : Bool, + att : CharAtt } -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +attributes_decoder : (Json.Decode.Decoder CharAtt) +attributes_decoder = + (Json.Decode.Pipeline.decode + CharAtt + |> (Json.Decode.Pipeline.required "con" Json.Decode.int) + |> (Json.Decode.Pipeline.required "dex" Json.Decode.int) + |> (Json.Decode.Pipeline.required "int" Json.Decode.int) + |> (Json.Decode.Pipeline.required "min" Json.Decode.int) + |> (Json.Decode.Pipeline.required "spe" Json.Decode.int) + |> (Json.Decode.Pipeline.required "str" Json.Decode.int) + ) + char_decoder : (Json.Decode.Decoder CharData) char_decoder = (Json.Decode.Pipeline.decode @@ -39,14 +60,12 @@ char_decoder = |> (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 "health" Json.Decode.int) - |> (Json.Decode.Pipeline.required "max_health" Json.Decode.int) |> (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 "mov_pts" Json.Decode.int) - |> (Json.Decode.Pipeline.required "atk_rg" Json.Decode.int) |> (Json.Decode.Pipeline.required "enabled" Json.Decode.bool) + |> (Json.Decode.Pipeline.required "att" attributes_decoder) ) -------------------------------------------------------------------------------- @@ -68,13 +87,18 @@ apply_to model serialized_char = char_data.name char_data.icon char_data.portrait - char_data.health - char_data.max_health {x = char_data.loc_x, y = char_data.loc_y} + char_data.health char_data.team - char_data.mov_pts - char_data.atk_rg char_data.enabled + (Struct.Attributes.new + char_data.att.con + char_data.att.dex + char_data.att.int + char_data.att.min + char_data.att.spe + char_data.att.str + ) ) ) diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm index 5c14ef8..a1062c0 100644 --- a/src/battlemap/src/Update/SelectCharacter.elm +++ b/src/battlemap/src/Update/SelectCharacter.elm @@ -13,6 +13,7 @@ import Struct.Event import Struct.Location import Struct.Model import Struct.Navigator +import Struct.Statistics import Struct.UI import Update.RequestDirection @@ -53,8 +54,10 @@ ctrl_or_focus_character model target_char_id target_char = ) (Struct.Navigator.new (Struct.Character.get_location target_char) - (Struct.Character.get_movement_points target_char) - (Struct.Character.get_attack_range target_char) + (Struct.Statistics.get_movement_points + (Struct.Character.get_statistics target_char) + ) + 1 -- Attack Range (Struct.Battlemap.get_movement_cost_function model.battlemap (Struct.Character.get_location target_char) |