1 | const GameChallenger = require('../ssb_ctrl/game_challenge');
|
2 | const GameSSBDao = require('../ssb_ctrl/game');
|
3 | const ChessIndex = require('ssb-chess-index');
|
4 | const GameDb = require('../db/game_db');
|
5 | const SocialCtrl = require('./social');
|
6 | const PlayerCtrl = require('./player');
|
7 | const MoveCtrl = require('./gameMove');
|
8 | const RecentActivityCtrl = require('./recentActivityCtrl');
|
9 | const PgnCtrl = require('./pgn');
|
10 | const MovesFinder = require('./validMovesFinder');
|
11 | const InviteCtrl = require('./inviteCtrl');
|
12 | const GameCtrl = require('./gameCtrl');
|
13 | const UserGamesUpdateWatcher = require('./userGameUpdatesWatcher');
|
14 |
|
15 | const settingsCtrl = require('./settings')();
|
16 |
|
17 | const BacklinkUtils = require('../utils/backlinks_obs');
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | module.exports = (sbot, myIdent) => {
|
26 |
|
27 | const chessIndex = ChessIndex(sbot);
|
28 |
|
29 | const backlinkUtils = BacklinkUtils();
|
30 | const socialCtrl = SocialCtrl(sbot, myIdent, chessIndex);
|
31 |
|
32 | const gameSSBDao = GameSSBDao(sbot, myIdent, backlinkUtils, socialCtrl);
|
33 | const gameChallenger = GameChallenger(sbot, myIdent);
|
34 | const gameDb = GameDb(chessIndex);
|
35 | const moveCtrl = MoveCtrl(gameSSBDao, myIdent);
|
36 | const pgnCtrl = PgnCtrl(gameSSBDao);
|
37 |
|
38 | const playerCtrl = PlayerCtrl(sbot, gameDb, gameSSBDao);
|
39 |
|
40 | const movesFinderCtrl = MovesFinder();
|
41 |
|
42 | const userGamesUpdateWatcher = UserGamesUpdateWatcher(sbot, chessIndex);
|
43 |
|
44 | const myGameUpdates = userGamesUpdateWatcher.latestGameMessageForPlayerObs(myIdent);
|
45 |
|
46 | const gameCtrl = GameCtrl(myIdent, gameSSBDao, gameDb, userGamesUpdateWatcher, myGameUpdates);
|
47 |
|
48 | const recentActivityCtrl = RecentActivityCtrl(
|
49 | userGamesUpdateWatcher,
|
50 | gameCtrl.getSituationObservable,
|
51 | myIdent,
|
52 | );
|
53 |
|
54 | const inviteCtrl = InviteCtrl(myIdent, gameChallenger, gameDb, myGameUpdates);
|
55 |
|
56 | function getMyIdent() {
|
57 | return myIdent;
|
58 | }
|
59 |
|
60 | return {
|
61 | |
62 |
|
63 |
|
64 | getMyIdent,
|
65 |
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 | getGameCtrl: () => gameCtrl,
|
72 |
|
73 | |
74 |
|
75 |
|
76 | getInviteCtrl: () => inviteCtrl,
|
77 |
|
78 | |
79 |
|
80 |
|
81 | getMoveCtrl: () => moveCtrl,
|
82 |
|
83 | |
84 |
|
85 |
|
86 | getSocialCtrl: () => socialCtrl,
|
87 |
|
88 | |
89 |
|
90 |
|
91 | getPlayerCtrl: () => playerCtrl,
|
92 |
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | getRecentActivityCtrl: () => recentActivityCtrl,
|
100 |
|
101 | |
102 |
|
103 |
|
104 | getMovesFinderCtrl: () => movesFinderCtrl,
|
105 |
|
106 | |
107 |
|
108 |
|
109 | getPgnCtrl: () => pgnCtrl,
|
110 |
|
111 | |
112 |
|
113 |
|
114 |
|
115 | getUserGameWatcherCtrl: () => userGamesUpdateWatcher,
|
116 |
|
117 | |
118 |
|
119 |
|
120 |
|
121 | getSbot: () => sbot,
|
122 |
|
123 | |
124 |
|
125 |
|
126 | getSettingsCtrl: () => settingsCtrl
|
127 | };
|
128 | };
|