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


Python Inventory.resetStats方法代码示例

本文整理汇总了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
  
开发者ID:Protonex,项目名称:IngressBot,代码行数:69,代码来源:ingressbot.py


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