Add player to mpris_players
160708
def _add_player(self, player_id):
        
        if not player_id.startswith(SERVICE_BUS):
            return False

        player = self._dbus.get(player_id, SERVICE_BUS_URL)

        if player.Identity not in self._mpris_names:
            self._mpris_names[player.Identity] = player_id.split(".")[-1]
            for p in self._mpris_players.values():
                if not p["name"] and p["identity"] in self._mpris_names:
                    p["name"] = self._mpris_names[p["identity"]]
                    p["full_name"] = u"{} {}".format(p["name"], p["index"])

        identity = player.Identity
        name = self._mpris_names.get(identity)
        if (
            self.player_priority != []
            and name not in self.player_priority
            and "*" not in self.player_priority
        ):
            return False

        if identity not in self._mpris_name_index:
            self._mpris_name_index[identity] = 0

        status = player.PlaybackStatus
        state_priority = WORKING_STATES.index(status)
        index = self._mpris_name_index[identity]
        self._mpris_name_index[identity] += 1
        try:
            subscription = player.PropertiesChanged.connect(
                self._player_monitor(player_id)
            )
        except AttributeError:
            subscription = {}

        self._mpris_players[player_id] = {
            "_dbus_player": player,
            "_id": player_id,
            "_state_priority": state_priority,
            "index": index,
            "identity": identity,
            "name": name,
            "full_name": u"{} {}".format(name, index),
            "status": status,
            "subscription": subscription,
        }

        return True
806313
public static void send(int message, EntityPlayerMP player)
	{
		MalisisCore.network.sendTo(new Packet(message), player);
	}
68881
def _add(self, hostport):
        """"""
        peer = self.peer_class(
            tchannel=self.tchannel,
            hostport=hostport,
            on_conn_change=self._update_heap,
        )
        peer.rank = self.rank_calculator.get_rank(peer)
        self._peers[peer.hostport] = peer

        self.peer_heap.add_and_shuffle(peer)
1348974
function restartGame(players) {
    // Replace the current instance with a new instance
    let newGame = new RockPaperScissors(game, players, winCounter, id);
    proxy.swap(newGame);

    q.delay(RESULTS_DELAY)
      .done(function() {
        deferred.resolve(newGame.handleIt(callbacks));
      });
  }
843009
function getPlayerPlays(player, game) {
  // Shuffle so that equal-weighted players aren't
  // always prioritized by their turn order
  return Util.shuffle(game.players)
    .reduce((plays, target) => {
      if (player === target) {
        return plays
      }
      return plays.concat(
        player.hand
          .map((card) => {
            return card.validPlays ? card.validPlays(player, target, game) : []
          })
          .reduce((acc, array) => {
            return acc.concat(array)
          }, [])
      )
    }, [])
    .sort((playA, playB) => playB.weight - playA.weight)
}
294577
def play(device_id = nil, params = {})
      url = "me/player/play"
      url = device_id.nil? ? url : "#{url}?device_id=#{device_id}"

      User.oauth_put(@user.id, url, params.to_json)
    end
815989
function updatePlayerList(dstListName, srcList, updateRule) {
                var dstList;
                // Initial setup call. Nothing to do.
                if (!srcList && !updateRule) return;

                dstList = dstListName === 'pl' ? this.game.pl : this.game.ml;
                updateRule = updateRule || 'replace';

                if (updateRule === 'replace') {
                    dstList.clear(true);
                }
                else if (updateRule !== 'append') {
                    throw new Error('setup("' + dstListName + '") is invalid ' +
                                    'updateRule: ' + updateRule + '.');
                }

                // Import clients (if any).
                // Automatic cast from Object to Player.
                if (srcList) dstList.importDB(srcList);

                return { updateRule: updateRule, list: srcList };
            }
937939
public function fixName(): Player
    {
        $this->name = $this->getDataFetcher()->fetchRealName($this->getName());

        return $this;
    }
773687
def _num_players(self):
        """"""
        self._player_num = 0
        self._computer_num = 0
        for player in self._header.scenario.game_settings.player_info:
            if player.type == 'human':
                self._player_num += 1
            elif player.type == 'computer':
                self._computer_num += 1
1059849
public function createPlayer(PlayerInfo $playerInfo, PlayerDetailedInfo $playerDetailedInfo)
    {
        $class = $this->class;
        $player = new $class();

        $player->merge($playerInfo);
        $player->merge($playerDetailedInfo);

        return $player;
    }
