summaryrefslogtreecommitdiff
blob: 5231a314cbd7389b919104ff7c85d9d5fe5ad24e (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-module(lgn_shim).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-export([generate_random_player/4]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec add_ref_to_event
   (
      binary(),
      binary(),
      boolean(),
      shr_player:type()
   )
   -> shr_player:type().
add_ref_to_event (BattleID, EventName, IsPlayersTurn, Player) ->
   Event =
      shr_battle_summary:new(BattleID, EventName, <<"Never">>, IsPlayersTurn),

   Result = shr_player:set_event_summaries(array:from_list([Event]), Player),

   Result.

-spec add_ref_to_map
   (
      binary(),
      binary(),
      shr_player:type()
   )
   -> shr_player:type().
add_ref_to_map (MapID, EventName, Player) ->
   MapRef = shr_map_summary:new(MapID, EventName),

   Result = shr_player:set_map_summaries(array:from_list([MapRef]), Player),

   Result.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate_random_player
   (
      binary(),
      binary(),
      binary(),
      binary()
   )
   -> shr_player:type().
generate_random_player (ID, Username, Password, Email) ->
   Result = shr_player:new(ID, Username, Password, Email),

   S0Result =
      case ID of
         <<"0">> ->
            S0 = add_ref_to_event(<<"0">>, <<"Test Battle">>, true, Result),
            S1 = shr_player:set_roster_id(<<"0">>, S0),
            S2 = add_ref_to_map(<<"0">>, <<"Test Map 0">>, S1),
            S2;

         <<"1">> ->
            S0 = add_ref_to_event(<<"0">>, <<"Test Battle">>, false, Result),
            S1 = shr_player:set_roster_id(<<"1">>, S0),
            S2 = add_ref_to_map(<<"1">>, <<"Test Map 1">>, S1),

            S2;

         _ -> Result
      end,

   S0Result.