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


Python paconf.PA类代码示例

本文整理汇总了Python中Core.paconf.PA的典型用法代码示例。如果您正苦于以下问题:Python PA类的具体用法?Python PA怎么用?Python PA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

 def execute(self, message, user, params):
     
     num, name = params.groups()
     
     ship = Ship.load(name=name)
     if ship is None:
         message.alert("No Ship called: %s" % (name,))
         return
     
     num = self.short2num(num)
     reply="Buying %s %s will cost %s metal, %s crystal and %s eonium."%(num,ship.name,
             self.num2short(ship.metal*num),
             self.num2short(ship.crystal*num),
             self.num2short(ship.eonium*num))
     
     for gov in PA.options("govs"):
         bonus = PA.getfloat(gov, "prodcost")
         if bonus == 0:
             continue
         
         reply += " %s: %s metal, %s crystal and %s eonium."%(
                     PA.get(gov, "name"),
                     self.num2short(ship.metal*(1+bonus)*num),
                     self.num2short(ship.crystal*(1+bonus)*num),
                     self.num2short(ship.eonium*(1+bonus)*num))
     
     reply+=" It will add %s value"%(self.num2short(ship.total_cost*num/100),)
     message.reply(reply)
开发者ID:munin,项目名称:merlin,代码行数:28,代码来源:cost.py

示例2: caprate

 def caprate(self, attacker=None):
     maxcap = PA.getfloat("roids", "maxcap")
     mincap = PA.getfloat("roids", "mincap")
     if not attacker or not self.value:
         return maxcap
     modifier = (float(self.value) / float(attacker.value)) ** 0.5
     return max(mincap, min(maxcap * modifier, maxcap))
开发者ID:munin,项目名称:merlin,代码行数:7,代码来源:maps.py

示例3: execute

    def execute(self, message, user, params):

        roids, cost, bonus = params.groups()
        roids, cost, bonus = int(roids), self.short2num(cost), int(bonus or 0)
        mining = PA.getint("roids", "mining")

        if roids == 0:
            message.reply("Another NewDawn landing, eh?")
            return

        mining = mining * ((float(bonus) + 100) / 100)

        ticks = (cost * PA.getint("numbers", "ship_value")) / (roids * mining)
        reply = "Capping %s roids at %s value with %s%% bonus will repay in %s ticks (%s days)" % (
            roids,
            self.num2short(cost),
            bonus,
            int(ticks),
            int(ticks / 24),
        )

        for gov in PA.options("govs"):
            bonus = PA.getfloat(gov, "prodcost")
            if bonus == 0:
                continue
            ticks_b = ticks * (1 + bonus)
            reply += " %s: %s ticks (%s days)" % (PA.get(gov, "name"), int(ticks_b), int(ticks_b / 24))

        message.reply(reply)
开发者ID:JDD,项目名称:DLR,代码行数:29,代码来源:roidcost.py

示例4: planet

 def planet(self, message, user, params):
     planet = Planet.load(*params.group(1,3,5))
     if planet is None:
         message.reply("No planet with coords %s:%s:%s found" % params.group(1,3,5))
         return
     
     # List of last 10 scans
     if params.group(6) == "o":
         scans = planet.scans.filter_by(scantype=self.type).order_by(desc(Scan.id))[:10]
         if len(scans) < 1:
             message.reply("No %s Scans of %s:%s:%s found"%(PA.get(self.type,"name"),planet.x,planet.y,planet.z))
             return
         prev = []
         for scan in scans:
             prev.append("(pt%s %s)" % (scan.tick, scan.pa_id,))
         reply = "Last 10 %s Scans on %s:%s:%s "%(PA.get(self.type,"name"),planet.x,planet.y,planet.z) + " ".join(prev)
         message.reply(reply)
         return
     
     # Latest scan
     scan = planet.scan(self.type)
     if scan is None:
         message.reply("No %s Scans of %s:%s:%s found"%(PA.get(self.type,"name"),planet.x,planet.y,planet.z))
         return
     
     # Link to scan
     if params.group(7) == "l":
         reply = "%s on %s:%s:%s " % (scan.type,planet.x,planet.y,planet.z,)
         reply+= self.url(scan.link, user)
         message.reply(reply)
         return
     
     # Display the scan
     message.reply(self.url(str(scan), user))
