当前位置: 首页>>代码示例>>Python>>正文


Python Params.getParams方法代码示例

本文整理汇总了Python中Params.getParams方法的典型用法代码示例。如果您正苦于以下问题:Python Params.getParams方法的具体用法?Python Params.getParams怎么用?Python Params.getParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Params的用法示例。


在下文中一共展示了Params.getParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TTWebSocketServer

# 需要导入模块: import Params [as 别名]
# 或者: from Params import getParams [as 别名]
class TTWebSocketServer(WebSocketServer):
    def __init__(self):
        WebSocketServer.__init__(self,clientClass = Player)
        self.teams = {'tizef':[],'tidu':[],'admin':[]}
        self.params = Params()
        self.threadCheckBattle = threading.Thread(target=self.checkBattle)
        self.threadCheckBattle.daemon = True
        self.threadCheckBattle.start()

    """
    this is util for checking for battles entering in zone
    """
    def checkBattle(self):
        self.keepAlive.set()
        while self.keepAlive.isSet(): # keepAlive is already set in pyWebSocket
            for index,value in enumerate(self.teams["tidu"]):
                if value.statuts != 1:
                    continue
                a = len(self.client) - 1 - index
                for index2,value2 in enumerate(self.teams["tizef"]):
                    #print("test :", value.username, "of the team tidu","and",value2.username, "of the team tizef")
                    if value2.status != 1:
                        continue
                    if utils.distance(value.pos,value2.pos) <= self.params.getParams("radius"):
                        print("beginning of a battle between :", value.username, "of the team tidu","and",value2.username, "of the team tizef")
                        tmpSup = BattleSupervisor(value2,value)
                        value.startBattle(value2,tmpSup)
                        value2.startBattle(value,tmpSup)

            for index,client in enumerate(self.client):
                if client.status is not "playing" or client.status is not "kill":
                    continue
                for index,zone in enumerate(self.params.getParams(zones)):
                    if utils.distance(zone.team,client.team) <= self.params.getParams("radius"):
                        zone.addPlayerInRadius(client)
            sleep(0.5)
                    
    def delClient(self,client):
        for index, aClient in enumerate(self.teams[client.team]) :
            if aClient == client:
                self.teams[client.team].pop(index)
        for index, aClient in enumerate(self.client) :
            if aClient == client:
                self.client.pop(index)    
        print("del the client : " + client.username)

    def send2team(self,data,team):
        for index, client in enumerate(self.teams[team]) :
            try:
                client.send(msg)
            except socket.error :
                self.client.pop(index)    
    """
    check if any user in your team have your pseudo and if your team exist
    return 0 if there isn't any error, 1 if team doesn't exist and 2 if the username already exist in your team
    """
    def addUser2Team(self,username,team,client):
        if not team in self.teams:
            return 1
        for aClient in self.client:
            if aClient.username==username and aClient.team==team:
                return 2
        self.teams[team].append(client)

    def setParams(self,data):
        if username == "admin":
            self.params.setParams(data)
开发者ID:sabro29,项目名称:tidutyzef,代码行数:69,代码来源:TTWebSocketServer.py


注:本文中的Params.getParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。