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


Python Updates.load方法代码示例

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


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

示例1: tick

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
 def tick(self, message, user, params):
     tick = Updates.load(params.group(1)) or Updates.current_tick()
     if isinstance(tick, Updates): # We have that tick
         message.reply(str(tick))
     elif tick == 0:               # We don't have any ticks
         ticktime = GameSetup.getint("round_start_time") + (int(params.group(1))-1)*GameSetup.getint("tick_speed")
         tdiff = int(ticktime - time.time())
         tdelta = abs(tdiff / 86400)
         retstr  = " %sd" % tdelta if tdelta else ""
         tdelta = (tdiff % 86400) / 3600
         retstr += " %sh" % tdelta if tdelta else ""
         tdelta = (tdiff % 3600) / 60
         retstr += " %sm" % tdelta if tdelta else ""
         retstr = "Tick %s %s expected to happen%s%s%s - %s" % (params.group(1), "is" if tdiff >= 0 else "was", " in" if tdiff >= 0 else "", retstr, " ago" if tdiff < 0 else "", datetime.utcfromtimestamp(float(ticktime)).strftime("%a %d/%m %H:%M UTC"))
         message.reply(retstr)
     else:                         # We have some ticks, but not that one
         diff = int(params.group(1)) - tick
         now = datetime.utcnow()
         tick_speed = GameSetup.getint("tick_speed")
         tdiff = timedelta(seconds=tick_speed*diff)-timedelta(minutes=now.minute%(tick_speed/60))
         retstr  = "%sd " % abs(tdiff.days) if tdiff.days else ""
         retstr += "%sh " % abs(tdiff.seconds/3600) if tdiff.seconds/3600 else ""
         retstr += "%sm " % abs(tdiff.seconds%3600/60) if tdiff.seconds%3600/60 else ""
             
         if diff == 1:
             retstr = "Next tick is %s (in %s" % (params.group(1), retstr)
         elif diff > 1:
             retstr = "Tick %s is expected to happen in %s ticks (in %s" % (params.group(1), diff, retstr)
         elif diff <= 0:
             retstr = "Tick %s was expected to happen %s ticks ago but was not scraped (%s ago" % (params.group(1), -diff, retstr)
         
         ticktime = now + tdiff
         retstr += " - %s)" % (ticktime.strftime("%a %d/%m %H:%M UTC"),)
         message.reply(retstr)
开发者ID:berten,项目名称:merlin,代码行数:36,代码来源:tick.py

示例2: tick

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
    def tick(self, message, user, params):
        tick = Updates.load(params.group(1)) or Updates.current_tick()
        if tick is None:
            message.reply("Ticks haven't started yet, go back to masturbating.")
        elif isinstance(tick, Updates):
            message.reply(str(tick))
        else:
            diff = int(params.group(1)) - tick
            now = datetime.utcnow()
            tick_length = PA.getint("numbers", "tick_length")
            tdiff = timedelta(seconds=tick_length * diff) - timedelta(minutes=now.minute % (tick_length / 60))
            seconds = 0
            retstr = "%sd " % abs(tdiff.days) if tdiff.days else ""
            retstr += "%sh " % abs(tdiff.seconds / 3600) if tdiff.seconds / 3600 else ""
            retstr += "%sm " % abs(tdiff.seconds % 3600 / 60) if tdiff.seconds % 3600 / 60 else ""

            if diff == 1:
                retstr = "Next tick is %s (in %s" % (params.group(1), retstr)
            elif diff > 1:
                retstr = "Tick %s is expected to happen in %s ticks (in %s" % (params.group(1), diff, retstr)
            elif diff <= 0:
                retstr = "Tick %s was expected to happen %s ticks ago but was not scraped (%s ago" % (
                    params.group(1),
                    -diff,
                    retstr,
                )

            time = now + tdiff
            retstr += " - %s)" % (time.strftime("%a %d/%m %H:%M"),)
            message.reply(retstr)
开发者ID:liam-wiltshire,项目名称:merlin,代码行数:32,代码来源:tick.py

