From 9dd67cd5c63ac2a050a517c313f2e343f008421b Mon Sep 17 00:00:00 2001 From: nsensfel Date: Wed, 22 Nov 2017 16:45:05 +0100 Subject: Got the player turns to work... I think. --- src/battlemap_instance.erl | 10 +++++++++- src/character_instance.erl | 5 ++++- src/database_shim.erl | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/battlemap_instance.erl b/src/battlemap_instance.erl index 37811b3..3f4b6cd 100644 --- a/src/battlemap_instance.erl +++ b/src/battlemap_instance.erl @@ -26,7 +26,15 @@ can_play_char_instance CharInstID ) -> ( - (array:get(BattlemapInstance#battlemap_instance.curr_player) =:= PlayerID) + ( + array:get + ( + BattlemapInstance#battlemap_instance.curr_player, + BattlemapInstance#battlemap_instance.players + ) + =:= + PlayerID + ) and lists:member(CharInstID, BattlemapInstance#battlemap_instance.rem_chars) ). diff --git a/src/character_instance.erl b/src/character_instance.erl index d8d7455..a38be5d 100644 --- a/src/character_instance.erl +++ b/src/character_instance.erl @@ -3,7 +3,8 @@ ( [ set_location/3, - get_location/1 + get_location/1, + get_owner/1 ] ). @@ -18,3 +19,5 @@ set_location (CharInst, X, Y) -> get_location (CharInst) -> {CharInst#character_instance.x, CharInst#character_instance.y}. + +get_owner (CharInst) -> CharInst#character_instance.team. diff --git a/src/database_shim.erl b/src/database_shim.erl index 0a46c00..8d97298 100644 --- a/src/database_shim.erl +++ b/src/database_shim.erl @@ -53,8 +53,19 @@ generate_map_instance (CharInts) -> { id = <<"0">>, chars = dict:from_list(CharInts), - curr_player = <<"0">>, - rem_chars = [], + curr_player = 0, + players = array:from_list([<<"0">>, <<"1">>]), + rem_chars = + lists:filtermap + ( + fun ({K, V}) -> + case character_instance:get_owner(V) of + 0 -> {true, K}; + _ -> false + end + end, + CharInts + ), last_turn = [] }. -- cgit v1.2.3-70-g09d2