Exemple #1
0
 def prb_onPlayerStateChanged(self, pID, roster):
     if pID == account_helpers.getPlayerID():
         playerInfo = self.getPlayerInfo(pID=pID)
         self.storage.isObserver = playerInfo.isVehicleSpecified(
         ) and playerInfo.getVehicle().isObserver
     super(EpicBattleTrainingEntity,
           self).prb_onPlayerStateChanged(pID, roster)
Exemple #2
0
    def getRosterKey(self, pID = None):
        rosters = prb_control.getPrebattleRosters()
        rosterRange = PREBATTLE_ROSTER.getRange(self.getPrbType())
        if pID is None:
            pID = account_helpers.getPlayerID()
        for roster in rosterRange:
            if roster in rosters and pID in rosters[roster].keys():
                return roster

        return PREBATTLE_ROSTER.UNKNOWN
Exemple #3
0
    def getRosterKey(self, pID = None):
        rosters = prb_getters.getPrebattleRosters()
        rosterRange = PREBATTLE_ROSTER.getRange(self.getEntityType())
        if pID is None:
            pID = account_helpers.getPlayerID()
        for roster in rosterRange:
            if roster in rosters and pID in rosters[roster].keys():
                return roster

        return PREBATTLE_ROSTER.UNKNOWN
Exemple #4
0
    def getPlayerInfo(self, pID = None, rosterKey = None):
        rosters = prb_control.getPrebattleRosters()
        if pID is None:
            pID = account_helpers.getPlayerID()
        if rosterKey is not None:
            if rosterKey in rosters and pID in rosters[rosterKey].keys():
                return prb_items.PlayerPrbInfo(pID, functional=self, roster=rosterKey, **rosters[rosterKey][pID])
        else:
            rosterRange = PREBATTLE_ROSTER.getRange(self.getPrbType())
            for roster in rosterRange:
                if roster in rosters and pID in rosters[roster].keys():
                    return prb_items.PlayerPrbInfo(pID, functional=self, roster=roster, **rosters[roster][pID])

        return prb_items.PlayerPrbInfo(-1L)
Exemple #5
0
    def getPlayerInfo(self, pID = None, rosterKey = None):
        rosters = prb_getters.getPrebattleRosters()
        if pID is None:
            pID = account_helpers.getPlayerID()
        if rosterKey is not None:
            if rosterKey in rosters and pID in rosters[rosterKey].keys():
                return prb_items.PlayerPrbInfo(pID, functional=self, roster=rosterKey, **rosters[rosterKey][pID])
        else:
            rosterRange = PREBATTLE_ROSTER.getRange(self.getEntityType())
            for roster in rosterRange:
                if roster in rosters and pID in rosters[roster].keys():
                    return prb_items.PlayerPrbInfo(pID, functional=self, roster=roster, **rosters[roster][pID])

        return prb_items.PlayerPrbInfo(-1L)
Exemple #6
0
    def prb_onPlayerRosterChanged(self, pID, prevRoster, roster, actorID):
        LOG_DEBUG('prb_onPlayerRosterChanged', pID, prevRoster, roster, actorID)
        rosters = self.getRosters(keys=[prevRoster, roster])
        actorInfo = self.getPlayerInfo(pID=actorID)
        playerInfo = self.getPlayerInfo(pID=pID)
        for listener in self.getListenersIterator():
            if actorInfo and playerInfo:
                listener.onPlayerRosterChanged(self, actorInfo, playerInfo)
            listener.onRostersChanged(self, rosters, False)

        if pID == account_helpers.getPlayerID():
            prevTeam, _ = decodeRoster(prevRoster)
            currentTeam, _ = decodeRoster(roster)
            if currentTeam is not prevTeam:
                self._invokeListeners('onPlayerTeamNumberChanged', self, currentTeam)
Exemple #7
0
 def isCurrentPlayer(self):
     if self.dbID > 0:
         result = self.dbID == getAccountDatabaseID()
     else:
         result = self.accID == getPlayerID()
     return result
 def assign(self, ctx, callback=None):
     pID = ctx.getPlayerID()
     prevTeam, _ = decodeRoster(self.getRosterKey(pID=pID))
     nextTeam, assigned = decodeRoster(ctx.getRoster())
     pPermissions = self.getPermissions()
     if prevTeam is nextTeam:
         if not pPermissions.canAssignToTeam(team=nextTeam, isSelfAssignment=pID == account_helpers.getPlayerID()):
             LOG_ERROR('Player can not change roster', nextTeam, assigned)
             if callback:
                 callback(False)
             return
     elif not pPermissions.canChangePlayerTeam():
         LOG_ERROR('Player can not change team', prevTeam, nextTeam)
         if callback:
             callback(False)
         return
     result = self.getLimits().isMaxCountValid(nextTeam, assigned)
     if result is not None and not result.isValid:
         LOG_ERROR('Max count limit', nextTeam, assigned)
         ctx.setErrorString(PREBATTLE_ERRORS.ROSTER_LIMIT)
         if callback:
             callback(False)
         return
     else:
         ctx.startProcessing(callback)
         BigWorld.player().prb_assign(ctx.getPlayerID(), ctx.getRoster(), ctx.onResponseReceived)
         return
Exemple #9
0
 def prb_onPlayerStateChanged(self, pID, roster):
     if pID == account_helpers.getPlayerID():
         playerInfo = self.getPlayerInfo(pID=pID)
         self.__states['isObserver'] = playerInfo.isVehicleSpecified() and playerInfo.getVehicle().isObserver
     super(TrainingFunctional, self).prb_onPlayerStateChanged(pID, roster)
Exemple #10
0
 def canMoveToUnassigned(self, pID):
     isSelfAssignment = pID == getPlayerID()
     return self.prbEntity.getPermissions().canAssignToTeam(
         self._getPlayerTeam(), isSelfAssignment)
Exemple #11
0
 def prb_onPlayerStateChanged(self, pID, roster):
     if pID == account_helpers.getPlayerID():
         playerInfo = self.getPlayerInfo(pID=pID)
         self.__states['isObserver'] = playerInfo.isVehicleSpecified(
         ) and playerInfo.getVehicle().isObserver
     super(TrainingFunctional, self).prb_onPlayerStateChanged(pID, roster)