示例3: tick

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
 def tick(self, message, user, params):
     tick = Updates.load(params.group(1)) or Updates.current_tick()
     if tick is None:
         message.reply("Ticks haven't started yet, go back to masturbating.")
     elif isinstance(tick, Updates):
         message.reply(str(tick))
     else:
         diff = int(params.group(1)) - tick
         now = datetime.utcnow()
         seconds = 0
         retstr = ""
         if diff > 0:
             
             if diff > 24:
                 days = (diff-1)/24
                 seconds += days*24*60*60
                 retstr += "%sd " % (days,)
             
             if diff > 1:
                 hours = (diff-1)%24
                 seconds += hours*60*60
                 retstr += "%sh " % (hours,)
             
             mins = 60 - now.minute
             seconds += mins *60
             retstr += "%sm" % (mins,)
             
             if diff == 1:
                 retstr = "Next tick is %s (in %s" % (params.group(1), retstr,)
             else:
                 retstr = "Tick %s is expected to happen in %s ticks (in %s" % (params.group(1), diff, retstr,)
         
         elif diff < 0:
             
             if diff < -23:
                 days = (-diff)/24
                 seconds -= days*24*60*60
                 retstr += "%sd " % (days,)
                 
             if diff < -1:
                 hours = (-diff)%24
                 seconds -= hours*60*60
                 retstr += "%sh " % (hours,)
                 
             mins = now.minute
             seconds -= mins*60
             retstr += "%sm" % (mins,)
             
             if diff == -1:
                 retstr = "Last tick was %s (%s ago" % (params.group(1), retstr,)
             else:
                 retstr = "Tick %s was expected to happen %s ticks ago but was not scraped (%s ago" % (params.group(1), -diff, retstr,)
         
         time = now + timedelta(seconds=seconds)
         retstr += " - %s)" % (time.strftime("%a %d/%m %H:%M"),)
         message.reply(retstr)
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:58,代码来源:tick.py

示例4: current

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
 def current(self, message, user, params):
     tick = Updates.load()
     if tick is None:
         if time.time() > GameSetup.getint("round_start_time"):
             tdiff = abs(int(GameSetup.getint("round_start_time") - time.time())) / GameSetup.getint("tick_speed") + 1
             message.reply("It *should* be tick %s, but I'm not ticking. Did someone forget to press the magic button?" % tdiff)
             if tdiff > 1:
                 admin_msg("It should be tick %s, but I'm not ticking!" % tdiff)
         else:
             message.reply("Ticks haven't started yet, go back to masturbating.")
     else:
         message.reply(str(tick))
开发者ID:berten,项目名称:merlin,代码行数:14,代码来源:tick.py

示例5: base_context

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
def base_context(request):
    context = {"name"   : Config.get("Alliance", "name"),
               "slogan" : Config.get("Alliance", "name"),
               "tick"   : Updates.current_tick(),
               "update" : Updates.load(),
               "graphs" : Config.get("Misc", "graphing") != "disabled",
               }
    if getattr(request, "user", None) is not None:
        context["user"] = request.user
        context["menu"] = menu.generate(request.user)
    if getattr(request, "session", None) is not None:
        slogan, count = Slogan.search("")
        if slogan is not None:
            context["slogan"] = str(slogan)
    if Config.has_section("FluxBB") and Config.getboolean("FluxBB", "enabled"):
        context["fluxurl"] = "<br><br><a href=\"%s\">Forum</a>" % (Config.get("FluxBB", "url"))
    return context
开发者ID:davesherratt,项目名称:merlin,代码行数:19,代码来源:context.py

示例6: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
    def execute(self, message, alliance=None, race=None, sortby="score"):
        planet = aliased(Planet)
        planet_intel = aliased(Intel)
        

        Q = session.query(planet.x, planet.y, planet.z, planet.score, planet.value, planet.size, planet.xp, planet.race, planet_intel.nick)
        Q = Q.join((planet.intel, planet_intel))
        if alliance:
            Q = Q.filter(planet_intel.alliance == alliance)
        if race:
            Q = Q.filter(planet.race == race)
        Q = Q.group_by(planet.x, planet.y, planet.z, planet.score, planet.value, planet.size, planet.xp, planet.race, planet_intel.nick)
        if sortby == "xp":
            Q = Q.order_by(asc(planet.xp))
        elif sortby == "size":
            Q = Q.order_by(asc(planet.size))
        elif sortby == "value":
            Q = Q.order_by(asc(planet.value))
        else:
            Q = Q.order_by(asc(planet.score))
        result = Q.all()
        
        reply = "Bottom%s planets" % (" "+race if race is not None else "")
        if alliance:
            reply+=" in %s"%(alliance.name,)
        reply+=" by %s:\n"%(sortby)
        prev = []
        if alliance:
            i = alliance.members # Not set for some reason... It should be.
        else:
            i = Updates.load().planets
        for x, y, z, score, value, size, xp, race, nick in result[:10]:
            i-=1
            line = "#%s - %s:%s:%s (%s) - Score: %s Value: %s Size: %s XP: %s"%(i,x,y,z,race,score,value,size,xp)
            if nick:
                line = "%s Nick: %s"%(line,nick)
            prev.append(line)
        message.reply(reply+"\n".join(prev))
