1 | const mutantPullReduce = require('mutant-pull-reduce');
|
2 | const computed = require('mutant/computed');
|
3 | const GameComparer = require('./gameComparer')();
|
4 | const Value = require('mutant/value');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | module.exports = (myIdent, gameChallenger, gameDb, myGameUpdates) => {
|
15 |
|
16 | function inviteToPlay(playerKey, asWhite, rematchFromGameId) {
|
17 | return gameChallenger.inviteToPlay(playerKey, asWhite, rematchFromGameId);
|
18 | }
|
19 |
|
20 | function acceptChallenge(rootGameMessage) {
|
21 | return gameChallenger.acceptChallenge(rootGameMessage);
|
22 | }
|
23 |
|
24 | function pendingChallengesSent() {
|
25 | const pendingChallengesSource = gameDb.pendingChallengesSent(myIdent);
|
26 |
|
27 | return mutantPullReduce(pendingChallengesSource, (state, next) => next, {
|
28 | nextTick: true,
|
29 | sync: true,
|
30 | });
|
31 | }
|
32 |
|
33 | function pendingChallengesReceived() {
|
34 | const challengesReceivedSource = gameDb.pendingChallengesReceived(myIdent);
|
35 |
|
36 | return mutantPullReduce(challengesReceivedSource, (state, next) => next, {
|
37 | nextTick: true,
|
38 | sync: true,
|
39 | });
|
40 | }
|
41 |
|
42 | return {
|
43 | inviteToPlay,
|
44 | acceptChallenge,
|
45 | pendingChallengesSent,
|
46 | pendingChallengesReceived,
|
47 | }
|
48 | } |
\ | No newline at end of file |