本文整理汇总了Python中Params.setParams方法的典型用法代码示例。如果您正苦于以下问题:Python Params.setParams方法的具体用法?Python Params.setParams怎么用?Python Params.setParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Params
的用法示例。
在下文中一共展示了Params.setParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TTWebSocketServer
# 需要导入模块: import Params [as 别名]
# 或者: from Params import setParams [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)