summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-02-26 21:34:35 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-02-26 21:34:35 +0100
commitb055ce4b1e9f9b056f38739506157432a9a82875 (patch)
tree4f6bfc923be0ed7fa0312a76b7154deb7ca8adf9
parent3d945fe5726bf8da486973328a5e8f58f15d3663 (diff)
Splits Tile & TileInstance (Battle).
-rw-r--r--src/battle/src/Comm/SetMap.elm88
-rw-r--r--src/battle/src/Struct/Map.elm81
-rw-r--r--src/battle/src/Struct/Tile.elm110
-rw-r--r--src/battle/src/Struct/TileInstance.elm183
-rw-r--r--src/battle/src/View/Map/Tile.elm30
-rw-r--r--src/battle/src/View/SubMenu/Status/TileInfo.elm30
-rw-r--r--src/map-editor/src/Comm/SetMap.elm7
-rw-r--r--src/map-editor/src/Struct/TileInstance.elm16
8 files changed, 283 insertions, 262 deletions
diff --git a/src/battle/src/Comm/SetMap.elm b/src/battle/src/Comm/SetMap.elm
index e1cc565..10d527a 100644
--- a/src/battle/src/Comm/SetMap.elm
+++ b/src/battle/src/Comm/SetMap.elm
@@ -1,87 +1,19 @@
module Comm.SetMap exposing (decode)
-- Elm -------------------------------------------------------------------------
-import Dict
-
import Json.Decode
--- Battle ----------------------------------------------------------------------
-import Constants.Movement
-
+-- Map -------------------------------------------------------------------------
import Struct.Map
-import Struct.MapMarker
import Struct.ServerReply
-import Struct.Tile
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-type alias MapData =
- {
- w : Int,
- h : Int,
- t : (List (List String)),
- m : (Dict.Dict String Struct.MapMarker.Type)
- }
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-deserialize_tile_borders : (
- (List String) ->
- (List Struct.Tile.Border) ->
- (List Struct.Tile.Border)
- )
-deserialize_tile_borders rem_ints current_borders =
- case rem_ints of
- [] -> (List.reverse current_borders)
- (a :: (b :: c)) ->
- (deserialize_tile_borders
- c
- ((Struct.Tile.new_border a b) :: current_borders)
- )
-
- _ -> []
-
-deserialize_tile_instance : Int -> Int -> (List String) -> Struct.Tile.Instance
-deserialize_tile_instance map_width index t =
- case t of
- (a :: (b :: c)) ->
- (Struct.Tile.new_instance
- {
- x = (modBy map_width index),
- y = (index // map_width)
- }
- a
- b
- Constants.Movement.cost_when_out_of_bounds
- (deserialize_tile_borders c [])
- )
-
- _ ->
- (Struct.Tile.new_instance
- {
- x = (modBy map_width index),
- y = (index // map_width)
- }
- "0"
- "0"
- Constants.Movement.cost_when_out_of_bounds
- []
- )
-
-internal_decoder : MapData -> Struct.ServerReply.Type
-internal_decoder map_data =
- (Struct.ServerReply.SetMap
- (Struct.Map.new
- map_data.w
- map_data.h
- (List.indexedMap
- (deserialize_tile_instance map_data.w)
- map_data.t
- )
- )
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -89,20 +21,6 @@ internal_decoder map_data =
decode : (Json.Decode.Decoder Struct.ServerReply.Type)
decode =
(Json.Decode.map
- internal_decoder
- (Json.Decode.map4 MapData
- (Json.Decode.field "w" Json.Decode.int)
- (Json.Decode.field "h" Json.Decode.int)
- (Json.Decode.field
- "t"
- (Json.Decode.list (Json.Decode.list Json.Decode.string))
- )
- (Json.Decode.field
- "m"
- (Json.Decode.map
- (Dict.fromList)
- (Json.Decode.keyValuePairs (Struct.MapMarker.decoder))
- )
- )
- )
+ (\map -> (Struct.ServerReply.SetMap map))
+ (Struct.Map.decoder)
)
diff --git a/src/battle/src/Struct/Map.elm b/src/battle/src/Struct/Map.elm
index 8c2491d..8bd39ad 100644
--- a/src/battle/src/Struct/Map.elm
+++ b/src/battle/src/Struct/Map.elm
@@ -9,7 +9,8 @@ module Struct.Map exposing
get_movement_cost_function,
solve_tiles,
try_getting_tile_at,
- get_omnimods_at
+ get_omnimods_at,
+ decoder
)
-- Elm -------------------------------------------------------------------------
@@ -17,6 +18,8 @@ import Array
import Dict
+import Json.Decode
+
-- Battle ----------------------------------------------------------------------
import Constants.Movement
@@ -24,15 +27,18 @@ import Struct.Character
import Struct.Location
import Struct.Omnimods
import Struct.Tile
+import Struct.TileInstance
+import Struct.MapMarker
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
{
- width: Int,
- height: Int,
- content: (Array.Array Struct.Tile.Instance)
+ width : Int,
+ height : Int,
+ content : (Array.Array Struct.TileInstance.Type),
+ markers : (Dict.Dict String Struct.MapMarker.Type)
}
--------------------------------------------------------------------------------
@@ -60,32 +66,36 @@ get_width bmap = bmap.width
get_height : Type -> Int
get_height bmap = bmap.height
-get_tiles : Type -> (Array.Array Struct.Tile.Instance)
-get_tiles bmap = bmap.content
+get_tiles : Type -> (Array.Array Struct.TileInstance.Type)
+get_tiles map = map.content
empty : Type
empty =
{
width = 0,
height = 0,
- content = (Array.empty)
+ content = (Array.empty),
+ markers = (Dict.empty)
}
-new : Int -> Int -> (List Struct.Tile.Instance) -> Type
+new : Int -> Int -> (List Struct.TileInstance.Type) -> Type
new width height tiles =
{
width = width,
height = height,
- content = (Array.fromList tiles)
+ content = (Array.fromList tiles),
+ markers = (Dict.empty)
}
try_getting_tile_at : (
Struct.Location.Type ->
Type ->
- (Maybe Struct.Tile.Instance)
+ (Maybe Struct.TileInstance.Type)
)
-try_getting_tile_at loc bmap =
- (Array.get (location_to_index loc bmap) bmap.content)
+try_getting_tile_at loc map =
+ if (has_location loc map)
+ then (Array.get (location_to_index loc map) map.content)
+ else Nothing
get_movement_cost_function : (
Type ->
@@ -114,18 +124,12 @@ get_movement_cost_function bmap start_loc char_list loc =
then
Constants.Movement.cost_when_occupied_tile
else
- (Struct.Tile.get_instance_cost tile)
+ (Struct.TileInstance.get_cost tile)
Nothing -> Constants.Movement.cost_when_out_of_bounds
else
Constants.Movement.cost_when_out_of_bounds
-solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type
-solve_tiles tiles bmap =
- {bmap |
- content = (Array.map (Struct.Tile.solve_tile_instance tiles) bmap.content)
- }
-
get_omnimods_at : (
Struct.Location.Type ->
(Dict.Dict Struct.Tile.Ref Struct.Tile.Type) ->
@@ -136,6 +140,43 @@ get_omnimods_at loc tiles_solver map =
case (try_getting_tile_at loc map) of
Nothing -> (Struct.Omnimods.new [] [] [] [])
(Just tile_inst) ->
- case (Dict.get (Struct.Tile.get_type_id tile_inst) tiles_solver) of
+ case
+ (Dict.get (Struct.TileInstance.get_class_id tile_inst) tiles_solver)
+ of
Nothing -> (Struct.Omnimods.new [] [] [] [])
(Just tile) -> (Struct.Tile.get_omnimods tile)
+
+solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type
+solve_tiles tiles map =
+ {map |
+ content = (Array.map (Struct.TileInstance.solve tiles) map.content)
+ }
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.andThen
+ (\width ->
+ (Json.Decode.map4
+ Type
+ (Json.Decode.field "w" Json.Decode.int)
+ (Json.Decode.field "h" Json.Decode.int)
+ (Json.Decode.field
+ "t"
+ (Json.Decode.map
+ (Array.indexedMap
+ (Struct.TileInstance.set_location_from_index width)
+ )
+ (Json.Decode.array (Struct.TileInstance.decoder))
+ )
+ )
+ (Json.Decode.field
+ "m"
+ (Json.Decode.map
+ (Dict.fromList)
+ (Json.Decode.keyValuePairs (Struct.MapMarker.decoder))
+ )
+ )
+ )
+ )
+ (Json.Decode.field "w" Json.Decode.int)
+ )
diff --git a/src/battle/src/Struct/Tile.elm b/src/battle/src/Struct/Tile.elm
index 90e328f..37a4e0d 100644
--- a/src/battle/src/Struct/Tile.elm
+++ b/src/battle/src/Struct/Tile.elm
@@ -3,25 +3,11 @@ module Struct.Tile exposing
Ref,
VariantID,
Type,
- Instance,
- Border,
new,
- new_instance,
- new_border,
- error_tile_instance,
get_id,
get_name,
- get_borders,
- get_border_type_id,
- get_border_variant_id,
get_cost,
- get_instance_cost,
- get_location,
- get_type_id,
- get_variant_id,
- get_local_variant_ix,
get_omnimods,
- solve_tile_instance,
decoder
)
@@ -52,27 +38,9 @@ type alias Type =
omnimods : Struct.Omnimods.Type
}
-type alias Border =
- {
- type_id : Ref,
- variant_id : VariantID
- }
-
-type alias Instance =
- {
- location : Struct.Location.Type,
- crossing_cost : Int,
- type_id : Ref ,
- variant_id : VariantID,
- borders : (List Border)
- }
-
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-noise_function : Int -> Int -> Int -> Int
-noise_function a b c =
- (round (radians (toFloat ((a + 1) * 2 + (b + 1) * 3 + c))))
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -86,96 +54,18 @@ new id name crossing_cost omnimods =
omnimods = omnimods
}
-new_border : Ref -> VariantID -> Border
-new_border a b =
- {
- type_id = a,
- variant_id = b
- }
-
-new_instance : (
- Struct.Location.Type ->
- Ref ->
- VariantID ->
- Int ->
- (List Border) ->
- Instance
- )
-new_instance location type_id variant_id crossing_cost borders =
- {
- location = location,
- type_id = type_id,
- variant_id = variant_id,
- crossing_cost = crossing_cost,
- borders = borders
- }
-
-error_tile_instance : Int -> Int -> Instance
-error_tile_instance x y =
- {
- location = {x = x, y = y},
- type_id = "0",
- variant_id = "0",
- crossing_cost = Constants.Movement.cost_when_out_of_bounds,
- borders = []
- }
-
get_id : Type -> Ref
get_id tile = tile.id
get_cost : Type -> Int
get_cost tile = tile.crossing_cost
-get_instance_cost : Instance -> Int
-get_instance_cost tile_inst = tile_inst.crossing_cost
-
get_name : Type -> String
get_name tile = tile.name
-get_location : Instance -> Struct.Location.Type
-get_location tile_inst = tile_inst.location
-
-get_type_id : Instance -> Ref
-get_type_id tile_inst = tile_inst.type_id
-
-get_border_type_id : Border -> Ref
-get_border_type_id tile_border = tile_border.type_id
-
-get_borders : Instance -> (List Border)
-get_borders tile_inst = tile_inst.borders
-
-get_variant_id : Instance -> VariantID
-get_variant_id tile_inst = tile_inst.variant_id
-
-get_border_variant_id : Border -> VariantID
-get_border_variant_id tile_border = tile_border.variant_id
-
-get_local_variant_ix : Instance -> Int
-get_local_variant_ix tile_inst =
- (modBy
- Constants.UI.local_variants_per_tile
- (noise_function
- tile_inst.location.x
- tile_inst.location.y
- tile_inst.crossing_cost
- )
- )
-
get_omnimods : Type -> Struct.Omnimods.Type
get_omnimods t = t.omnimods
-solve_tile_instance : (Dict.Dict Ref Type) -> Instance -> Instance
-solve_tile_instance tiles tile_instance =
- case (Dict.get tile_instance.type_id tiles) of
- (Just tile) ->
- {tile_instance | crossing_cost = tile.crossing_cost}
-
- Nothing ->
- (error_tile_instance
- tile_instance.location.x
- tile_instance.location.y
- )
-
decoder : (Json.Decode.Decoder Type)
decoder =
(Json.Decode.succeed
diff --git a/src/battle/src/Struct/TileInstance.elm b/src/battle/src/Struct/TileInstance.elm
new file mode 100644
index 0000000..dba4151
--- /dev/null
+++ b/src/battle/src/Struct/TileInstance.elm
@@ -0,0 +1,183 @@
+module Struct.TileInstance exposing
+ (
+ Type,
+ Border,
+ clone,
+ get_location,
+ get_class_id,
+ get_cost,
+ default,
+ get_borders,
+ new_border,
+ get_variant_id,
+ get_border_variant_id,
+ get_border_class_id,
+ get_local_variant_ix,
+ error,
+ solve,
+ set_location_from_index,
+ decoder
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Battle ----------------------------------------------------------------------
+import Constants.UI
+import Constants.Movement
+
+import Struct.Tile
+import Struct.Location
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ location : Struct.Location.Type,
+ crossing_cost : Int,
+ class_id : Struct.Tile.Ref,
+ variant_id : Struct.Tile.VariantID,
+ triggers : (List String),
+ borders : (List Border)
+ }
+
+type alias Border =
+ {
+ class_id : Struct.Tile.Ref,
+ variant_id : Struct.Tile.VariantID
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+noise_function : Int -> Int -> Int -> Int
+noise_function a b c =
+ (round (radians (toFloat ((a + 1) * 2 + (b + 1) * 3 + c))))
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+clone : Struct.Location.Type -> Type -> Type
+clone loc inst = {inst | location = loc}
+
+new_border : Struct.Tile.Ref -> Struct.Tile.VariantID -> Border
+new_border class_id variant_id =
+ {
+ class_id = class_id,
+ variant_id = variant_id
+ }
+
+default : Struct.Tile.Type -> Type
+default tile =
+ {
+ location = {x = 0, y = 0},
+ class_id = (Struct.Tile.get_id tile),
+ variant_id = "0",
+ crossing_cost = (Struct.Tile.get_cost tile),
+ triggers = [],
+ borders = []
+ }
+
+error : Int -> Int -> Type
+error x y =
+ {
+ location = {x = x, y = y},
+ class_id = "0",
+ variant_id = "0",
+ crossing_cost = Constants.Movement.cost_when_out_of_bounds,
+ triggers = [],
+ borders = []
+ }
+
+get_class_id : Type -> Struct.Tile.Ref
+get_class_id inst = inst.class_id
+
+get_cost : Type -> Int
+get_cost inst = inst.crossing_cost
+
+get_location : Type -> Struct.Location.Type
+get_location inst = inst.location
+
+get_borders : Type -> (List Border)
+get_borders tile_inst = tile_inst.borders
+
+get_variant_id : Type -> Struct.Tile.VariantID
+get_variant_id tile_inst = tile_inst.variant_id
+
+get_border_variant_id : Border -> Struct.Tile.VariantID
+get_border_variant_id tile_border = tile_border.variant_id
+
+get_local_variant_ix : Type -> Int
+get_local_variant_ix tile_inst =
+ (modBy
+ Constants.UI.local_variants_per_tile
+ (noise_function
+ tile_inst.location.x
+ tile_inst.location.y
+ tile_inst.crossing_cost
+ )
+ )
+
+solve : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type
+solve tiles tile_inst =
+ case (Dict.get tile_inst.class_id tiles) of
+ (Just tile) -> {tile_inst | crossing_cost = (Struct.Tile.get_cost tile)}
+ Nothing -> {tile_inst | crossing_cost = -1}
+
+list_to_borders : (
+ (List String) ->
+ (List Border) ->
+ (List Border)
+ )
+list_to_borders list borders =
+ case list of
+ (a :: (b :: c)) ->
+ (list_to_borders
+ c
+ ({ class_id = a, variant_id = b } :: borders)
+ )
+ _ -> (List.reverse borders)
+
+decoder : (Json.Decode.Decoder Type)
+decoder =
+ (Json.Decode.andThen
+ (\tile_data ->
+ case tile_data of
+ (tile_id :: (variant_id :: borders)) ->
+ (Json.Decode.succeed
+ Type
+ |> (Json.Decode.Pipeline.hardcoded {x = 0, y = 0}) -- Location
+ |> (Json.Decode.Pipeline.hardcoded 0) -- Crossing Cost
+ |> (Json.Decode.Pipeline.hardcoded tile_id)
+ |> (Json.Decode.Pipeline.hardcoded variant_id)
+ |>
+ (Json.Decode.Pipeline.required
+ "t"
+ (Json.Decode.list (Json.Decode.string))
+ )
+ |>
+ (Json.Decode.Pipeline.hardcoded
+ (list_to_borders borders [])
+ )
+ )
+ _ -> (Json.Decode.succeed (error 0 0))
+ )
+ (Json.Decode.field "b" (Json.Decode.list (Json.Decode.string)))
+ )
+
+get_border_class_id : Border -> Struct.Tile.Ref
+get_border_class_id tile_border = tile_border.class_id
+
+set_location_from_index : Int -> Int -> Type -> Type
+set_location_from_index map_width index tile_inst =
+ {tile_inst |
+ location =
+ {
+ x = (modBy map_width index),
+ y = (index // map_width)
+ }
+ }
diff --git a/src/battle/src/View/Map/Tile.elm b/src/battle/src/View/Map/Tile.elm
index 172ca59..abadea1 100644
--- a/src/battle/src/View/Map/Tile.elm
+++ b/src/battle/src/View/Map/Tile.elm
@@ -11,14 +11,14 @@ import Constants.IO
import Struct.Event
import Struct.Location
-import Struct.Tile
+import Struct.TileInstance
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_layer_html : (
Int ->
- Struct.Tile.Border ->
+ Struct.TileInstance.Border ->
(Html.Html Struct.Event.Type)
)
get_layer_html index border =
@@ -30,9 +30,9 @@ get_layer_html index border =
(
"url("
++ Constants.IO.tile_assets_url
- ++ (Struct.Tile.get_border_type_id border)
+ ++ (Struct.TileInstance.get_border_class_id border)
++ "-f-"
- ++ (Struct.Tile.get_border_variant_id border)
+ ++ (Struct.TileInstance.get_border_variant_id border)
++ ".svg)"
)
)
@@ -43,7 +43,10 @@ get_layer_html index border =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_content_html : Struct.Tile.Instance -> (List (Html.Html Struct.Event.Type))
+get_content_html : (
+ Struct.TileInstance.Type ->
+ (List (Html.Html Struct.Event.Type))
+ )
get_content_html tile =
(
(Html.div
@@ -54,7 +57,7 @@ get_content_html tile =
(
"url("
++ Constants.IO.tile_assets_url
- ++ (Struct.Tile.get_type_id tile)
+ ++ (Struct.TileInstance.get_class_id tile)
++ "-bg.svg)"
)
)
@@ -71,9 +74,9 @@ get_content_html tile =
(
"url("
++ Constants.IO.tile_assets_url
- ++ (Struct.Tile.get_type_id tile)
+ ++ (Struct.TileInstance.get_class_id tile)
++ "-v-"
- ++ (Struct.Tile.get_variant_id tile)
+ ++ (Struct.TileInstance.get_variant_id tile)
++ ".svg)"
)
)
@@ -83,14 +86,14 @@ get_content_html tile =
::
(List.indexedMap
(get_layer_html)
- (Struct.Tile.get_borders tile)
+ (Struct.TileInstance.get_borders tile)
)
)
)
-get_html : Struct.Tile.Instance -> (Html.Html Struct.Event.Type)
+get_html : Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)
get_html tile =
- let tile_loc = (Struct.Tile.get_location tile) in
+ let tile_loc = (Struct.TileInstance.get_location tile) in
(Html.div
[
(Html.Attributes.class "tile-icon"),
@@ -98,7 +101,10 @@ get_html tile =
(Html.Attributes.class
(
"tile-variant-"
- ++ (String.fromInt (Struct.Tile.get_local_variant_ix tile))
+ ++
+ (String.fromInt
+ (Struct.TileInstance.get_local_variant_ix tile)
+ )
)
),
(Html.Attributes.class "clickable"),
diff --git a/src/battle/src/View/SubMenu/Status/TileInfo.elm b/src/battle/src/View/SubMenu/Status/TileInfo.elm
index bc382fc..44f7293 100644
--- a/src/battle/src/View/SubMenu/Status/TileInfo.elm
+++ b/src/battle/src/View/SubMenu/Status/TileInfo.elm
@@ -15,6 +15,7 @@ import Struct.Location
import Struct.Omnimods
import Struct.Model
import Struct.Tile
+import Struct.TileInstance
import Util.Html
@@ -23,7 +24,7 @@ import View.Map.Tile
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_icon : (Struct.Tile.Instance -> (Html.Html Struct.Event.Type))
+get_icon : (Struct.TileInstance.Type -> (Html.Html Struct.Event.Type))
get_icon tile =
(Html.div
[
@@ -32,7 +33,10 @@ get_icon tile =
(Html.Attributes.class
(
"tile-variant-"
- ++ (String.fromInt (Struct.Tile.get_local_variant_ix tile))
+ ++
+ (String.fromInt
+ (Struct.TileInstance.get_local_variant_ix tile)
+ )
)
)
]
@@ -41,13 +45,13 @@ get_icon tile =
get_name : (
Struct.Model.Type ->
- Struct.Tile.Instance ->
+ Struct.TileInstance.Type ->
(Html.Html Struct.Event.Type)
)
-get_name model tile =
- case (Dict.get (Struct.Tile.get_type_id tile) model.tiles) of
+get_name model tile_inst =
+ case (Dict.get (Struct.TileInstance.get_class_id tile_inst) model.tiles) of
Nothing -> (Util.Html.nothing)
- (Just tile_type) ->
+ (Just tile) ->
(Html.div
[
(Html.Attributes.class "info-card-name"),
@@ -55,14 +59,14 @@ get_name model tile =
(Html.Attributes.class "tile-card-name")
]
[
- (Html.text (Struct.Tile.get_name tile_type))
+ (Html.text (Struct.Tile.get_name tile))
]
)
-get_cost : Struct.Tile.Instance -> (Html.Html Struct.Event.Type)
-get_cost tile =
+get_cost : Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)
+get_cost tile_inst =
let
- cost = (Struct.Tile.get_instance_cost tile)
+ cost = (Struct.TileInstance.get_cost tile_inst)
text =
if (cost > Constants.Movement.max_points)
then
@@ -80,10 +84,10 @@ get_cost tile =
]
)
-get_location : Struct.Tile.Instance -> (Html.Html Struct.Event.Type)
-get_location tile =
+get_location : Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)
+get_location tile_inst =
let
- tile_location = (Struct.Tile.get_location tile)
+ tile_location = (Struct.TileInstance.get_location tile_inst)
in
(Html.div
[
diff --git a/src/map-editor/src/Comm/SetMap.elm b/src/map-editor/src/Comm/SetMap.elm
index 06fa34c..10d527a 100644
--- a/src/map-editor/src/Comm/SetMap.elm
+++ b/src/map-editor/src/Comm/SetMap.elm
@@ -1,18 +1,11 @@
module Comm.SetMap exposing (decode)
-- Elm -------------------------------------------------------------------------
-import Dict
-
import Json.Decode
-- Map -------------------------------------------------------------------------
-import Constants.Movement
-
import Struct.Map
-import Struct.MapMarker
import Struct.ServerReply
-import Struct.Tile
-import Struct.TileInstance
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
diff --git a/src/map-editor/src/Struct/TileInstance.elm b/src/map-editor/src/Struct/TileInstance.elm
index 4d03630..862598b 100644
--- a/src/map-editor/src/Struct/TileInstance.elm
+++ b/src/map-editor/src/Struct/TileInstance.elm
@@ -62,21 +62,7 @@ type alias Border =
--------------------------------------------------------------------------------
noise_function : Int -> Int -> Int -> Int
noise_function a b c =
- let
- af = (toFloat a)
- bf = (toFloat b)
- cf = (toFloat c)
- (df, ef) = (toPolar (af, bf))
- (ff, gf) = (toPolar (bf, af))
- (hf, jf) = (toPolar (bf, cf))
- (kf, lf) = (toPolar (cf, bf))
- (mf, nf) = (toPolar (af, cf))
- (qf, rf) = (toPolar (cf, af))
- (resA, resB) = (fromPolar ((df + qf), (ef + nf)))
- (resC, resD) = (fromPolar ((hf + mf), (jf + gf)))
- (resE, resF) = (toPolar ((resA - resC), (resB - resD)))
- in
- (round (resE - resF))
+ (round (radians (toFloat ((a + 1) * 2 + (b + 1) * 3 + c))))
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------