858907
function(FLEX_HOME, done) {
    var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player');
    if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) {
      var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir();
      var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal');

      var prepOldPlayerStorage = function(done) {
        function cb(err) {
          done(err ? new Error('Failed to prepare the storage location for the old "playerglobal.swc" library collection.\nError: ' + err) : null);
        }

        if (fs.existsSync(tmpOldPlayersDir)) {
          async.series(
            [
              function(done) {
                rimraf(tmpOldPlayersDir, done);
              },
              function(done) {
                mkdirp(tmpOldPlayersDir, done);
              }
            ],
            cb
          );
        }
        else {
          mkdirp(tmpOldPlayersDir, cb);
        }
      };

      var saveOldPlayers = function(done) {
        ncp(playersDir, tmpOldPlayersDir, function(err) {
          done(err ? new Error('Failed to maintain the old "playerglobal.swc" library collection.\nError: ' + err) : null);
        });
      };

      var installNewPlayers = function(done) {
        ncp(downloadDir, playersDir, function(err) {
          done(err ? new Error('Failed to install the new "playerglobal.swc" library collection.\nError: ' + err) : null);
        });
      };

      var restoreNonConflictingOldPlayers = function(done) {
        ncp(tmpOldPlayersDir, playersDir, { clobber: false }, function(err) {
          if (err) {
            console.warn('WARNING: Failed to restore any non-conflicting files from the old "playerglobal.swc" library collection.\nError: ' + err);
          }
          done();
        });
      };

      async.series(
        [
          prepOldPlayerStorage,
          saveOldPlayers,
          installNewPlayers,
          restoreNonConflictingOldPlayers
        ],
        done
      );
    }
    else {
      done(new TypeError('The FLEX_HOME provided does not contain the expected directory structure'));
    }
  }
850697
public static void removeIngredientsFromPlayer(EntityPlayerMP player, List<ItemStack> ingredients)
    {
        NonNullList<ItemStack> main = player.inventory.mainInventory;
        NonNullList<ItemStack> arm = player.inventory.armorInventory;

        for (ItemStack isIngredient : ingredients)
        {
            int target = isIngredient.getCount();
            for (int i = 0; i < main.size() + arm.size() && target > 0; i++)
            {
                ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i);
                if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient))
                {
                    if (target >= isPlayer.getCount())
                    {
                        // Consume this stack:
                        target -= isPlayer.getCount();
                        if (i >= main.size())
                            arm.get(i - main.size()).setCount(0);
                        else
                            main.get(i).setCount(0);
                    }
                    else
                    {
                        isPlayer.setCount(isPlayer.getCount() - target);
                        target = 0;
                    }
                }
            }
            ItemStack resultForReward = isIngredient.copy();
            RewardForDiscardingItemImplementation.LoseItemEvent event = new RewardForDiscardingItemImplementation.LoseItemEvent(resultForReward);
            MinecraftForge.EVENT_BUS.post(event);
        }
    }
140212
def invite_user(self, new_member, inviter=None, roster=None):
        """"""
        roster = roster or self.client.getRoster()
        jid = new_member['JID']

        logger.info('roster %s %s' % (jid, roster.getSubscription(jid)))
        if jid in roster.keys() and roster.getSubscription(jid) in ['both', 'to']:
            new_member['STATUS'] = 'ACTIVE'
            if inviter:
                self.send_message('%s is already a member' % (jid,), inviter)
        else:
            new_member['STATUS'] = 'INVITED'
            self.broadcast('inviting %s to the room' % (jid,))

            #Add nickname according to http://xmpp.org/extensions/xep-0172.html
            subscribe_presence = xmpp.dispatcher.Presence(to=jid, typ='subscribe')
            if 'NICK' in self.params:
                subscribe_presence.addChild(name='nick', namespace=xmpp.protocol.NS_NICK, payload=self.params['NICK'])
            self.client.send(subscribe_presence)

        if not self.is_member(new_member):
            new_member.setdefault('NICK', jid.split('@')[0])
            self.params['MEMBERS'].append(new_member)
518419
def _map_player_request_to_func(self, player_request_type):
        """"""
        # calbacks for on_playback requests are optional
        view_func = self._intent_view_funcs.get(player_request_type, lambda: None)

        argspec = inspect.getargspec(view_func)
        arg_names = argspec.args
        arg_values = self._map_params_to_view_args(player_request_type, arg_names)

        return partial(view_func, *arg_values)
943279
def getPlayer(name):
    """"""
    if isinstance(name, PlayerRecord): return name
    try:    return getKnownPlayers()[name.lower()]
    except KeyError:
        raise ValueError("given player name '%s' is not a known player definition"%(name))
630494
public function addPlayers()
    {
        if (func_num_args() < 1) {
            throw new RockPaperScissorsSpockLizardException('No player objects supplied to addPlayers()');
        }
        
        $count = 0;
        foreach (func_get_args() as $player) {
            
            $count++;
            // error if not Player objects
            if (!$player instanceof Player) {
                throw new RockPaperScissorsSpockLizardException('Parameter # ' . $count . ' is not an instance of Player()');
            }
            
            $this->addPlayer($player);
        }
        
        return $this;
    }
376175
def _on_connect(self, participant):
        
        lock = get_redis_lock()
        if not lock:
            lock = fake_lock()

        with lock:
            self.refresh_from_db()
            if self.ran_ready_function:
                return
            for player in self.get_players():
                if Connection.objects.filter(participant__code=player.participant.code).count() == 0:
                    return
                    
            self.when_all_players_ready()
            self.ran_ready_function = timezone.now()
            self.save()

            self.send('state', 'period_start')

            if self.period_length():
                # TODO: Should replace this with something like Huey/Celery so it'll survive a server restart.
                self._timer = threading.Timer(
                    self.period_length(),
                    lambda: self.send('state', 'period_end'))
                self._timer.start()