Returns a promise for the ID of the player who won the game
431321
function handleIt(cb) {
    callbacks = cb;
    broadcast = callbacks.broadcast;

    let msg = {
      cmd: MessageType.RockPaperScissors,
      handlerId: id
    };
    broadcast("action", msg);

    // Return a promise for the result
    deferred = q.defer();
    return deferred.promise;
  }
222397
def current_game(self):
        
        obj = self._prof
        gameid = obj.get("gameid")
        gameserverip = obj.get("gameserverip")
        gameextrainfo = obj.get("gameextrainfo")
        return (int(gameid) if gameid else None, gameserverip, gameextrainfo)
1307912
function playerFromReq(request, response, game) {
    var jar = new cookies(request, response);
    var p = decodeURIComponent(jar.get('player'));
    return game.players[p];
}
422638
function getPlayerCounters(player, attacker, game) {
  return player.hand
    .map((card) => {
      return card.validCounters ? card.validCounters(player, attacker, game) : []
    })
    .reduce((acc, array) => {
      return acc.concat(array)
    }, [])
    .sort((counterA, counterB) => counterB.weight - counterA.weight)
}
666864
function(entity){
            var game = this.game;
            return function(x, y){
                return game.entityCanSeeThrough(entity, x, y);
            };
        }
1174779
function getGameBeforeLastMove(game) {
    // $Fix I do NOT know if it is the best way to make game immutable.
    game = Object.assign({}, game);
    let lastMove = game.moves.pop();
    if (lastMove)
        game = getGameAfterMove(game, getBackMove(lastMove), true);
    if (Game.getPlayerTurn(game).isAi) {
        lastMove = game.moves.pop();
        if (lastMove) {
            game = getGameAfterMove(game, getBackMove(lastMove), true);
        }
    }
    return game;
}
719262
def get_winner
      ls = get_boxscore.linescore
      if ls.home_team_runs > ls.away_team_runs
        return home_team_abbrev
      else
        return visit_team_abbrev
      end
    end
1087281
def get_tournament_prize_pool(self, leagueid=None, **kwargs):
        
        if 'leagueid' not in kwargs:
            kwargs['leagueid'] = leagueid
        url = self.__build_url(urls.GET_TOURNAMENT_PRIZE_POOL, **kwargs)
        req = self.executor(url)
        if self.logger:
            self.logger.info('URL: {0}'.format(url))
        if not self.__check_http_err(req.status_code):
            return response.build(req, url, self.raw_mode)
1111952
def _set_winning_team(self):
        """"""
        if not self._summary['finished']:
            return
        for team in self._summary['diplomacy']['teams']:
            team['winner'] = False
            for player_number in team['player_numbers']:
                for player in self._summary['players']:
                    if player_number == player['number']:
                        if player['winner']:
                            team['winner'] = True
434282
function( obj ) {
					if ( obj == null ) {
						obj = promise;
					} else {
						for ( var key in promise ) {
							obj[ key ] = promise[ key ];
						}
					}
					return obj;
				}
970353
function getItem(id) {
  return new Promise((resolve, reject) => {
    return instance.pkgs.then(db => {
      const req = db.transaction(db.name)
        .objectStore(db.name).get(id);
      req.onsuccess = event => resolve(event.target.result);
      req.onerror = event => reject(event);
    });
  });
}
1258203
def getResult(self, queue, uid, suid=None):
        

        if suid:
            r = yield self.client.get('rhumba.dq.%s.%s.%s' % (suid, queue, uid))
        else:
            r = yield self.client.get('rhumba.q.%s.%s' % (queue, uid))

        if r:
            defer.returnValue(json.loads(r))
        else:
            defer.returnValue(None)
