本文整理汇总了Python中Core.paconf.PA.getfloat方法的典型用法代码示例。如果您正苦于以下问题:Python PA.getfloat方法的具体用法?Python PA.getfloat怎么用?Python PA.getfloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.paconf.PA
的用法示例。
在下文中一共展示了PA.getfloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例2: caprate
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [as 别名]
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))
示例3: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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, '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)
示例4: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例5: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例6: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例7: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例8: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例9: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [as 别名]
def execute(self, message, user, params):
num, name, target = params.groups()
target = target or "t1"
ship = Ship.load(name=name)
num = self.short2num(num)
if ship is None:
message.alert("No Ship called: %s" % (name,))
return
efficiency = PA.getfloat("teffs", target.lower())
target_class = getattr(ship, target)
if ship.damage:
total_damage = ship.damage * num
if ship.t1 == "Roids":
killed = total_damage / 50
message.reply(
"%s %s (%s) will capture Asteroid: %s (%s)"
% (num, ship.name, self.num2short(num * ship.total_cost / 100), killed, self.num2short(killed * 200))
)
return
if ship.t1 == "Struct":
killed = total_damage / 500
message.reply(
"%s %s (%s) will destroy Structure: %s (%s)"
% (num, ship.name, self.num2short(num * ship.total_cost / 100), killed, self.num2short(killed * 1500))
)
return
targets = session.query(Ship).filter(Ship.class_ == target_class)
if targets.count() == 0:
message.reply("%s does not have any targets in that category (%s)" % (ship.name, target))
return
reply = "%s %s (%s) hitting %s will " % (
num,
ship.name,
self.num2short(num * ship.total_cost / 100),
target_class,
)
if ship.type.lower() == "norm" or ship.type.lower() == "cloak":
reply += "destroy "
elif ship.type.lower() == "emp":
reply += "hug "
elif ship.type.lower() == "steal":
reply += "steal "
else:
raise Exception("Erroneous type %s" % (ship.type,))
for target in targets:
if ship.type.lower() == "emp":
killed = int(efficiency * ship.guns * num * float(100 - target.empres) / 100)
else:
killed = int(efficiency * total_damage / target.armor)
reply += "%s: %s (%s) " % (target.name, killed, self.num2short(target.total_cost * killed / 100))
message.reply(reply)
示例10: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
cost=self.num2short(ticks*roids*mining/100)
reply="In %s ticks (%s days) %s roids with %s%% bonus will mine %s value" % (ticks,ticks/24,roids,bonus,cost)
cost=self.num2short(ticks*roids*mining/100*(1/(1+PA.getfloat("feud","prodcost"))))
reply+=" Feudalism: %s value" % (cost)
message.reply(reply)
示例11: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
示例12: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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)
repay=int((cost*100)/(roids*mining))
reply="Capping %s roids at %s value with %s%% bonus will repay in %s ticks (%s days)" % (roids,self.num2short(cost),bonus,repay,repay/24)
repay = int((cost*100)/(roids*mining*(1/(1+PA.getfloat("feud","prodcost")))))
reply+=" Feudalism: %s ticks (%s days)" % (repay,repay/24)
message.reply(reply)
示例13: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [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
feud = PA.getfloat("feud","prodcost")
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))
reply+=" Feudalism: %s metal, %s crystal and %s eonium."%(
self.num2short(ship.metal*(1+feud)*num),
self.num2short(ship.crystal*(1+feud)*num),
self.num2short(ship.eonium*(1+feud)*num))
reply+=" It will add %s value"%(self.num2short(ship.total_cost*num/100),)
message.reply(reply)
示例14: bashcap
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [as 别名]
def bashcap(context, target, attr):
present = getattr(target, attr)
if not isinstance(target, Planet) or attr not in ("value", "score", "size"):
return intcomma(present)
attacker = context["user"].planet
if not attacker:
return intcomma(present)
if attr == "size":
ret = '<span title="%s XP/roid * %s roids (%s%%) = %s XP">%s</span>'
return ret % (
round(attacker.bravery(target), 2),
target.maxcap(attacker),
round(target.caprate(attacker), 2),
intcomma(attacker.calc_xp(target)),
intcomma(present),
)
else:
ret = '<span class="%s" title="%s%%">%s</span>'
limit = PA.getfloat("bash", attr)
fraction = 1.0 * present / getattr(attacker, attr)
return ret % ("white" if fraction >= limit else "orange", round(fraction * 100, 2), intcomma(present))
示例15: execute
# 需要导入模块: from Core.paconf import PA [as 别名]
# 或者: from Core.paconf.PA import getfloat [as 别名]
def execute(self, message, user, params):
num, name, attacker = params.groups()
attacker = (attacker or "t1").lower()
num = self.short2num(num)
ship = Ship.load(name=name)
if ship is not None:
pass
elif "asteroids".rfind(name.lower()) > -1:
ship = Ship(name="Asteroids",class_="Roids",armor=50,total_cost=PA.getint("numbers", "roid_value")*100)
elif "constructions".rfind(name.lower()) > -1:
ship = Ship(name="Constructions",class_="Struct",armor=500,total_cost=PA.getint("numbers", "cons_value")*100)
else:
message.alert("No Ship called: %s" % (name,))
return
efficiency = PA.getfloat("teffs",attacker.lower())
attacker_class = getattr(Ship, attacker)
attackers = session.query(Ship).filter(attacker_class == ship.class_)
if attackers.count() == 0:
message.reply("%s are not hit by anything as that category (%s)" % (ship.name,attacker))
return
if ship.class_ == "Roids":
reply="Capturing"
elif ship.class_ == "Struct":
reply="Destroying"
else:
reply="Stopping"
reply+=" %s %s (%s) as %s requires " % (num, ship.name,self.num2short(num*ship.total_cost/100),attacker)
for attacker in attackers:
if attacker.type.lower() == "emp" :
needed=int((math.ceil(num/(float(100-ship.empres)/100)/attacker.guns))/efficiency)
else:
needed=int((math.ceil(float(ship.armor*num)/attacker.damage))/efficiency)
reply+="%s: %s (%s) " % (attacker.name,needed,self.num2short(attacker.total_cost*needed/100))
message.reply(reply)