开发者ID:JDD,项目名称:merlin,代码行数:40,代码来源:last10.py

示例7: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
    def execute(self, message, user, params):
        
        planet = Planet.load(*params.group(1,3,5))
        if planet is None:
            message.alert("No planet with coords %s:%s:%s" % params.group(1,3,5))
            return

        tick=Updates.load().current_tick()

        pscan = planet.scan("P")
        if pscan is None:
            message.reply("No Planet Scans of %s:%s:%s found"%(planet.x,planet.y,planet.z))
            return
        else:
            p_age = tick - pscan.tick
            pscan = pscan.planetscan

        dscan = planet.scan("D")
        if dscan is None:
            message.reply("No Development Scans of %s:%s:%s found"%(planet.x,planet.y,planet.z))
            return
        else:
            d_age = tick - dscan.tick
            dscan = dscan.devscan

        gov_bonus = 0
        gov = "Unknown"
        if planet.intel.gov is not None:
            if planet.intel.gov[0].lower() == "c":
                gov = "Corporatism"
                gov_bonus = -0.05
            if planet.intel.gov[0].lower() == "d":
                gov = "Democracy"
                gov_bonus = -0.10
            if planet.intel.gov[0].lower() == "n":
                gov = "Nationalism"
                gov_bonus = 0.25
            if planet.intel.gov[0].lower() == "s":
                gov = "Socialism"
                gov_bonus = 0.00
            if planet.intel.gov[0].lower() == "t":
                gov = "Totalitarianism"
                gov_bonus = 0.10


        alert_min = int((50+5*min(pscan.guards/(planet.size+1),15))*(1+dscan.security_centre*2/dscan.total + (gov_bonus if gov != "Unknown" else -0.10) + 0.0))
        alert_max = int((50+5*min(pscan.guards/(planet.size+1),15))*(1+dscan.security_centre*2/dscan.total + (gov_bonus if gov != "Unknown" else +0.25) + 0.5))

        message.reply("Planet: %s:%s:%s  Government: %s  Alert: %s-%s  (Scan Age P:%s D:%s)" % (planet.x, planet.y, planet.z, gov, alert_min, alert_max, p_age, d_age))
        if params.group(6):
            agents = int(params.group(6))
            max_res = user.planet.resources_per_agent(planet)
            message.reply("Results:   SD: %1.1f%% (%dXP) NC: %d%% (%dXP) EF: %d roids (%dXP) S: %d ships (%dXP) SGP: %d guards (%dXP)" % (0.5*agents, self.xpcalc(agents,1),
                     agents, self.xpcalc(agents,2), agents/3, self.xpcalc(agents,3), agents, self.xpcalc(agents,4), 10*agents, self.xpcalc(agents,5)))
            message.reply("           IB: %d amps+dists (%dXP) RT: %dM %dC %dE (%dXP) H: %d buildings (%dXP)" % (agents/15, self.xpcalc(agents,6),
                     min(max_res, pscan.res_metal/10), min(max_res, pscan.res_crystal/10), min(max_res, pscan.res_eonium/10), self.xpcalc(agents,7), agents/20, self.xpcalc(agents,8)))

            if params.group(7):
                stealth = int(params.group(7))
                stealth = stealth - 5 - int(agents/2)
                t=19-alert_min
                prob = 100*(t+stealth)/(t+alert_max)
                if prob < 0:
                    prob = 0
                elif prob > 100:
                    prob = 100

                race = user.planet.race
                if race == "Ter":
                    growth = 6
                elif race == "Cat":
                    growth = 10
                elif race == "Xan":
                    growth = 4
                elif race == "Zik":
                    growth = 6
                elif race == "Etd":
                    growth = 6
                from math import ceil
                message.reply("New stealth: %s  Success rate: %s%%  Recovery time: %1.1f ticks" % (stealth, prob, ceil((5+int(agents/2))/growth)))
