本文整理汇总了Python中inventory.Inventory.resetStats方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.resetStats方法的具体用法?Python Inventory.resetStats怎么用?Python Inventory.resetStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.resetStats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ingressbot
# 需要导入模块: from inventory import Inventory [as 别名]
# 或者: from inventory.Inventory import resetStats [as 别名]
#.........这里部分代码省略.........
self.inventoryLock.acquire()
if len(args) == 0:
return "Your inventory holds " + str(len(self.inventory)) + "/2000 items.\n"
elif args.strip() == "full":
lines = self.invToStrings()
out = ""
for line in lines:
out += line + "\n";
return out
finally:
self.inventoryLock.release()
@botcmd(hidden=True)
def stat(self, mess, args):
"""Displays a statistic about the items you have recieved and spent.
The Parameter \"rst\" or \"reset\" resets the statistic.
"""
if self.cfg["master"] != mess.getFrom().getStripped():
return None
try:
self.inventoryLock.acquire()
if len(args) == 0:
lines = self.statsToStrings()
str = ""
first = True
for line in lines:
if not first:
str += "\n"
else:
first = False
str += line
return str
elif args.strip() == "rst" or args.strip() == "reset":
self.inventory.resetStats()
return "Stats resetted"
finally:
self.inventoryLock.release()
@botcmd
def seen(self, message, args):
"""Displays where a player was last seen on the map.
Takes one or more nicknames (seperated by space) as parameter.
"""
if len(args.strip()) == 0:
return "Please specify a nickname"
output = ""
tokens = args.strip().split(" ")
print len(tokens)
for key in tokens:
if key in self.playerHistory:
entry = self.playerHistory[key]
delta = datetime.datetime.now() - datetime.datetime.fromtimestamp(entry["when"] / 1000.0)
hours, remainder = divmod(delta.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
deltaStr = ""
if(delta.days > 0):
deltaStr += str(delta.days) + "d "
if(hours > 0):
deltaStr += str(hours) + "h "
deltaStr += str(minutes) + "m"
output += entry["player"] + " was last seen " + deltaStr + " ago on " + entry["where"] + "\n"
else:
output += "Can't remember " + key + "\n"
return output