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


Python PA.get方法代码示例

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


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

示例1: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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.0, 'Low': 0.33, 'Medium': 0.66, 'High': 1.0}
     
     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)
     
     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"%(ship.name,int(buildable))
     
     for gov in PA.options("govs"):
         bonus = PA.getfloat(gov, "prodcost")
         if bonus == 0:
             continue
         reply+=" | %s: %s"%(PA.get(gov, "name"),int(buildable/(1+bonus)))
     
     factory_usage=getattr(planetscan,class_factory_table[ship.class_])
     if prod_res > 0 and factory_usage != "None":
         max_prod_modifier=prod_modifier_table[factory_usage]
         buildable_from_prod = buildable + max_prod_modifier*prod_res/total_cost
         reply+=" Counting %s res in prod at %s usage:" % (self.num2short(prod_res),factory_usage)
         reply+=" %s"%(int(buildable_from_prod))
         
         for gov in PA.options("govs"):
             bonus = PA.getfloat(gov, "prodcost")
             if bonus == 0:
                 continue
             reply+=" | %s: %s"%(PA.get(gov, "name"),int(buildable_from_prod/(1+bonus)))
     
     message.reply(reply)
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:62,代码来源:afford.py

示例2: planet

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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,代码行数:36,代码来源:scan.py

示例3: robocop

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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,代码行数:16,代码来源:scans.py

