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


Python PA.options方法代码示例

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


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

示例1: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [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: execute

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

示例3: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
 def execute(self, request, user, page="1", sort="score", race="all"):
     page = int(page)
     offset = (page - 1)*50
     order =  {"score" : (asc(Planet.score_rank),),
               "value" : (asc(Planet.value_rank),),
               "size"  : (asc(Planet.size_rank),),
               "xp"    : (asc(Planet.xp_rank),),
               "race"  : (asc(Planet.race), asc(Planet.size_rank),),
               }
     if sort not in order.keys():
         sort = "score"
     order = order.get(sort)
     
     tick = Updates.midnight_tick()
     
     Q = session.query(Planet, PlanetHistory, Intel.nick, Alliance.name)
     Q = Q.outerjoin(Planet.intel)
     Q = Q.outerjoin(Intel.alliance)
     Q = Q.outerjoin((PlanetHistory, and_(Planet.id == PlanetHistory.id, PlanetHistory.tick == tick)))
     Q = Q.filter(Planet.active == True)
     
     if race.lower() in PA.options("races"):
         Q = Q.filter(Planet.race.ilike(race))
     else:
         race = "all"
     
     count = Q.count()
     pages = count/50 + int(count%50 > 0)
     pages = range(1, 1+pages)
     
     for o in order:
         Q = Q.order_by(o)
     Q = Q.limit(50).offset(offset)
     return render("planets.tpl", request, planets=Q.all(), offset=offset, pages=pages, page=page, sort=sort, race=race)
开发者ID:munin,项目名称:merlin,代码行数:36,代码来源:planets.py

示例4: execute

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

示例5: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
 def execute(self, request, user, name, page="1", sort="score", race="all"):
     page = int(page)
     offset = (page - 1)*50
     order =  {"score" : (asc(Planet.score_rank),),
               "value" : (asc(Planet.value_rank),),
               "size"  : (asc(Planet.size_rank),),
               "xp"    : (asc(Planet.xp_rank),),
               "ratio" : (desc(Planet.ratio),),
               "race"  : (asc(Planet.race), asc(Planet.size_rank),),
               "xyz"   : (asc(Planet.x), asc(Planet.y), asc(Planet.z),),
               "score_growth" : (desc(Planet.score_growth),),
               "value_growth" : (desc(Planet.value_growth),),
               "size_growth"  : (desc(Planet.size_growth),),
               "xp_growth"    : (desc(Planet.xp_growth),),
               "score_growth_pc" : (desc(Planet.score_growth_pc),),
               "value_growth_pc" : (desc(Planet.value_growth_pc),),
               "size_growth_pc"  : (desc(Planet.size_growth_pc),),
               "xp_growth_pc"    : (desc(Planet.xp_growth_pc),),
               }
     if sort not in order.keys():
         sort = "score"
     order = order.get(sort)
     
     alliance = Alliance.load(name)
     if alliance is None:
         return HttpResponseRedirect(reverse("alliance_ranks"))
     
     Q = session.query(Planet, Intel.nick, Alliance.name)
     Q = Q.join(Planet.intel)
     Q = Q.join(Intel.alliance)
     Q = Q.filter(Planet.active == True)
     Q = Q.filter(Intel.alliance == alliance)
     
     if race.lower() in PA.options("races"):
         Q = Q.filter(Planet.race.ilike(race))
     else:
         race = "all"
     
     count = Q.count()
     pages = count/50 + int(count%50 > 0)
     pages = range(1, 1+pages)
     
     for o in order:
         Q = Q.order_by(o)
     Q = Q.limit(50).offset(offset)
     return render("palliance.tpl", request, alliance=alliance, planets=Q.all(), offset=offset, pages=pages, page=page, sort=sort, race=race)
开发者ID:JDD,项目名称:DLR,代码行数:48,代码来源:palliance.py

示例6: execute

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

示例7: execute

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]

