本文整理汇总了Python中core.formation.Formation.in_formation_hero_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Formation.in_formation_hero_ids方法的具体用法?Python Formation.in_formation_hero_ids怎么用?Python Formation.in_formation_hero_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.formation.Formation
的用法示例。
在下文中一共展示了Formation.in_formation_hero_ids方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: break_hero
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def break_hero(char_id, _id):
# 主动将武将转为卡魂
try:
h = char_heros_dict(char_id)[_id]
except KeyError:
raise SanguoException(
errormsg.HERO_NOT_EXSIT,
char_id,
"Hero Break",
"hero {0} not exist".format(_id)
)
formation = Formation(char_id)
if _id in formation.in_formation_hero_ids():
raise SanguoException(
errormsg.HERO_CANNOT_BREAK_IN_FORMATION,
char_id,
"Hero Break",
"hero {0} in formation, cannot break".format(_id)
)
oid = h.oid
quality = HEROS[oid].quality
souls_amount = SAVE_HERO_TO_SOUL_TABLE[quality]
MongoHero.objects.get(id=_id).delete()
hero_del_signal.send(
sender=None,
char_id=char_id,
hero_id=_id,
hero_oid=oid
)
HeroSoul(char_id).add_soul([(oid, souls_amount)])
示例2: create_character_infomation_message
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def create_character_infomation_message(char_id):
from core.character import Char
from core.formation import Formation
from core.hero import char_heros_dict
msg = CharacterInfomation()
char = Char(char_id)
heros = char_heros_dict(char_id)
f = Formation(char_id)
msg.id = char.mc.id
msg.name = char.mc.name
msg.level = char.mc.level
msg.vip = char.mc.vip
msg.power = char.power
msg.leader = f.get_leader_oid()
for hid in f.in_formation_hero_ids():
msg_hero = msg.formation.add()
if hid == 0:
msg_hero.id = 0
msg_hero.oid = 0
msg_hero.step = 0
else:
h = heros[hid]
msg_hero.id = h.id
msg_hero.oid = h.oid
msg_hero.step = h.step
return msg
示例3: power
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def power(self):
f = Formation(self.id)
hero_ids = f.in_formation_hero_ids()
p = 0
for hid in hero_ids:
if hid == 0:
continue
h = Hero.cache_obj(hid)
p += h.power
return p
示例4: __init__
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def __init__(self, char_id, city_id):
from core.affairs import Affairs
from core.battle.hero import BattleHero
self.city_id = city_id
if char_id:
char = Char(char_id)
self.char_id = char_id
self.name = char.mc.name
self.level = char.mc.level
self.power = char.power
self.leader = char.leader_oid
f = Formation(char_id)
self.formation = f.in_formation_hero_ids()
self.hero_original_ids = f.in_formation_hero_original_ids()
self.gold = Affairs(self.char_id).get_drop()['gold']
self.msg_char_information = create_character_infomation_message(self.char_id).SerializeToString()
battle_heros = []
for hid in self.formation:
if hid == 0:
battle_heros.append(None)
else:
battle_heros.append(BattleHero(hid))
self.battle_heros = base64.b64encode(dill.dumps(battle_heros))
else:
self.char_id = 0
self.name = ""
self.level = 0
self.power = 0
self.leader = 0
self.formation = []
self.hero_original_ids = []
self.gold = 0
self.msg_char_information = ""
self.battle_heros = base64.b64encode(dill.dumps([None] * 9))
示例5: __init__
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def __init__(self, char_id, city_id):
self.city_id = city_id
if char_id:
char = Char(char_id)
self.char_id = char_id
self.name = char.mc.name
self.level = char.mc.level
self.power = char.power
self.leader = char.leader_oid
f = Formation(char_id)
self.formation = f.in_formation_hero_ids()
self.hero_original_ids = f.in_formation_hero_original_ids()
else:
self.char_id = 0
self.name = ""
self.level = 0
self.power = 0
self.leader = 0
self.formation = []
self.hero_original_ids = []
示例6: _msg_friend
# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_ids [as 别名]
def _msg_friend(self, msg, fid, status):
char_f = Char(fid)
cache_f = char_f.cacheobj
msg.id = fid
msg.name = cache_f.name
msg.level = cache_f.level
msg.official = cache_f.official
if status == FRIEND_OK or status == FRIEND_NOT:
msg.power = char_f.power
msg.status = status
f = Formation(fid)
in_formation_hero_ids = [h for h in f.in_formation_hero_ids() if h]
hero_list = [(Hero.cache_obj(hid).power, hid) for hid in in_formation_hero_ids]
hero_list.sort(key=lambda item: -item[0])
leader_oid = Hero.cache_obj(hero_list[0][1]).oid
if status == FRIEND_OK:
f = Formation(fid)
msg.formation.extend(f.in_formation_hero_original_ids())
msg.leader = leader_oid