示例4: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
    def execute(self, message, user, params):
        
        name, ticks, factories = params.group(1,2,3)

        ship = Ship.load(name=name)
        if ship is None:
            message.alert("%s is not a ship." % name)
            return
        ticks = int(ticks)
        factories = int(factories)

        race = ship.race[:3].lower()
        race = "etd" if race == "eit" else race

        gov = None
        pop = 0
        for p in (params.group(4) or "").split():
            m=self.govre.match(p)
            if m and not gov:
                gov=m.group(1).lower()
                continue
            if p.isdigit() and not pop:
                pop = int(p)
                continue

        m = ship.metal
        c = ship.crystal
        e = ship.eonium
        bonus = 1 + pop/100.0
        if gov:
            m *= (1+PA.getfloat(gov,"prodcost"))
            c *= (1+PA.getfloat(gov,"prodcost"))
            e *= (1+PA.getfloat(gov,"prodcost"))
            bonus += PA.getfloat(gov,"prodtime")
        if race:
            bonus += PA.getfloat(race,"prodtime")
        cost = floor(m)+floor(c)+floor(e)

        res = int(self.revprod(ticks, factories, bonus))
        ships = int(res / cost)

        reply = "You can build %s %s (%s) in %d ticks" % (self.num2short(ships), ship.name, self.num2short(ships*ship.total_cost//PA.getint("numbers", "ship_value")), ticks)
        reply += " using %s factories" % (factories,) if factories > 1 else ""
        reply += " with a" if race or gov else ""
        reply += " %s"%(PA.get(gov,"name"),) if gov else ""
        reply += " %s"%(PA.get(race,"name"),) if race else ""
        reply += " planet" if race or gov else ""
        reply += " with %s%% population"%(pop,) if pop else ""
        message.reply(reply)
开发者ID:JDD,项目名称:merlin,代码行数:51,代码来源:rprod.py

示例5: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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,代码行数:51,代码来源:scan.py

示例6: robocop

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 def robocop(self, message, scantype, pa_id, x, y, z, names):
     nicks = []
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= Config.get("URL","viewscan") % (pa_id,)
     
     for name in names.split(","):
         user = User.load(name)
         for nick in CUT.get_user_nicks(name):
             nicks.append(nick)
             message.privmsg(self.url(reply, user), nick)
     
     reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     reply+= "delivered to: "
     reply+= ", ".join(nicks) if not Config.getboolean("Misc", "anonscans") else "Anon"
     from Hooks.scans.request import request
     message.privmsg(reply, request().scanchan())
开发者ID:Hardware-Hacks,项目名称:merlin,代码行数:18,代码来源:scans.py

示例7: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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,代码行数:30,代码来源:cost.py

示例8: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
    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,代码行数:31,代码来源:roidcost.py

示例9: link

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 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,代码行数:9,代码来源:maps.py

示例10: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
    def execute(self, message, user, params):
        
        num, name, factories = params.group(1,2,3)

        ship = Ship.load(name=name)
        if ship is None:
            message.alert("%s is not a ship." % name)
            return
        num = self.short2num(num)
        factories = int(factories)

        race = gov = None
        pop = 0
        for p in (params.group(4) or "").split():
            m=self.racere.match(p)
            if m and not race:
                race=m.group(1).lower()
                continue
            m=self.govre.match(p)
            if m and not gov:
                gov=m.group(1).lower()
                continue
            if p.isdigit() and not pop:
                pop = int(p)
                continue

        cost = ship.total_cost
        bonus = 1 + pop/100.0
        if gov:
            cost *= (1+PA.getfloat(gov,"prodcost"))
            bonus += PA.getfloat(gov,"prodtime")
        if race:
            bonus += PA.getfloat(race,"prodtime")

        ticks = self.calc_ticks(cost, num, bonus, factories)

        reply = "It will take %s ticks to build %s %s (%s)" % (ticks, self.num2short(num), ship.name, self.num2short(num*ship.total_cost/100))
        reply += " using %s factories" % (factories,) if factories > 1 else ""
        reply += " with a" if race or gov else ""
        reply += " %s"%(PA.get(gov,"name"),) if gov else ""
        reply += " %s"%(PA.get(race,"name"),) if race else ""
        reply += " planet" if race or gov else ""
        reply += " with %s%% population"%(pop,) if pop else ""
        message.reply(reply)
开发者ID:munin,项目名称:merlin,代码行数:46,代码来源:prod.py

示例11: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
    def execute(self, message, user, params):
        
        name, ticks, factories = params.group(1,2,3)

        ship = Ship.load(name=name)
        if ship is None:
            message.alert("%s is not a ship." % name)
            return
        ticks = int(ticks)
        factories = int(factories)

        race = gov = None
        pop = 0
        for p in (params.group(4) or "").split():
            m=self.racere.match(p)
            if m and not race:
                race=m.group(1).lower()
                continue
            m=self.govre.match(p)
            if m and not gov:
                gov=m.group(1).lower()
                continue
            if p.isdigit() and not pop:
                pop = int(p)
                continue

        cost = ship.total_cost
        bonus = 1 + pop/100.0
        if gov:
            cost *= (1+PA.getfloat(gov,"prodcost"))
            bonus += PA.getfloat(gov,"prodtime")
        if race:
            bonus += PA.getfloat(race,"prodtime")

        res = int(self.revprod(ticks, factories, bonus))
        ships = int(res / cost)

        reply = "You can build %s %s (%s) in %d ticks" % (self.num2short(ships), ship.name, self.num2short(ships*ship.total_cost/100), ticks)
        reply += " with a" if race or gov else ""
        reply += " %s"%(PA.get(gov,"name"),) if gov else ""
        reply += " %s"%(PA.get(race,"name"),) if race else ""
        reply += " planet" if race or gov else ""
        reply += " with %s%% population"%(pop,) if pop else ""
        message.reply(reply)
开发者ID:Go3Media,项目名称:merlin,代码行数:46,代码来源:rprod.py

示例12: robocop

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 def robocop(self, message, scantype, pa_id, x, y, z, names, scanner, reqs, old=False):
     nicks = []
     reply = "Old " if old else ""
     reply += "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,)
     if ("showscanner" in Config.options("Misc") and Config.getboolean("Misc", "showscanner") and scanner != 'None'):
         reply+= "from %s " % (User.load(id=scanner).name) if User.load(id=scanner) not in (None, 'None') else ""
     reply += Config.get("URL","viewscan") % (pa_id,)
     if old:
         reply += " !request cancel %s if this is suitable." % (reqs)
     
     for name in names.split(","):
         user = User.load(name)
         for nick in CUT.get_user_nicks(name):
             nicks.append(nick)
             message.privmsg(self.url(reply, user), nick)
     
     if not old:
         reply = "[-%s] %s on %s:%s:%s " % (reqs,PA.get(scantype,"name"),x,y,z,)
         reply+= "delivered to: "
         reply+= ", ".join(nicks) if not Config.getboolean("Misc", "anonscans") else "Anon"
         if Config.getboolean("Misc", "showurls"):
             reply += " (%s)" % (Config.get("URL","viewscan") % (pa_id,))
         from Hooks.scans.request import request
         message.privmsg(reply, request().scanchan())
开发者ID:JDD,项目名称:merlin,代码行数:26,代码来源:scans.py

示例13: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
    def execute(self, message, user, params):
        
        roids=int(params.group(1))
        ticks=int(params.group(2))
        bonus=int(params.group(3) or 0)
        mining = PA.getint("roids","mining")

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

        value = ticks*roids*mining/100
        reply = "In %s ticks (%s days) %s roids with %s%% bonus will mine %s value" % (ticks,ticks/24,roids,bonus,self.num2short(value))
        
        for gov in PA.options("govs"):
            bonus = PA.getfloat(gov, "prodcost")
            if bonus == 0:
                continue
            value_b = value/(1+bonus)
            reply += " %s: %s value" % (PA.get(gov, "name"), self.num2short(value_b))
        
        message.reply(reply)
开发者ID:munin,项目名称:merlin,代码行数:22,代码来源:roidsave.py

示例14: __str__

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 def __str__(self):
     p = self.planet
     ph = p.history(self.tick)
     
     head = "%s on %s:%s:%s " % (PA.get(self.scantype,"name"),p.x,p.y,p.z,)
     if self.scantype in ("P","D","J","N",):
         id_tick = "(id: %s, pt: %s)" % (self.pa_id,self.tick,)
     if self.scantype in ("U","A",):
         vdiff = p.value-ph.value if ph else None
         id_age_value = "(id: %s, age: %s, value diff: %s)" % (self.pa_id,Updates.current_tick()-self.tick,vdiff)
     
     if self.scantype in ("P",):
         return head + id_tick + str(self.planetscan)
     if self.scantype in ("D",):
         return head + id_tick + str(self.devscan)
     if self.scantype in ("U","A",):
         return head + id_age_value + " " + " | ".join(map(str,self.units))
     if self.scantype == "J":
         return head + id_tick + " " + " | ".join(map(str,self.fleets))
     if self.scantype == "N":
         return head + Config.get("URL","viewscan") % (self.pa_id,)
开发者ID:Go3Media,项目名称:merlin,代码行数:23,代码来源:maps.py

示例15: type

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import get [as 别名]
 def type(self):
     return PA.get(self.scantype, "name")
开发者ID:munin,项目名称:merlin,代码行数:4,代码来源:maps.py


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