summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-03-05 13:51:14 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-03-05 13:51:14 +0100
commit6a82ead205f4463ee34cc4fcbc06f1b3e7b1dd1a (patch)
tree6b9fa780865044b8c57800d48fe251e4dff2d6f6 /src/struct/location.erl
parent10b1058e56079232728e3fc959709bc784e58b5b (diff)
Starting to work on the client diff messages.
Diffstat (limited to 'src/struct/location.erl')
-rw-r--r--src/struct/location.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/struct/location.erl b/src/struct/location.erl
index 624fe56..462dc46 100644
--- a/src/struct/location.erl
+++ b/src/struct/location.erl
@@ -13,6 +13,14 @@
-export
(
[
+ decode/1,
+ encode/1
+ ]
+).
+
+-export
+(
+ [
apply_direction/2,
dist/2
]
@@ -43,3 +51,9 @@ apply_direction (down, {X, Y}) ->
-spec dist(type(), type()) -> non_neg_integer().
dist ({OX, OY}, {DX, DY}) ->
(abs(DY - OY) + abs(DX - OX)).
+
+-spec encode (type()) -> list(non_neg_integer()).
+encode ({X, Y}) -> [X, Y].
+
+-spec decode (list(non_neg_integer)) -> type().
+decode ([X, Y]) when (is_integer(X) and is_integer(Y)) -> validate({X, Y}).