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


Python Updates.current_tick方法代码示例

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


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

示例1: list

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def list(self, message, user, params):
     Q = session.query(Attack)
     if user.access < (Config.getint("Access",  "hc") if "hc" in Config.options("Access") else 1000): # Hide attacks until they are active, unless the user has access
         Q = Q.filter(Attack.landtick <= Updates.current_tick() + Config.getint("Misc", "attactive"))
     Q = Q.filter(Attack.landtick + Attack.waves >= Updates.current_tick()) # Hide attacks one tick after the last wave has landed
     Q = Q.order_by(asc(Attack.id))
     
     replies = []
     for attack in Q:
         replies.append("(%d LT: %d %s)" %(attack.id,attack.landtick,attack.comment,))
     
     reply = "Open attacks: " + " ".join(replies)
     message.reply(reply)
开发者ID:JDD,项目名称:merlin,代码行数:15,代码来源:attack.py

示例2: update_comment_and_fleetcount

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def update_comment_and_fleetcount(self,user,fleetcount,comment):
     user.fleetcount = fleetcount
     if comment != "":
         if comment in self.nulls:
             comment=""
         user.fleetcomment = comment
     user.fleetupdated = Updates.current_tick()
开发者ID:munin,项目名称:merlin,代码行数:9,代码来源:mydef.py

示例3: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def execute(self, message, user, params):
     
     tick = Updates.current_tick() + (params.group(1) or 1)
     replies = []
     
     Q = session.query(Galaxy.x, Galaxy.y, count())
     Q = Q.join(Target.planet)
     Q = Q.join(Planet.galaxy)
     Q = Q.filter(Planet.active == True)
     Q = Q.filter(Target.tick >= tick)
     Q = Q.group_by(Galaxy.x, Galaxy.y)
     result = Q.all()
     prev = []
     for x, y, bitches in result:
         prev.append("%s:%s(%s)"%(x,y,bitches))
     replies.append("Active bookings: " + ", ".join(prev))
     
     Q = session.query(Alliance.name, count())
     Q = Q.join(Target.planet)
     Q = Q.outerjoin(Planet.intel)
     Q = Q.outerjoin(Intel.alliance)
     Q = Q.filter(Planet.active == True)
     Q = Q.filter(Target.tick >= tick)
     Q = Q.group_by(Alliance.name)
     result = Q.all()
     prev = []
     for name, bitches in result:
         prev.append("%s (%s)"%(name or "Unknown", bitches))
     replies.append("Active bitches: " + ", ".join(prev))
     
     if len(replies) < 1:
         replies.append("No active bookings. This makes %s sad. Please don't make %s sad." %((Config.get("Connection","nick"),)*2))
     message.reply("\n".join(replies))
开发者ID:Go3Media,项目名称:merlin,代码行数:35,代码来源:bitches.py

示例4: land

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def land(self, message, user, params):
     id = int(params.group(1))
     attack = Attack.load(id)
     if attack is None:
         message.alert("No attack exists with id %d" %(id))
         return
     
     tick = Updates.current_tick()
     when = int(params.group(2))
     
     if when == 0:
         session.delete(attack)
         session.commit()
         message.reply("Deleted Attack %d LT: %d | %s" %(attack.id,attack.landtick,attack.comment,))
         return
     
     if when < PA.getint("numbers", "protection"):
         eta = when
         when += tick
     elif when <= tick:
         message.alert("Can not create attacks in the past. You wanted tick %s, but current tick is %s." % (when, tick,))
         return
     else:
         eta = when - tick
     if when > 32767:
         when = 32767
     
     old = attack.landtick
     attack.landtick = when
     
     session.commit()
     message.reply("Changed LT for attack %d from %d to %d"%(id,old,when))
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:34,代码来源:editattack.py

示例5: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
    def execute(self, message, user, params):
        
        fleetcount = int(params.group(1))
        comment = params.group(2)
        reply = ""

        if user.planet:
            scan = user.planet.scan("A")
            if scan is None:
                message.reply("Advanced Unit Scan not found for %s:%s:%s" % (user.planet.x, user.planet.y, user.planet.z))
                return
        else:
            message.reply("Planet not set. Use !pref planet=x:y:z")
            return

        scanage = Updates.current_tick() - scan.tick
        if scanage > 12:
            reply += "Warning: Scan is %d ticks old.\n" % scanage

        self.update_comment_and_fleetcount(user, fleetcount, comment)
        user.fleets.delete()
        for uscan in scan.units:
            user.fleets.append(UserFleet(ship_id=uscan.ship_id, ship_count=uscan.amount))
        session.commit()

        ships = user.fleets.all()
        
        reply += "Updated your def info to: fleetcount %s, updated: pt%s ships: " % (user.fleetcount, user. fleetupdated)
        reply += ", ".join(map(lambda x:"%s %s" % (self.num2short(x.ship_count), x.ship.name), ships))
        reply += " and comment: %s" %(user.fleetcomment)
        message.reply(reply)
