| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/battlemap_instance.erl | 10 | ||||
| -rw-r--r-- | src/character_instance.erl | 5 | ||||
| -rw-r--r-- | src/database_shim.erl | 15 | 
3 files changed, 26 insertions, 4 deletions
| 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 = []     }. | 