开发者ID:JDD,项目名称:merlin,代码行数:34,代码来源:scan.py

示例5: execute

 def execute(self, request, user, x, y, z, h=False, hs=False, ticks=None):
     planet = Planet.load(x,y,z)
     if planet is None:
         return HttpResponseRedirect(reverse("planet_ranks"))
     
     ticks = int(ticks or 0) if (h or hs) else 12
     
     if not hs:
         sizediffvalue = PlanetHistory.rdiff * PA.getint("numbers", "roid_value")
         valuediffwsizevalue = PlanetHistory.vdiff - sizediffvalue
         resvalue = valuediffwsizevalue * PA.getint("numbers", "res_value")
         shipvalue = valuediffwsizevalue * PA.getint("numbers", "ship_value")
         xpvalue = PlanetHistory.xdiff * PA.getint("numbers", "xp_value")
         Q = session.query(PlanetHistory,
                             sizediffvalue,
                             valuediffwsizevalue,
                             resvalue, shipvalue,
                             xpvalue,
                             )
         Q = Q.filter(PlanetHistory.current == planet)
         Q = Q.order_by(desc(PlanetHistory.tick))
         history = Q[:ticks] if ticks else Q.all()
     else:
         history = None
     
     if not (h or hs):
         landings = session.query(PlanetLandings.hour, count()).filter(PlanetLandings.planet==planet).group_by(PlanetLandings.hour).all()
         landed = session.query(PlanetLandedOn.hour, count()).filter(PlanetLandedOn.planet==planet).group_by(PlanetLandedOn.hour).all()
         vdrops = session.query(PlanetValueDrops.hour, count()).filter(PlanetValueDrops.planet==planet).group_by(PlanetValueDrops.hour).all()
         idles = session.query(PlanetIdles.hour, count()).filter(PlanetIdles.planet==planet).group_by(PlanetIdles.hour).all()
         hourstats = {
                         'landings' : dict(landings), 'landingsT' : sum([c for hour,c in landings]),
                         'landed'   : dict(landed),   'landedT'   : sum([c for hour,c in landed]),
                         'vdrops'   : dict(vdrops),   'vdropsT'   : sum([c for hour,c in vdrops]),
                         'idles'    : dict(idles),    'idlesT'    : sum([c for hour,c in idles]),
                         }
     else:
         hourstats = None
     
     if not h:
         Q = session.query(PlanetHistory)
         Q = Q.filter(or_(PlanetHistory.hour == 23, PlanetHistory.tick == Updates.current_tick()))
         Q = Q.filter(PlanetHistory.current == planet)
         Q = Q.order_by(desc(PlanetHistory.tick))
         hsummary = Q.all() if hs else Q[:14]
     else:
         hsummary = None
     
     return render(["planet.tpl",["hplanet.tpl","hsplanet.tpl"][hs]][h or hs],
                     request,
                     planet = planet,
                     history = history,
                     hour = datetime.utcnow().hour, hourstats = hourstats,
                     hsummary = hsummary,
                     ticks = ticks,
                   )
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:56,代码来源:planet.py