开发者ID:JDD,项目名称:merlin,代码行数:33,代码来源:aumydef.py

示例6: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def execute(self, message, user, params):
     
     search=params.group(1)
     
     Q = session.query(FleetLog)
     
     if search != "":
         ship = Ship.load(name=search)
         if ship is not None:
             Q = Q.filter(FleetLog.ship == ship)
         else:
             u = User.load(search, exact=False, access="member")
             if u is not None:
                 Q = Q.filter(FleetLog.user == u)
             else:
                 Q = Q.filter(FleetLog.id == -1)
     Q = Q.order_by(desc(FleetLog.tick))
     
     result = Q[:10]
     
     if len(result) < 1:
         message.reply("No matches found in the deflog for search '%s'"%(search,))
         return
     
     tick = Updates.current_tick()
     reply = ", ".join(map(lambda x:"%s gave %s %s to %s (%s)"%(x.user.name,self.num2short(x.ship_count),x.ship.name,x.taker.name,x.tick-tick),result))
     message.reply(reply)
开发者ID:Go3Media,项目名称:merlin,代码行数:29,代码来源:logdef.py

示例7: tick

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [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

示例8: tick

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [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

示例9: rollback

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
def rollback(message):
    """Rollback to a given tick. Tick must be repeated for confirmation."""
    
    msg = message.get_msg().split()[1:]
    if len(msg) != 2:
        message.reply("rollback <tick> <tick>")
        return
    if msg[0] != msg[1]:
        message.reply("Ticks must match!")
        return
    if not msg[0].isdigit():
        message.reply("Ticks should be numeric.")
        return
    if int(msg[0]) > Updates.current_tick():
        message.reply("Timetravel module not installed. Cannot rollback to a future tick.")
        return

    session.execute(text("DELETE FROM updates WHERE id > %s;" % (msg[0])))
    session.execute(text("DELETE FROM planet_exiles WHERE tick > %s;" % (msg[0])))
    session.execute(text("DELETE FROM planet_idles WHERE tick > %s;" % (msg[0])))
    session.execute(text("DELETE FROM planet_value_drops WHERE tick > %s;" % (msg[0])))
    session.execute(text("DELETE FROM planet_landings WHERE tick > %s;" % (msg[0])))
    session.execute(text("DELETE FROM planet_landed_on WHERE tick > %s;" % (msg[0])))
    session.execute(text("DELETE from galaxy_history where tick > %s;" % (msg[0])))
    session.execute(text("DELETE from planet_history where tick > %s;" % (msg[0])))
    session.execute(text("DELETE from alliance_history where tick > %s;" % (msg[0])))
    session.execute(text("DELETE from cluster_history where tick > %s;" % (msg[0])))

    session.commit()
    message.reply("Rollback complete. Bot will update at next tick.")
开发者ID:JDD,项目名称:merlin,代码行数:32,代码来源:rollback.py

示例10: links

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def links(self, message, user, params):
     Q = session.query(Request)
     Q = Q.filter(Request.tick > Updates.current_tick() - 5)
     Q = Q.filter(Request.active == True)
     Q = Q.order_by(asc(Request.id))
     
     message.reply(" ".join(map(lambda request: "[%s: %s]" % (request.id, request.link,), Q[:5])))
开发者ID:munin,项目名称:merlin,代码行数:9,代码来源:request.py

示例11: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def execute(self, request, user, id, x, y, z, when):
     planet = Planet.load(x,y,z)
     if planet is None:
         return self.attack(request, user, id, "No planet with coords %s:%s:%s" %(x,y,z,))
     
     tick = Updates.current_tick()
     when = int(when)
     if when < PA.getint("numbers", "protection"):
         eta = when
         when += tick
     elif when <= tick:
         return self.attack(request, user, id, "Can not book targets in the past. You wanted tick %s, but current tick is %s." % (when, tick,))
     else:
         eta = when - tick
     if when > 32767:
         when = 32767        
     
     if planet.intel and planet.alliance and planet.alliance.name == Config.get("Alliance","name"):
         return self.attack(request, user, id, "%s:%s:%s is %s in %s. Quick, launch before they notice!" % (x,y,z, planet.intel.nick or 'someone', Config.get("Alliance","name"),))
     
     try:
         planet.bookings.append(Target(user=user, tick=when))
         session.commit()
     except IntegrityError:
         session.rollback()
         target = planet.bookings.filter(Target.tick == when).first()
         if target is not None:
             return self.attack(request, user, id, "Target %s:%s:%s is already booked for landing tick %s by user %s" % (x,y,z, when, target.user.name,))
     else:
         return self.attack(request, user, id, "Booked landing on %s:%s:%s tick %s (eta %s) for user %s" % (x,y,z, when, (when-tick), user.name,))
     
     return self.attack(request, user, id)
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:34,代码来源:book.py

示例12: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def execute(self, request, user, id, message=None):
     attack = Attack.load(id)
     if attack is None or not attack.active:
         return HttpResponseRedirect(reverse("attacks"))
     
     waves = xrange(attack.landtick, attack.landtick + Attack._waves)
     show_jgps = attack.landtick <= Updates.current_tick() + Attack._show_jgp_ticks
     
     group = []
     scans = []
     for planet in attack.planets:
         group.append((planet, [], [],))
         if planet.scan("P"):
             group[-1][1].append(planet.scan("P"))
             scans.append(planet.scan("P"))
         
         if planet.scan("D"):
             group[-1][1].append(planet.scan("D"))
             scans.append(planet.scan("D"))
         
         if planet.scan("A") or planet.scan("U"):
             group[-1][1].append(planet.scan("A") or planet.scan("U"))
             scans.append(planet.scan("A") or planet.scan("U"))
         
         if show_jgps and planet.scan("J"):
             group[-1][1].append(planet.scan("J"))
             scans.append(planet.scan("J"))
         
         bookings = dict([(target.tick, target,) for target in planet.bookings.filter(Target.tick.between(attack.landtick, attack.landtick+4))])
         for tick in waves:
             group[-1][2].append((tick, bookings.get(tick) or (False if show_jgps else None),))
     
     return render("attack.tpl", request, attack=attack, message=message, waves=waves, group=group, scans=scans)
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:35,代码来源:attack.py

示例13: bonus

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
    def bonus(self, message, user, params):

        # Check if tick is provided
        tick = int(params.group(1) or 0)

        if tick > PA.getint("numbers", "last_tick"):
            message.reply("Use your bonus during the round, not after.")
            return

        # If there is no tick provided in the command then check what the current tick is.
        if not tick:
            # Retrieve current tick
            tick = Updates.current_tick()
            if not tick:
                # Game not ticking yet.
                message.reply("Game is not ticking yet!")
                return

        resources = 10000 + tick * 4800
        roids = int(6 + tick * 0.15)
        research = 4000 + tick * 24
        construction = 2000 + tick * 18

        message.reply(
            "Upgrade Bonus calculation for tick {} | Resources: {:,} EACH | Roids: {:,} EACH | Research Points: {:,} | Construction Units: {:,}".format(
                tick, resources, roids, research, construction
            )
        )
开发者ID:liam-wiltshire,项目名称:merlin,代码行数:30,代码来源:bonus.py

示例14: execute

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
 def execute(self, request, user, sort=None):
     
     levels = [] + User.levels
     
     if sort is not None:
         levels = [("All member", levels[-1][1],),]
     
     order =  {"name"  : (asc(User.name),),
               "sponsor" : (asc(User.sponsor),),
               "access" : (desc(User.access),desc(User.carebears),asc(User.name),),
               "carebears" : (desc(User.carebears),),
               "planet" : (asc(Planet.x),asc(Planet.y),asc(Planet.z),),
               "defage" : (asc(User.fleetupdated),),
               }
     if sort not in order.keys():
         sort = "name"
     order = order.get(sort)
     
     members = []
     for level in levels:
         Q = session.query(User.name, User.alias, User.sponsor, User.access, User.carebears, Planet, User.fleetupdated,
                           User.phone, User.pubphone, User.id.in_(session.query(PhoneFriend.user_id).filter_by(friend=user)))
         Q = Q.outerjoin(User.planet)
         Q = Q.filter(User.active == True)
         Q = Q.filter(User.access >= level[1])
         Q = Q.filter(User.access < levels[levels.index(level)-1][1]) if levels.index(level) > 0 else Q
         for o in order:
             Q = Q.order_by(o)
         
         members.append((level[0], Q.all(),))
     
     return render("members.tpl", request, accesslist=members, tick=Updates.current_tick()*-1)
开发者ID:munin,项目名称:merlin,代码行数:34,代码来源:members.py

示例15: list

# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import current_tick [as 别名]
    def list(self, message, user, params):
        Q = session.query(func.count().label("count"), func.max(Request.id).label("max_id"))
        Q = Q.filter(Request.tick > Updates.current_tick() - 5)
        Q = Q.filter(Request.active == True)
        Q = Q.group_by(Request.planet_id, Request.scantype)
        Q = Q.order_by(asc("max_id"))
        SQ = Q.subquery()
        Q = session.query(Request, SQ.c.count).join((SQ, and_(Request.id == SQ.c.max_id)))

        if Q.count() < 1:
            message.reply("There are no open scan requests")
            return

        message.reply(
            " ".join(
                map(
                    lambda (request, count): Config.get("Misc", "reqlist").decode("string_escape")
                    % (
                        request.id,
                        request.target.intel.dists if request.target.intel else "0",
                        "/%s" % request.dists if request.dists > 0 else "",
                        request.scantype,
                        request.target.x,
                        request.target.y,
                        request.target.z,
                    ),
                    Q.all(),
                )
            )
        )
开发者ID:liam-wiltshire,项目名称:merlin,代码行数:32,代码来源:request.py


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