本文整理汇总了Python中Constants.buildingTopList方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.buildingTopList方法的具体用法?Python Constants.buildingTopList怎么用?Python Constants.buildingTopList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constants
的用法示例。
在下文中一共展示了Constants.buildingTopList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: realy_handle_command
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import buildingTopList [as 别名]
def realy_handle_command(command, connection=False, target=False):
retStr = []
s = re.search("^(?P<search>(a|f)?)(?P<type>(player)|(alliance)) (?P<name>.+)$", command)
if s:
if s.group("search") == "a":
api.quick = False
else:
api.quick = True
name = s.group("name").decode("utf-8")
if s.group("type") == "player":
if s.group("search") == "f":
data = api.findPlayer(name, 6)
else:
data = api.getPlayerString(name)
if s.group("type") == "alliance":
if s.group("search") == "f":
data = api.findAlliance(name, 6)
else:
data = api.getAllianceString(name)
retStr = "".join(data).split("\n")
elif command == "help":
retStr.append(u"!player name - infos zu einem spieler")
retStr.append(u"!alliance tag - infos zu einer allianz")
retStr.append(u"!aplayer bzw. aalliance - gibt erweiterte infos")
retStr.append(u"!fplayer bzw. falliance - gibt 6 spieler/allianz nach Ähnlichkeit zurück")
retStr.append(u"!which met kris deut [plasma] [temp] [kurs] - gibt Vorschlag welche Mine am besten zu bauen ist - help which für mehr")
retStr.append(u"!awhich same as which, but a bit more detailed")
retStr.append(u"!diff playername [hours] - highscore diff")
retStr.append(u"!inactive yourpos [radius] [duration] [minscore] [maxscore] [maxdefperplanet]- finds inactive. use ainactive for more results")
retStr.append(u"!dinactive yourpos [radius] [duration] [maxdefperplanet] - finds inactive")
elif command == "help which":
retStr.append(u"Beispielaufruf: !which 18 15 12 für met=18,kris=15 und deut=12 - plasmatech=0 und maximale temperatur=50 da nicht angegeben, kurs=2:1:1")
retStr.append(u"Beispielaufruf: !which 18 15 12 3 45 3:2:1 nun ist plasma=3, temp=45 und der kurs 3:2:1")
elif command.startswith("which ") or command.startswith("awhich"):
args = command.split(" ")
plasma = 0
temp = 50
mse = [2.0, 1.0, 1.0]
buildings = {}
if len(args) > 2:
buildings[1] = int(args[1])
buildings[2] = int(args[2])
if len(args) > 3:
buildings[3] = int(args[3])
if len(args) > 4:
plasma = int(args[4])
if len(args) > 5:
temp = int(args[5])
if len(args) > 6:
mse = []
for i in args[6].split(":"):
mse.append(float(i))
import Constants
Constants.loadLanguage("de")
if command.startswith("which "):
bId = Constants.buildingTopList(buildings, {122:plasma}, temp, mse)[0]["bId"]
retStr.append("Am besten baust du: %s" % Constants.buildLabels[bId])
else:
t = Constants.buildingTopList(buildings, {122:plasma}, temp, mse)
i = 0
for build in t:
i+=1
bId = build["bId"]
atime = build["atime"]
import datetime
atime = str(datetime.timedelta(seconds=atime))
retStr.append("%d: %s %s" % (i, Constants.buildLabels[bId], atime))
elif command == "dbupdate":
import db
if connection:
connection.privmsg(target, "updating db - this takes some time..")
db.update(server)
retStr.append("updated")
elif command.startswith("dbquery"):
import db
try:
res = db.query(command[8:])
except Exception, ex:
connection.privmsg(target, ex)
if len(command[8:]) == 445:
retStr.append("Your query can't be longer than 445 chars")
retStr.append(command[8:])
return
if res is None:
retStr = ["No result for your query"]
max = 9
for line in res:
max -= 1
if max == 0:
break
retStr.append(str(line).replace("\n", "")[:406]+" ...")