开发者ID:davesherratt,项目名称:merlin,代码行数:82,代码来源:covop.py

示例8: current

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
 def current(self, message, user, params):
     tick = Updates.load()
     if tick is None:
         message.reply("Ticks haven't started yet, go back to masturbating.")
     else:
         message.reply(str(tick))
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:8,代码来源:tick.py

示例9: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import load [as 别名]
    def execute(self, message, user, params):
        
        planet = Planet.load(*params.group(1,3,5))
        if planet is None:
            message.alert("No planet with coords %s:%s:%s" % params.group(1,3,5))
            return

        tick=Updates.load().current_tick()

        pscan = planet.scan("P")
        if pscan is None:
            message.reply("No Planet Scans of %s:%s:%s found"%(planet.x,planet.y,planet.z))
            return
        else:
            p_age = tick - pscan.tick
            pscan = pscan.planetscan

        dscan = planet.scan("D")
        if dscan is None:
            message.reply("No Development Scans of %s:%s:%s found"%(planet.x,planet.y,planet.z))
            return
        else:
            d_age = tick - dscan.tick
            dscan = dscan.devscan

        # Get government info from pa.cfg and intel
        gov_bonus = 0
        gov = "Unknown"
        gov_alert_max = 0.00
        gov_alert_min = 0.00
        int_gov = planet.intel.gov
        if int_gov is not None:
            int_gov = int_gov[0].lower()
        for gcode in PA.options("govs"):
            gov_alert = PA.getfloat(gcode, "alert")
            if int_gov and int_gov == gcode[0]:
                gov = PA.get(gcode, "name")
                gov_bonus = gov_alert
            if gov_alert > gov_alert_max:
                gov_alert_max = gov_alert
            if gov_alert < gov_alert_min:
                gov_alert_min = gov_alert


        alert_min = int((50+5*min(pscan.guards/(planet.size+1),15))*(1+dscan.security_centre*0.0275 + (gov_bonus if gov != "Unknown" else gov_alert_min) + 0.0))
        alert_max = int((50+5*min(pscan.guards/(planet.size+1),15))*(1+dscan.security_centre*0.0275 + (gov_bonus if gov != "Unknown" else gov_alert_max) + 0.5))

        message.reply("Planet: %s:%s:%s  Government: %s  Alert: %s-%s  (Scan Age P:%s D:%s)" % (planet.x, planet.y, planet.z, gov, alert_min, alert_max, p_age, d_age))
        if params.group(6):
            agents = int(params.group(6))
            max_res = user.planet.resources_per_agent(planet)
            message.reply("Results:   EF: %d roids (%dXP) AD: %d agents (%dXP) SGD: %d guards (%dXP) H:SD: %1.2f%% RP (%dXP) WDM: %d ship value (%dXP)" % (agents //3, 
                     self.xpcalc(agents,1), agents, self.xpcalc(agents,2), agents*10, self.xpcalc(agents,3), agents*0.25, self.xpcalc(agents,4), 
                     agents*(min(50+10*planet.value//user.planet.value, 100)), self.xpcalc(agents,5)))
            message.reply("           IB: %d amps+dists (%dXP) H: %d buildings (%dXP) H:RT: %dM %dC %dE (%dXP) GS: %d ticks (%dXP)" % (agents//15, self.xpcalc(agents,6),
                     agents//20, self.xpcalc(agents,7), min(max_res, pscan.res_metal//10), min(max_res, pscan.res_crystal//10), min(max_res, pscan.res_eonium//10),
                     self.xpcalc(agents,8), agents//5, self.xpcalc(agents,9)))

            # If stealth is supplied, calculate the probability of success.
            if params.group(7):
                stealth = int(params.group(7))
                stealth = stealth - 5 - int(agents/2)
                t=8-alert_min
                prob = 100*(t+stealth)//(t+alert_max)
                if prob < 0:
                    prob = 0
                elif prob > 100:
                    prob = 100

                growth = PA.getint(user.planet.race.lower(), "sgrowth")
                from math import ceil
                message.reply("New stealth: %s  Success rate: %s%%  Recovery time: %d ticks" % (stealth, prob, ceil((5.0+int(agents/2))/growth)))
开发者ID:d7415,项目名称:merlin,代码行数:74,代码来源:covop.py


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