lucky_sup.erl 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. -module(lucky_sup).
  2. -behaviour(supervisor).
  3. -include_lib("db/include/config.hrl").
  4. -export([start_link/0]).
  5. -export([init/1]).
  6. -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
  7. start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []).
  8. init([]) ->
  9. RestartStrategy = one_for_one,
  10. MaxRestarts = 1000,
  11. MaxSecondsBetweenRestarts = 1,
  12. SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
  13. Restart = permanent,
  14. Shutdown = 2000,
  15. OkeyTableParams = [{mult_factor, 1},
  16. {slang_allowed, false},
  17. {observers_allowed, false},
  18. {tournament_type, lucky},
  19. {round_timeout, infinity},
  20. %%% {round_timeout, 30 * 1000},
  21. {set_timeout, infinity},
  22. %%% {set_timeout, 10 * 60 *1000},
  23. {speed, normal},
  24. {game_type, standard},
  25. {rounds, undefined},
  26. {reveal_confirmation, true},
  27. {next_series_confirmation, no},
  28. {pause_mode, normal},
  29. {social_actions_enabled, true},
  30. {gosterge_finish_allowed, undefined}
  31. ],
  32. OkeyGameId = id_generator:get_id(),
  33. GameName = "I'm filling lucky - " ++ erlang:integer_to_list(OkeyGameId),
  34. OkeyParams = [{game, game_okey},
  35. {game_mode, standard},
  36. {game_name, GameName},
  37. {mode, normal}, % Common table for several real players
  38. {seats, 4},
  39. %%% {quota_per_round, Quota},
  40. {table_module, game_okey_ng_table_trn},
  41. {bot_module, game_okey_bot},
  42. {table_params, OkeyTableParams}
  43. ],
  44. OkeySpec = {okey_lucky, {nsg_trn_lucky, start_link, [OkeyGameId, OkeyParams]},
  45. Restart, Shutdown, worker, [nsg_trn_lucky]},
  46. TavlaTableParams = [{mult_factor, 1},
  47. {slang_allowed, false},
  48. {observers_allowed, false},
  49. {tournament_type, lucky},
  50. {round_timeout, infinity},
  51. %%% {round_timeout, 30 * 1000},
  52. {set_timeout, infinity},
  53. %%% {set_timeout, 10 * 60 *1000},
  54. {speed, normal},
  55. {game_mode, standard},
  56. {rounds, undefined},
  57. {next_series_confirmation, no},
  58. {pause_mode, normal},
  59. {social_actions_enabled, true}
  60. ],
  61. TavlaGameId = id_generator:get_id(),
  62. TavlaGameName = "I'm filling lucky - " ++ erlang:integer_to_list(TavlaGameId),
  63. TavlaParams = [{game, game_tavla},
  64. {game_mode, standard},
  65. {game_name, TavlaGameName},
  66. {mode, normal}, % Common table for several real players
  67. {seats, 2},
  68. %%% {quota_per_round, Quota},
  69. {table_module, game_tavla_ng_table},
  70. {bot_module, game_tavla_bot},
  71. {table_params, TavlaTableParams}
  72. ],
  73. TavlaSpec = {tavla_lucky, {nsg_trn_lucky, start_link, [TavlaGameId, TavlaParams]},
  74. Restart, Shutdown, worker, [nsg_trn_lucky]},
  75. %% TavlaSpec = {tavla_lucky, {fl_lucky, start_link, [TavlaGameId,[{game_type, game_tavla}, {mode, normal}]]},
  76. %% Restart, Shutdown, worker, [fl_lucky]},
  77. {ok, { SupFlags, [OkeySpec, TavlaSpec]} }.