1354735
function Player(config) {

    /**
     * Gets a users hiscores and activities (available for `rs` / `osrs`)
     * @param username {String} Display name of the user
     * @param type {String} [Optional] normal, ironman, hardcore/ultimate
     * @returns {Promise} Object of the users hiscores and activities
     * @example
     * // returns Sync's RS stats and activities
     * rsapi.rs.player.hiscores('sync').then(function(stats) {
     *  console.log(stats);
     * }).catch(console.error);
     *
     * // returns Sausage's RS stats and activities from the ironman game type
     * api.rs.hiscores.player('sausage', 'ironman').then(function(stats) {
     *   console.log(stats)
     * }).catch(console.error);
     *
     * // returns Sausage's RS stats and activities from the hardcore ironman game type
     * api.rs.hiscores.player('sausage', 'hardcore').then(function(stats) {
     *   console.log(stats)
     * }).catch(console.error);
     *
     * // returns hey jase's Old School RS stats and activities
     * api.osrs.hiscores.player('hey jase').then(function(stats) {
     *   console.log(stats)
     * }).catch(console.error);
     *
     * // returns lezley's Old School RS stats and activities from the ironman game type
     * api.osrs.hiscores.player('lezley', 'ironman').then(function(stats) {
     *   console.log(stats)
     * }).catch(console.error);
     *
     * // returns perm iron's Old School RS stats and activities from the ultimate ironman game type
     * api.osrs.hiscores.player('perm iron', 'ultimate').then(function(stats) {
     *   console.log(stats)
     * }).catch(console.error);
     */
    this.hiscores = function (username, type) {
        return new Hiscores(username, config.hiscores).lookup(type);
    };

    /**
     * Gets a users events log (aka adventure log) (available for `rs`)
     * @param username {String} Display name of the user
     * @returns {Promise} Object of the users events log
     * @example
     * // returns Sync's events / adventure log
     * rsapi.rs.player.events('sync').then(function(stats) {
     *  console.log(stats);
     * }).catch(console.error);
     */
    this.events = function (username) {
        return new Events(username, config.events).lookup();
    }

    /**
     * Returns the input user(s) clan, title, if the clan is recruiting, if the title is a suffix, as well as online status
     * if process.env.username and process.env.password are configured to a valid RS sign-in
     * @param usernames {string|array} String of a single username or array of multiple to lookup
     * @returns {Promise} Object of the users player details
     * @example
     * rsapi.rs.player.details(['sync','xredfoxx']).then(function(details) {
     *  console.log(details);
     * }).catch(console.error);
     */
    this.details = function (usernames) {
        return new Promise(function (resolve, reject) {
            var names = [];
            if (typeof usernames === 'string') {
                names.push(usernames);
            }
            else if (typeof usernames === 'object') {
                names = usernames;
            }
            else {
                var jsonError = new Error('Unrecognized input for usernames. Should be a string or array.');
                reject(jsonError);
            }

            request.createSession().then( function(session) {
                request.jsonp(config.urls.playerDetails + JSON.stringify(names), session).then(resolve).catch(reject);
                }
            ).catch(console.error);
        });
    }

    /**
     * Return RuneMetrics profile for user
     * @param usernames
     * @returns {Promise} Object of the users player profile
     * @example
     * rsapi.rs.player.profile('sync').then(function(profile) {
     *  console.log(profile);
     * }).catch(console.error);
     */
    this.profile = function(usernames) {
        return new Profile(usernames, config).lookup();
    }
}
965821
function()
    {
        if (this._executePromise)
            return this._executePromise;

        var q = this.clone();

        var table  = q._T.__name__;
        var page   = q._page;
        var fields = q._fields;

        // Create the query from our stuff
        var query = {};
        _(q._where.concat(q._like)).each(function (q) {
            query[q.key] = q.value;
        });

        var doneLoading      = Q.defer();
        this._executePromise = doneLoading.promise;

        var left = q._take;

        // A single iteration of fetching via the API. Called repeatedly in
        // the case of large / unbounded TAKES
        var loop = function() {

            // always take 1000 unless we're almost done
            var take = left < 1000 ? left : 1000;

            // Hit the API and incremement the page
            q._fetch(table, take, page++, query, fields).then(function(res) {

                // publish progress
                doneLoading.notify(q._results.length);

                if (left !== undefined) left -= res.length;

                // Either resolve the the promise with the results if we're
                // done or call the loop again

                if (q._doneLoading || left <= 0)
                    doneLoading.resolve(q._getResults());
                else
                    process.nextTick(loop);

            }).catch(function(err) {
                doneLoading.reject(err);
            });
        };

        // do tha damn thing
        loop();
        return doneLoading.promise;
    }
222373
def box_score(game_id):
    """"""
    # get box score data
    data = mlbgame.game.box_score(game_id)
    # create object with data
    obj = mlbgame.game.GameBoxScore(data)
    return obj
841484
def next_player(self):
        
        logging.warning('turn={}, players={}'.format(
            self.game._cur_turn,
            self.game.players
        ))
        return self.game.players[(self.game._cur_turn + 1) % len(self.game.players)]
506630
def fetchone(self):
        
        self._check_executed()
        fut = self._loop.create_future()

        if self._rows is None or self._rownumber >= len(self._rows):
            fut.set_result(None)
            return fut
        result = self._rows[self._rownumber]
        self._rownumber += 1

        fut = self._loop.create_future()
        fut.set_result(result)
        return fut