示例6: execute

 def execute(self, request, user, x, y, h=False, hs=False, ticks=None):
     galaxy = Galaxy.load(x,y)
     if galaxy is None:
         return HttpResponseRedirect(reverse("galaxy_ranks"))
     
     ticks = int(ticks or 0) if (h or hs) else 12
     
     if not (h or hs):
         Q = session.query(Planet, Intel.nick, Alliance.name)
         Q = Q.outerjoin(Planet.intel)
         Q = Q.outerjoin(Intel.alliance)
         Q = Q.filter(Planet.active == True)
         Q = Q.filter(Planet.galaxy == galaxy)
         Q = Q.order_by(asc(Planet.z))
         planets = Q.all()
         exiles = galaxy.exiles[:10]
     else:
         planets, exiles = None, None
     
     if not hs:
         sizediffvalue = GalaxyHistory.rdiff * PA.getint("numbers", "roid_value")
         valuediffwsizevalue = GalaxyHistory.vdiff - sizediffvalue
         resvalue = valuediffwsizevalue * PA.getint("numbers", "res_value")
         shipvalue = valuediffwsizevalue * PA.getint("numbers", "ship_value")
         xpvalue = GalaxyHistory.xdiff * PA.getint("numbers", "xp_value")
         Q = session.query(GalaxyHistory,
                             sizediffvalue,
                             valuediffwsizevalue,
                             resvalue, shipvalue,
                             xpvalue,
                             )
         Q = Q.filter(GalaxyHistory.current == galaxy)
         Q = Q.order_by(desc(GalaxyHistory.tick))
         history = Q[:ticks] if ticks else Q.all()
     else:
         history = None
     
     if not h:
         Q = session.query(GalaxyHistory)
         Q = Q.filter(or_(GalaxyHistory.hour == 23, GalaxyHistory.tick == Updates.current_tick()))
         Q = Q.filter(GalaxyHistory.current == galaxy)
         Q = Q.order_by(desc(GalaxyHistory.tick))
         hsummary = Q.all() if hs else Q[:14]
     else:
         hsummary = None
     
     return render(["galaxy.tpl",["hgalaxy.tpl","hsgalaxy.tpl"][hs]][h or hs],
                     request,
                     galaxy = galaxy,
                     planets = planets,
                     exiles = exiles,
                     history = history,
                     hsummary = hsummary,
                     ticks = ticks,
                   )
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:55,代码来源:galaxy.py

示例7: execute

 def execute(self, message, user, params):
     
     p = Planet.load(*params.group(1,3,5))
     if p is None:
         message.reply("No planet with coords %s:%s:%s found" % params.group(1,3,5))
         return
     ship = Ship.load(name=params.group(6))
     if ship is None:
         message.alert("No Ship called: %s" % (params.group(6),))
         return
     
     scan = p.scan("P")
     if scan is None:
         message.reply("No planet scans available on %s:%s:%s" % (p.x,p.y,p.z,))
         return
     
     planetscan = scan.planetscan
     tick=scan.tick
     res_m=planetscan.res_metal
     res_c=planetscan.res_crystal
     res_e=planetscan.res_eonium
     prod_res=planetscan.prod_res
     rand_id=scan.pa_id
     
     cost_m=ship.metal
     cost_c=ship.crystal
     cost_e=ship.eonium
     total_cost=ship.total_cost
     
     class_factory_table = {'Fighter': 'factory_usage_light', 'Corvette': 'factory_usage_light', 'Frigate': 'factory_usage_medium',
                            'Destroyer': 'factory_usage_medium', 'Cruiser': 'factory_usage_heavy', 'Battleship': 'factory_usage_heavy'}
     prod_modifier_table = {'None': 0, 'Low': 33, 'Medium': 66, 'High': 100}
     
     capped_number=min(res_m/cost_m, res_c/cost_c, res_e/cost_e)
     overflow=res_m+res_c+res_e-(capped_number*(cost_m+cost_c+cost_e))
     buildable = capped_number + ((overflow*.95)/total_cost)
     
     demo = 1/(1+PA.getfloat("demo","prodcost"))
     total = 1/(1+PA.getfloat("total","prodcost"))
     reply="Newest planet scan on %s:%s:%s (id: %s, pt: %s)" % (p.x,p.y,p.z,rand_id,tick)
     reply+=" can purchase %s: %s | Demo: %s | Total: %s"%(ship.name,int(buildable),int(buildable*demo),int(buildable*total))
     
     if prod_res > 0:
         factory_usage=getattr(planetscan,class_factory_table[ship.class_])
         max_prod_modifier=prod_modifier_table[factory_usage]
         buildable_from_prod = buildable + max_prod_modifier*(prod_res)/100/total_cost
         reply+=" Counting %d res in prod at %s usage:" % (prod_res,factory_usage)
         reply+=" %s | Demo: %s | Total: %s "%(int(buildable_from_prod), int(buildable_from_prod*demo),int(buildable*total))
     
     message.reply(reply)
