summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/battlemap.erl')
-rw-r--r--src/battlemap.erl22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/battlemap.erl b/src/battlemap.erl
new file mode 100644
index 0000000..4366852
--- /dev/null
+++ b/src/battlemap.erl
@@ -0,0 +1,22 @@
+-module(battlemap).
+-export([encode_in_json/1]).
+
+encode_in_json (
+ {
+ Width,
+ Height,
+ Tiles
+ }
+) ->
+ jiffy:encode(
+ {
+ [
+ {<<"width">>, Width},
+ {<<"height">>, Height},
+ {
+ <<"content">>,
+ lists:map((fun ({ID, Cost}) -> [ID, Cost] end), Tiles)
+ }
+ ]
+ }
+ ).