summaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/asset/www/svg/tile/-1.svg | 181 | ||||
-rw-r--r-- | src/battlemap/src/Comm/AddArmor.elm | 8 | ||||
-rw-r--r-- | src/battlemap/src/Comm/AddChar.elm | 9 | ||||
-rw-r--r-- | src/battlemap/src/Comm/AddTile.elm | 5 | ||||
-rw-r--r-- | src/battlemap/src/Comm/AddWeapon.elm | 6 | ||||
-rw-r--r-- | src/battlemap/src/Comm/Send.elm | 26 | ||||
-rw-r--r-- | src/battlemap/src/Comm/SetMap.elm | 7 | ||||
-rw-r--r-- | src/battlemap/src/Struct/Battlemap.elm | 7 | ||||
-rw-r--r-- | src/battlemap/src/Struct/Tile.elm | 69 | ||||
-rw-r--r-- | src/battlemap/src/Struct/UI.elm | 1 | ||||
-rw-r--r-- | src/battlemap/src/Update/HandleServerReply.elm | 3 | ||||
-rw-r--r-- | src/battlemap/src/Update/SendLoadBattlemapRequest.elm | 2 |
12 files changed, 260 insertions, 64 deletions
diff --git a/src/asset/www/svg/tile/-1.svg b/src/asset/www/svg/tile/-1.svg new file mode 100644 index 0000000..ef31ace --- /dev/null +++ b/src/asset/www/svg/tile/-1.svg @@ -0,0 +1,181 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="96mm" + height="96mm" + viewBox="0 0 96 96" + version="1.1" + id="svg8" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + sodipodi:docname="-1.svg"> + <defs + id="defs2" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.86" + inkscape:cx="194.22928" + inkscape:cy="191.07429" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="true" + showguides="false" + inkscape:window-width="1678" + inkscape:window-height="1029" + inkscape:window-x="1" + inkscape:window-y="516" + inkscape:window-maximized="0" + inkscape:snap-global="false"> + <inkscape:grid + type="xygrid" + id="grid882" + units="mm" + spacingx="31.999999" + spacingy="31.999999" /> + </sodipodi:namedview> + <metadata + id="metadata5"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="background" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-201)" + style="display:inline"> + <rect + style="opacity:1;fill:#800080;fill-opacity:1;stroke:none;stroke-width:9.41215611;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect4504" + width="96" + height="96" + x="0" + y="201" /> + <flowRoot + xml:space="preserve" + id="flowRoot1100" + style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" + transform="matrix(0.26458333,0,0,0.26458333,0,201)"><flowRegion + id="flowRegion1102"><rect + id="rect1104" + width="68.817207" + height="66.666664" + x="15.053763" + y="35.415291" /></flowRegion><flowPara + id="flowPara1106">ERROR</flowPara></flowRoot> <g + aria-label="error" + style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332" + id="text1110"> + <path + d="m 39.982403,249.52193 h -4.216797 q 0.05684,0.50643 0.273885,0.75448 0.304891,0.35657 0.795817,0.35657 0.310059,0 0.589111,-0.15503 0.170532,-0.0982 0.366903,-0.34624 l 2.072225,0.19121 q -0.475423,0.82682 -1.147217,1.18855 -0.671794,0.35657 -1.927531,0.35657 -1.090373,0 -1.715657,-0.30489 -0.625285,-0.31006 -1.038697,-0.97668 -0.408243,-0.6718 -0.408243,-1.57613 0,-1.28675 0.821655,-2.08256 0.826823,-0.79582 2.27893,-0.79582 1.178223,0 1.860352,0.35657 0.682129,0.35656 1.038696,1.03352 0.356568,0.67697 0.356568,1.76217 z m -2.139405,-1.00769 q -0.06201,-0.60978 -0.330729,-0.87333 -0.26355,-0.26355 -0.697632,-0.26355 -0.501261,0 -0.800984,0.39791 -0.191203,0.24805 -0.24288,0.73897 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, ';fill:#ffffff;stroke-width:0.26458332" + id="path1112" /> + <path + d="m 40.979758,246.25598 h 1.968872 v 0.89917 q 0.28422,-0.58394 0.583944,-0.80098 0.304891,-0.22221 0.749308,-0.22221 0.465088,0 1.018026,0.28939 l -0.651123,1.49861 q -0.372071,-0.15503 -0.589112,-0.15503 -0.413411,0 -0.640788,0.34107 -0.325561,0.48059 -0.325561,1.79834 v 1.83968 h -2.113566 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, ';fill:#ffffff;stroke-width:0.26458332" + id="path1114" /> + <path + d="m 46.126731,246.25598 h 1.968872 v 0.89917 q 0.28422,-0.58394 0.583943,-0.80098 0.304891,-0.22221 0.749309,-0.22221 0.465087,0 1.018025,0.28939 l -0.651123,1.49861 q -0.37207,-0.15503 -0.589111,-0.15503 -0.413412,0 -0.640788,0.34107 -0.325561,0.48059 -0.325561,1.79834 v 1.83968 h -2.113566 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, ';fill:#ffffff;stroke-width:0.26458332" + id="path1116" /> + <path + d="m 50.705262,249.0155 q 0,-1.25573 0.847493,-2.06705 0.847494,-0.81649 2.289266,-0.81649 1.648478,0 2.490804,0.95601 0.676961,0.76998 0.676961,1.89653 0,1.26607 -0.842325,2.07739 -0.837159,0.80615 -2.320272,0.80615 -1.322917,0 -2.139404,-0.67179 -1.002523,-0.83199 -1.002523,-2.18075 z m 2.108398,-0.005 q 0,0.7338 0.294556,1.0852 0.299723,0.3514 0.749308,0.3514 0.454753,0 0.744141,-0.34623 0.294555,-0.34623 0.294555,-1.11105 0,-0.71313 -0.294555,-1.05936 -0.294556,-0.3514 -0.728638,-0.3514 -0.45992,0 -0.759643,0.35657 -0.299724,0.3514 -0.299724,1.07487 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, ';fill:#ffffff;stroke-width:0.26458332" + id="path1118" /> + <path + d="m 58.053651,246.25598 h 1.968872 v 0.89917 q 0.28422,-0.58394 0.583943,-0.80098 0.304891,-0.22221 0.749308,-0.22221 0.465088,0 1.018026,0.28939 l -0.651123,1.49861 q -0.37207,-0.15503 -0.589111,-0.15503 -0.413412,0 -0.640788,0.34107 -0.325561,0.48059 -0.325561,1.79834 v 1.83968 h -2.113566 z" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Arial Black';-inkscape-font-specification:'Arial Black, ';fill:#ffffff;stroke-width:0.26458332" + id="path1120" /> + </g> + <use + x="0" + y="0" + xlink:href="#text1110" + id="use1123" + transform="translate(-32.000202)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1123" + id="use1125" + transform="translate(64)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1125" + id="use1127" + transform="translate(0,31.99996)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1127" + id="use1129" + transform="translate(-32)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1129" + id="use1131" + transform="translate(-32)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1131" + id="use1133" + transform="translate(0,-64)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1133" + id="use1135" + transform="translate(32)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#use1135" + id="use1137" + transform="translate(32)" + width="100%" + height="100%" /> + </g> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="details" + transform="translate(0,64)" + style="display:inline" /> +</svg> diff --git a/src/battlemap/src/Comm/AddArmor.elm b/src/battlemap/src/Comm/AddArmor.elm index 7633521..ad9df3e 100644 --- a/src/battlemap/src/Comm/AddArmor.elm +++ b/src/battlemap/src/Comm/AddArmor.elm @@ -5,7 +5,6 @@ import Json.Decode -- Battlemap ------------------------------------------------------------------- import Struct.Armor -import Struct.Model import Struct.ServerReply -------------------------------------------------------------------------------- @@ -16,11 +15,10 @@ import Struct.ServerReply -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- internal_decoder : Struct.Armor.Type -> Struct.ServerReply.Type -internal_decoder wp = (Struct.ServerReply.AddArmor wp) +internal_decoder ar = (Struct.ServerReply.AddArmor ar) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -decode : (Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type)) -decode model = - (Json.Decode.map (internal_decoder) (Struct.Armor.decoder)) +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map (internal_decoder) (Struct.Armor.decoder)) diff --git a/src/battlemap/src/Comm/AddChar.elm b/src/battlemap/src/Comm/AddChar.elm index 1b5cacd..ebe8656 100644 --- a/src/battlemap/src/Comm/AddChar.elm +++ b/src/battlemap/src/Comm/AddChar.elm @@ -5,7 +5,6 @@ import Json.Decode -- Battlemap ------------------------------------------------------------------- import Struct.Character -import Struct.Model import Struct.ServerReply -------------------------------------------------------------------------------- @@ -25,9 +24,5 @@ internal_decoder char_and_refs = (Struct.ServerReply.AddCharacter char_and_refs) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -decode : (Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type)) -decode model = - (Json.Decode.map - (internal_decoder) - (Struct.Character.decoder) - ) +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map (internal_decoder) (Struct.Character.decoder)) diff --git a/src/battlemap/src/Comm/AddTile.elm b/src/battlemap/src/Comm/AddTile.elm index ff184fd..d0a3ce8 100644 --- a/src/battlemap/src/Comm/AddTile.elm +++ b/src/battlemap/src/Comm/AddTile.elm @@ -5,7 +5,6 @@ import Json.Decode -- Battlemap ------------------------------------------------------------------- import Struct.Tile -import Struct.Model import Struct.ServerReply -------------------------------------------------------------------------------- @@ -21,5 +20,5 @@ internal_decoder wp = (Struct.ServerReply.AddTile wp) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -decode : (Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type)) -decode model = (Json.Decode.map (internal_decoder) (Struct.Tile.decoder)) +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map (internal_decoder) (Struct.Tile.decoder)) diff --git a/src/battlemap/src/Comm/AddWeapon.elm b/src/battlemap/src/Comm/AddWeapon.elm index 3a5c1f1..b41c054 100644 --- a/src/battlemap/src/Comm/AddWeapon.elm +++ b/src/battlemap/src/Comm/AddWeapon.elm @@ -5,7 +5,6 @@ import Json.Decode -- Battlemap ------------------------------------------------------------------- import Struct.Weapon -import Struct.Model import Struct.ServerReply -------------------------------------------------------------------------------- @@ -21,6 +20,5 @@ internal_decoder wp = (Struct.ServerReply.AddWeapon wp) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -decode : (Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type)) -decode model = - (Json.Decode.map (internal_decoder) (Struct.Weapon.decoder)) +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map (internal_decoder) (Struct.Weapon.decoder)) diff --git a/src/battlemap/src/Comm/Send.elm b/src/battlemap/src/Comm/Send.elm index 45be5d0..a6129cd 100644 --- a/src/battlemap/src/Comm/Send.elm +++ b/src/battlemap/src/Comm/Send.elm @@ -26,18 +26,14 @@ import Struct.Model -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -internal_decoder : ( - Struct.Model.Type -> - String -> - (Json.Decode.Decoder Struct.ServerReply.Type) - ) -internal_decoder model reply_type = +internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type) +internal_decoder reply_type = case reply_type of - "add_tile" -> (Comm.AddTile.decode model) - "add_armor" -> (Comm.AddArmor.decode model) - "add_char" -> (Comm.AddChar.decode model) - "add_weapon" -> (Comm.AddWeapon.decode model) - "set_map" -> (Comm.SetMap.decode model) + "add_tile" -> (Comm.AddTile.decode) + "add_armor" -> (Comm.AddArmor.decode) + "add_char" -> (Comm.AddChar.decode) + "add_weapon" -> (Comm.AddWeapon.decode) + "set_map" -> (Comm.SetMap.decode) "turn_results" -> (Comm.TurnResults.decode) "set_timeline" -> (Comm.SetTimeline.decode) other -> @@ -49,10 +45,10 @@ internal_decoder model reply_type = ) ) -decode : Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type) -decode model = +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.field "msg" Json.Decode.string) - |> (Json.Decode.andThen (internal_decoder model)) + |> (Json.Decode.andThen (internal_decoder)) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -72,7 +68,7 @@ try_sending model recipient try_encoding_fun = (Http.post recipient (Http.jsonBody serial) - (Json.Decode.list (decode model)) + (Json.Decode.list (decode)) ) ) ) diff --git a/src/battlemap/src/Comm/SetMap.elm b/src/battlemap/src/Comm/SetMap.elm index 84e4b5f..dc499cf 100644 --- a/src/battlemap/src/Comm/SetMap.elm +++ b/src/battlemap/src/Comm/SetMap.elm @@ -5,7 +5,6 @@ import Json.Decode -- Battlemap ------------------------------------------------------------------- import Struct.Battlemap -import Struct.Model import Struct.ServerReply import Struct.Tile @@ -27,7 +26,7 @@ deserialize_tile_instance map_width index id = (Struct.Tile.new_instance (index % map_width) (index // map_width) - (toString id) + id -1 -1 ) @@ -48,8 +47,8 @@ internal_decoder map_data = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -decode : (Struct.Model.Type -> (Json.Decode.Decoder Struct.ServerReply.Type)) -decode model = +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map internal_decoder (Json.Decode.map3 MapData diff --git a/src/battlemap/src/Struct/Battlemap.elm b/src/battlemap/src/Struct/Battlemap.elm index 5387039..80de9c3 100644 --- a/src/battlemap/src/Struct/Battlemap.elm +++ b/src/battlemap/src/Struct/Battlemap.elm @@ -14,8 +14,6 @@ module Struct.Battlemap exposing -- Elm ------------------------------------------------------------------------- import Array -import Dict - -- Battlemap ------------------------------------------------------------------- import Struct.Character import Struct.Tile @@ -117,9 +115,8 @@ get_movement_cost_function bmap start_loc char_list loc = else Constants.Movement.cost_when_out_of_bounds -solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type +solve_tiles : (List Struct.Tile.Type) -> Type -> Type solve_tiles tiles bmap = {bmap | - content = - (Array.map (Struct.Tile.solve_tile_instance tiles) bmap.content) + content = (Array.map (Struct.Tile.solve_tile_instance tiles) bmap.content) } diff --git a/src/battlemap/src/Struct/Tile.elm b/src/battlemap/src/Struct/Tile.elm index 3bd2336..405db95 100644 --- a/src/battlemap/src/Struct/Tile.elm +++ b/src/battlemap/src/Struct/Tile.elm @@ -20,7 +20,8 @@ module Struct.Tile exposing ) -- Elm ------------------------------------------------------------------------- -import Dict +import Debug +import List import Json.Decode import Json.Decode.Pipeline @@ -57,7 +58,7 @@ type alias Type = type alias Instance = { location : Struct.Location.Type, - icon_id : String, + icon_id : Int, crossing_cost : Int, type_id : Int } @@ -79,6 +80,25 @@ finish_decoding add_tile = range_maximum = add_tile.rma } +seek_tile_instance_type : Instance -> Type -> (Maybe Type) -> (Maybe Type) +seek_tile_instance_type instance candidate current_sol = + if (current_sol == Nothing) + then + let + icon_id = instance.icon_id + in + if + ( + (icon_id >= candidate.range_minimum) + && (icon_id <= candidate.range_maximum) + ) + then + (Just candidate) + else + current_sol + else + current_sol + -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -92,7 +112,7 @@ new id name crossing_cost range_minimum range_maximum = range_maximum = range_maximum } -new_instance : Int -> Int -> String -> Int -> Int -> Instance +new_instance : Int -> Int -> Int -> Int -> Int -> Instance new_instance x y icon_id crossing_cost type_id = { location = {x = x, y = y}, @@ -105,7 +125,7 @@ error_tile_instance : Int -> Int -> Instance error_tile_instance x y = { location = {x = x, y = y}, - icon_id = "error", + icon_id = -1, type_id = -1, crossing_cost = Constants.Movement.cost_when_out_of_bounds } @@ -133,7 +153,7 @@ get_location : Instance -> Struct.Location.Type get_location tile_inst = tile_inst.location get_icon_id : Instance -> String -get_icon_id tile_inst = tile_inst.icon_id +get_icon_id tile_inst = (toString tile_inst.icon_id) get_variant_id : Instance -> Int get_variant_id tile_inst = @@ -146,20 +166,33 @@ get_variant_id tile_inst = % Constants.UI.variants_per_tile ) -solve_tile_instance : (Dict.Dict Ref Type) -> Instance -> Instance +solve_tile_instance : (List Type) -> Instance -> Instance solve_tile_instance tiles tile_instance = - case (Dict.get tile_instance.type_id tiles) of - (Just tile) -> - {tile_instance | - type_id = tile.id, - crossing_cost = tile.crossing_cost - } - - Nothing -> - (error_tile_instance - tile_instance.location.x - tile_instance.location.y - ) + let + maybe_type = + (List.foldr (seek_tile_instance_type tile_instance) Nothing tiles) + in + case maybe_type of + (Just tile) -> + {tile_instance | + type_id = tile.id, + crossing_cost = tile.crossing_cost + } + + Nothing -> + (Debug.log + ( + "Couldn't find tile type matching " + ++ (toString tile_instance.icon_id) + ++ " among " + ++ (toString (List.length tiles)) + ++ " candidates." + ) + (error_tile_instance + tile_instance.location.x + tile_instance.location.y + ) + ) decoder : (Json.Decode.Decoder Type) decoder = diff --git a/src/battlemap/src/Struct/UI.elm b/src/battlemap/src/Struct/UI.elm index fe1cfe1..447cfc4 100644 --- a/src/battlemap/src/Struct/UI.elm +++ b/src/battlemap/src/Struct/UI.elm @@ -27,7 +27,6 @@ module Struct.UI exposing ) -- Battlemap ------------------------------------------------------------------- -import Struct.Character import Struct.Location import Struct.Navigator diff --git a/src/battlemap/src/Update/HandleServerReply.elm b/src/battlemap/src/Update/HandleServerReply.elm index 5296f91..27ea1ac 100644 --- a/src/battlemap/src/Update/HandleServerReply.elm +++ b/src/battlemap/src/Update/HandleServerReply.elm @@ -105,7 +105,8 @@ set_map map current_state = (model, _) -> ( {model | - battlemap = (Struct.Battlemap.solve_tiles model.tiles map) + battlemap = + (Struct.Battlemap.solve_tiles (Dict.values model.tiles) map) }, Nothing ) diff --git a/src/battlemap/src/Update/SendLoadBattlemapRequest.elm b/src/battlemap/src/Update/SendLoadBattlemapRequest.elm index e55d60b..bb6ae6b 100644 --- a/src/battlemap/src/Update/SendLoadBattlemapRequest.elm +++ b/src/battlemap/src/Update/SendLoadBattlemapRequest.elm @@ -20,7 +20,7 @@ apply_to : ( ) apply_to model = ( - model, + (Struct.Model.full_debug_reset model), (case (Comm.LoadBattlemap.try model) of (Just cmd) -> cmd Nothing -> Cmd.none |