#.........这里部分代码省略.........
     
     wordfilts = {
                 "ruler" : Planet.rulername,
                 "planet" : Planet.planetname,
                 "galaxy" : Galaxy.name,
                 }
     
     if request.POST.get("search"):
         r = request.POST
         search = "/search/"
         
         for word in wordfilts.keys() + ["nick", "alliance"]:
             filt = (r.get(word) or "").strip()
             if not filt:
                 continue
             search += "%s:%s/" %(word,filt,)
         
         for filt in filters.keys():
             one = (r.get("min"+filt) or "").strip()
             two = (r.get("max"+filt) or "").strip()
             if not one and not two:
                 continue
             
             if one and one == two:
                 search += "%s:%s/" %(filt,one,)
             elif one and not two:
                 search += "%s:%s|/" %(filt,one,)
             elif two and not one:
                 search += "%s:|%s/" %(filt,two,)
             elif one and two:
                 search += "%s:%s|%s/" %(filt,one,two,)
         
         races = []
         for race in PA.options("races"):
             if (r.get(race) or "").strip():
                 races.append(race)
         if len(races) != len(PA.options("races")):
             search += "race:%s/" %("|".join(races),)
         
         if (r.get("bash") or "").strip():
             search += "bash/"
         
         o1 = (r.get("order1") or "").strip()
         o1o = (r.get("order1o") or "").strip()
         o2 = (r.get("order2") or "").strip()
         o2o = (r.get("order2o") or "").strip()
         if o1 not in order:
             o1, o1o = o2, o2o
         if o1 in order and (o1 == o2 or o2 not in order):
             if o1 == "score" and o1o == "desc":
                 pass
             else:
                 o1o = "^" if o1o == "asc" else "_"
                 search += "order:%s%s/" %(o1o,o1,)
         elif o1 in order and o2 in order:
             o1o = "^" if o1o == "asc" else "_"
             o2o = "^" if o2o == "asc" else "_"
             search += "order:%s%s|%s%s/" %(o1o,o1,o2o,o2,)
         
         return HttpResponseRedirect(search)
     
     for param in params.lower().split("/"):
         if param == "bash" and user.planet is not None:
             Q = Q.filter(or_(Planet.value.op(">")(user.planet.value*PA.getfloat("bash","value")),
                              Planet.score.op(">")(user.planet.score*PA.getfloat("bash","score"))))
             Q = Q.filter(Planet.x < 200)
开发者ID:d7415,项目名称:merlin,代码行数:70,代码来源:search.py

示例8:

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
 
import re
import sys
import urllib2
from sqlalchemy.sql import text
from Core.config import Config
from Core.paconf import PA
from Core.db import true, false, session
from Core.maps import Ship

useragent = "Merlin (Python-urllib/%s); Alliance/%s; BotNick/%s; Admin/%s" % (urllib2.__version__, Config.get("Alliance", "name"), 
                                                                              Config.get("Connection", "nick"), Config.items("Admins")[0][0])

regex = r'^<tr class="('
races = []
for race in PA.options("races"):
    races.append(PA.get(race, "name"))
regex += "|".join(races)
regex += ')">.+?>([^<]+)</td>' # race & name
regex += r'<td>(\w+)</td>' # class
regex += r'(?:<td>(\w\w|\-)</td>)?'*3 # t1,t2,t3
regex += r'<td>(\w+)</td>' # type
regex += r'.+?(\d+|\-)</td>'*8 # some numbers
regex += r'.+?</tr>$' # end of the line
sre = re.compile(regex,re.I|re.M)

