blob: f3119461b84193f8485c4e584d4ad54de8666d1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-module(battlemap_load_state).
-export(
[
handle/1
]
).
handle (Req) ->
JSONReqMap = jiffy:decode(Req, [return_maps]),
BattlemapID = maps:get(<<"battlemap_id">>, JSONReqMap),
io:format("~nLoading Battlemap ~p...~n", [BattlemapID]),
{Battlemap, CharList} =
timed_cache_object:fetch(
battlemaps_db,
BattlemapID
),
%% ok = users_manager:ping(UserToken),
jiffy:encode(
[
[
<<"set_map">>,
battlemap_battlemap:encode_in_json(Battlemap)
]
|
lists:map(
fun (Char) ->
[
<<"add_char">>,
battlemap_character:encode_in_json(Char)
]
end,
CharList
)
]
).
|