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


Python Formation.in_formation_hero_ids方法代码示例

本文整理汇总了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)])
开发者ID:yaosj,项目名称:sanguo-server,代码行数:37,代码来源:hero.py

示例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
开发者ID:yaosj,项目名称:sanguo-server,代码行数:34,代码来源:msgfactory.py

示例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
开发者ID:hx002,项目名称:sanguo-server,代码行数:12,代码来源:character.py

示例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))
开发者ID:yueyoum,项目名称:sanguo-server,代码行数:43,代码来源:plunder.py

示例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 = []
开发者ID:hx002,项目名称:sanguo-server,代码行数:23,代码来源:plunder.py

示例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
开发者ID:wyrover,项目名称:sanguo-server,代码行数:25,代码来源:friend.py


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