mapping = { "Fi": "Fighter",
            "Co": "Corvette",
            "Fr": "Frigate",
            "De": "Destroyer",
            "Cr": "Cruiser",
开发者ID:TBBTNut,项目名称:merlin,代码行数:33,代码来源:shipstats.py

示例9: patterns

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
from django.conf.urls.defaults import include, patterns, url
from Core.paconf import PA
from Arthur.scans import list
from Arthur.scans import request

urlpatterns = patterns('Arthur.scans',
    url(r'^$', 'list.scans', name="scans"),
    url(r'^(?P<x>\d+)[. :\-](?P<y>\d+)[. :\-](?P<z>\d+)/',
        include(patterns('Arthur.scans.planet',
            url(r'^$', 'planet', name="planet_scans"),
            url(r'^(?P<types>['+"".join([type.lower() for type in PA.options("scans")])+']+)/$', "types"),
            *[url(r'^'+type.lower()+'\w*/$', "scan", {"type":type}, name="planet_scan_"+type.lower()) for type in PA.options("scans")]
        ))),
    url(r'^(?P<x>\d+)[. :\-](?P<y>\d+)/',
        include(patterns('Arthur.scans.galaxy',
            url(r'^$', 'galaxy', name="galaxy_scans"),
            url(r'^(?P<types>['+"".join([type.lower() for type in PA.options("scans")])+']+)/$', "types")
        ))),
    url('^(?P<tick>\d+)/$', 'list.tick', name="scan_tick"),
    url('^(?P<tick>\d+)/(?P<id>\w+)/$', 'planet.id', name="scan_id"),
    url('^group/(?P<id>\w+)/$', 'list.group', name="scan_group_id"),
    url('^requests/$', 'request.requests', name="requests"),
)
开发者ID:munin,项目名称:merlin,代码行数:32,代码来源:__init__.py

示例10: patterns

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
from django.conf.urls.defaults import include, patterns, url
from sqlalchemy.sql import asc
from Core.paconf import PA
from Core.db import session
from Core.maps import Updates, Planet, Request
from Core.robocop import push
from Arthur.context import menu, render
from Arthur.loadable import loadable, load

urlpatterns = patterns('Arthur.scans.request',
    url(r'^(?P<x>\d+)[. :\-](?P<y>\d+)[. :\-](?P<z>\d+)/(?P<type>['+"".join([type.lower() for type in PA.options("scans")])+'])/(?:(?P<dists>\d+)/)?$', 'request', name="request_planet"),
    url(r'^cancel/(?P<id>\d+)/$', 'cancel', name="request_cancel"),
    url(r'^(?P<id>\d+)/blocks/(?P<dists>\d+)/$', 'blocks', name="request_blocks"),
)

@load
class request(loadable):
    access = "half"
    def execute(self, request, user, x, y, z, type, dists):
        from Arthur.scans.list import scans
        tick = Updates.current_tick()
        type = type.upper()
        
        planet = Planet.load(x,y,z)
        if planet is None:
            return scans.execute(request, user, message="No planet with coords %s:%s:%s" %(x,y,z,))
开发者ID:munin,项目名称:merlin,代码行数:33,代码来源:request.py

示例11: execute

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

示例12: url

# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import options [as 别名]
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
from django.conf.urls import include, url
from Core.paconf import PA
from Arthur.views.scans import list as slist, request, planet, galaxy

urlpatterns = [
  url(r'^scans?/', include( [
    url(r'^$', slist.scans, name="scans"),
    url(r'^(?P<x>\d+)[. :\-](?P<y>\d+)[. :\-](?P<z>\d+)/',
        include(
            [url(r'^$', planet.planet, name="planet_scans"),
            url(r'^(?P<types>['+"".join([type.lower() for type in PA.options("scans")])+']+)/$', planet.types),
            ] + [url(r'^'+type.lower()+'\w*/$', planet.scan, {"type":type}, name="planet_scan_"+type.lower()) for type in PA.options("scans")]
        )),
    url(r'^(?P<x>\d+)[. :\-](?P<y>\d+)/',
        include( [
            url(r'^$', galaxy.galaxy, name="galaxy_scans"),
            url(r'^(?P<types>['+"".join([type.lower() for type in PA.options("scans")])+']+)/$', galaxy.types)
        ])),
    url('^(?P<tick>\d+)/$', slist.tick, name="scan_tick"),
    url('^(?P<tick>\d+)/(?P<id>\w+)/$', planet.id, name="scan_id"),
    url('^group/(?P<id>\w+)/$', slist.group, name="scan_group_id"),
  ])),
  url('^(?:scans?/)?requests?/$', request.requests, name="requests"),
  url(r'^(?:scans?/)?requests?/', include(request)),
]
开发者ID:d7415,项目名称:merlin,代码行数:32,代码来源:__init__.py


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