Random Number Generator (RNG)
Other Documentation
Tournaments

get_tournaments_in_state

Get a list of tournament ids for upcoming tournaments
1
Apis.instance().db_api().exec('get_tournaments_in_state', [stateString, accountId])
Copied!
Parameters
Return
Code
  • stateString: The tournament state
  • accountId:Account Id
All tournaments for the selected state.
1
ChainStore.prototype.getTournamentIdsInState = function getTournamentIdsInState(accountId, stateString) {
2
var _this7 = this;
3
4
var tournamentIdsForThisAccountAndState = void 0;
5
var tournamentIdsForThisAccount = this.tournament_ids_by_state.get(accountId);
6
7
if (tournamentIdsForThisAccount === undefined) {
8
tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
9
tournamentIdsForThisAccount = new _immutable2.default.Map().set(stateString, tournamentIdsForThisAccountAndState);
10
this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
11
} else {
12
tournamentIdsForThisAccountAndState = tournamentIdsForThisAccount.get(stateString);
13
14
if (tournamentIdsForThisAccountAndState !== undefined) {
15
return tournamentIdsForThisAccountAndState;
16
}
17
18
tournamentIdsForThisAccountAndState = new _immutable2.default.Set();
19
tournamentIdsForThisAccount = tournamentIdsForThisAccount.set(stateString, tournamentIdsForThisAccountAndState);
20
this.tournament_ids_by_state = this.tournament_ids_by_state.set(accountId, tournamentIdsForThisAccount);
21
}
22
23
_ws.Apis.instance().db_api().exec('get_tournaments_in_state', [stateString, 100]).then(function (tournaments) {
24
var originalTournamentIdsInState = _this7.tournament_ids_by_state.getIn([accountId, stateString]);
25
// call updateObject on each tournament, which will classify it
26
tournaments.forEach(function (tournament) {
27
/**
28
* Fix bug: we cant update tournament_ids_by_state if objects_by_id has a tournament
29
*/
30
if (!originalTournamentIdsInState.get(tournament.id)) {
31
_this7.clearObjectCache(tournament.id);
32
}
33
34
_this7._updateObject(tournament);
35
});
36
37
var tournament_id = _this7.tournament_ids_by_state.getIn([accountId, stateString]);
38
39
if (tournament_id !== originalTournamentIdsInState) {
40
_this7.notifySubscribers();
41
}
42
});
43
return tournamentIdsForThisAccountAndState;
44
};
Copied!

get_registered_tournaments

Get a list of registered tournaments by account id.
1
Apis.instance().db_api().exec('get_registered_tournaments', [accountId, 100])
Copied!
Parameters
Return
Code
  • accountId: Account Id.
All registered tournaments for an account.
1
ChainStore.prototype.getRegisteredTournamentIds = function getRegisteredTournamentIds(accountId) {
2
var _this8 = this;
3
4
var tournamentIds = this.registered_tournament_ids_by_player.get(accountId);
5
6
if (tournamentIds !== undefined) {
7
return tournamentIds;
8
}
9
10
tournamentIds = new _immutable2.default.Set();
11
this.registered_tournament_ids_by_player = this.registered_tournament_ids_by_player.set(accountId, tournamentIds);
12
13
_ws.Apis.instance().db_api().exec('get_registered_tournaments', [accountId, 100]).then(function (registered_tournaments) {
14
var originalTournamentIds = _this8.registered_tournament_ids_by_player.get(accountId);
15
var newTournamentIds = new _immutable2.default.Set(registered_tournaments);
16
17
if (!originalTournamentIds.equals(newTournamentIds)) {
18
_this8.registered_tournament_ids_by_player = _this8.registered_tournament_ids_by_player.set(accountId, newTournamentIds);
19
_this8.notifySubscribers();
20
}
21
});
22
23
return tournamentIds;
24
};
25
Copied!

get_tournaments

Get all tournaments between last_tournament_id and start_tournament_id.
1
_ws.Apis.instance().db_api().exec('get_tournaments', [last_tournament_id, limit, start_tournament_id])
Copied!
Parameters
Return
Code
  • last_tournament_id: The last tournament id
  • limit: The limit of tournaments to return.
  • start_tournament_id: The starting tournament id.
A list of all tournaments between last_tournament_id and start_tournament_id.
1
ChainStore.prototype.getTournaments = function getTournaments(last_tournament_id) {
2
var _this20 = this;
3
4
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
5
var start_tournament_id = arguments[2];
6
7
return _ws.Apis.instance().db_api().exec('get_tournaments', [last_tournament_id, limit, start_tournament_id]).then(function (tournaments) {
8
var list = _immutable2.default.List();
9
10
_this20.setLastTournamentId(null);
11
12
if (tournaments && tournaments.length) {
13
list = list.withMutations(function (l) {
14
tournaments.forEach(function (tournament) {
15
if (!_this20.objects_by_id.has(tournament.id)) {
16
_this20._updateObject(tournament);
17
}
18
19
l.unshift(_this20.objects_by_id.get(tournament.id));
20
});
21
});
22
}
23
24
return list;
25
});
26
};
Copied!
Last modified 2yr ago