开发者ID:Go3Media,项目名称:merlin,代码行数:50,代码来源:afford.py

示例8: robocop

 def robocop(self, message, scantype, pa_id, x, y, z, names):
     nicks = []
     [nicks.extend(nick) for nick in [CUT.list_user_nicks(name) for name in names.split(",")]]
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= Config.get("URL","viewscan") % (pa_id,)
     for nick in nicks:
         message.privmsg(reply, nick)
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= "delivered to: "
     reply+= ", ".join(nicks)
     from Hooks.scans.request import request
     message.privmsg(reply, request().scanchan())
开发者ID:JDD,项目名称:DLR,代码行数:14,代码来源:scans.py

示例9: execute

 def execute(self, message, user, params):
     
     # Planet
     if len(params.groups()) > 1:
         planet = Planet.load(*params.group(1,3,5))
         if planet is None:
             message.reply("No planet with coords %s:%s:%s found" % params.group(1,3,5))
             return
         
         # List of last 10 scans
         if params.group(6) == "o":
             scans = planet.scans.filter_by(scantype=self.type).order_by(desc(Scan.id))[:10]
             if len(scans) < 1:
                 message.reply("No %s Scans of %s:%s:%s found"%(PA.get(self.type,"name"),planet.x,planet.y,planet.z))
                 return
             prev = []
             for scan in scans:
                 prev.append("(pt%s %s)" % (scan.tick, scan.pa_id,))
             reply = "Last 10 %s Scans on %s:%s:%s "%(PA.get(self.type,"name"),planet.x,planet.y,planet.z) + " ".join(prev)
             message.reply(reply)
             return
         
         # Latest scan
         scan = planet.scan(self.type)
         if scan is None:
             message.reply("No %s Scans of %s:%s:%s found"%(PA.get(self.type,"name"),planet.x,planet.y,planet.z))
             return
         
         # Link to scan
         if params.group(7) == "l":
             reply = "%s on %s:%s:%s " % (PA.get(self.type,"name"),planet.x,planet.y,planet.z,)
             reply+= Config.get("URL","viewscan") % (scan.pa_id,)
             message.reply(reply)
             return
         
         # Display the scan
         message.reply(str(scan))
     
     # ID
     else:
         Q = session.query(Scan)
         Q = Q.filter(Scan.pa_id.ilike("%"+params.group(1)+"%"))
         Q = Q.order_by(desc(Scan.id))
         scan = Q.first()
         if scan is None:
             message.reply("No Scans matching ID '%s'"%(params.group(1),))
             return
         # Display the scan
         message.reply(str(scan))
开发者ID:Go3Media,项目名称:merlin,代码行数:49,代码来源:scan.py

示例10: new

    def new(self, message, user, params):
        tick = Updates.current_tick()
        comment = params.group(3) or ""
        when = int(params.group(1))
        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

        attack = Attack(landtick=when, comment=comment)
        session.add(attack)

        for coord in re.findall(loadable.coord, params.group(2)):
            if not coord[4]:
                galaxy = Galaxy.load(coord[0], coord[2])
                if galaxy:
                    attack.addGalaxy(galaxy)

            else:
                planet = Planet.load(coord[0], coord[2], coord[4])
                if planet:
                    attack.addPlanet(planet)

        session.commit()
        message.reply(str(attack))
开发者ID:ellonweb,项目名称:merlin,代码行数:33,代码来源:attack.py

示例11: execute

 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,代码行数:32,代码来源:book.py

示例12: tick

    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,代码行数:30,代码来源:tick.py

示例13: link

 def link(self):
     return Config.get("URL", "reqscan") % (
         PA.get(self.scantype, "type"),
         self.target.x,
         self.target.y,
         self.target.z,
     )
开发者ID:munin,项目名称:merlin,代码行数:7,代码来源:maps.py

示例14: land

 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,代码行数:32,代码来源:editattack.py

示例15: bonus

    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,代码行数:28,代码来源:bonus.py


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