summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2017-11-20 17:25:37 +0100
committernsensfel <SpamShield0@noot-noot.org>2017-11-20 17:25:37 +0100
commitb984be19b36226b02cb2d58d8597d2cff4be1eaf (patch)
tree96493a00a29ec934297acf073ee431bf6174f1e8 /src/battlemap.erl
parentc3c8f24ebde2370d8314b1f0e571a26fbcff9450 (diff)
Trying to get character turns to register.
Diffstat (limited to 'src/battlemap.erl')
-rw-r--r--src/battlemap.erl24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/battlemap.erl b/src/battlemap.erl
new file mode 100644
index 0000000..209a4ab
--- /dev/null
+++ b/src/battlemap.erl
@@ -0,0 +1,24 @@
+-module(battlemap).
+-export
+(
+ [
+ cross/4
+ ]
+).
+
+-include("timed_cache_data.hrl").
+
+calc_new_loc (X, Y, [], _Points, _Map, _OtherChars) ->
+ {X, Y};
+calc_new_loc (X, Y, [Step|Path], Points, Map, OtherChars) ->
+ case Step of
+ <<"U">> -> calc_new_loc(X, (Y - 1), Path, Points, Map, OtherChars);
+ <<"D">> -> calc_new_loc(X, (Y + 1), Path, Points, Map, OtherChars);
+ <<"L">> -> calc_new_loc((X - 1), Y, Path, Points, Map, OtherChars);
+ <<"R">> -> calc_new_loc((X + 1), Y, Path, Points, Map, OtherChars);
+ _ -> calc_new_loc(X, Y, Path, Points, Map, OtherChars)
+ end.
+
+cross (Battlemap, CharInst, Path, OtherChars) ->
+ {X, Y} = character_instance:get_location(CharInst),
+ {ok, calc_new_loc(X, Y, Path, 99, Battlemap, OtherChars)}.