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


Python Formation.in_formation_hero_original_ids方法代码示例

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


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

示例1: __init__

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_original_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

示例2: __init__

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_original_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

示例3: _msg_friend

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_original_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

示例4: get_plunder_list

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_original_ids [as 别名]
    def get_plunder_list(self):
        """
        @return: [[id, name, power, formation, is_robot, gold], ...]
        @rtype: list
        """
        char = Char(self.char_id)
        cache_char = char.cacheobj
        char_level = cache_char.level

        choosing_list = MongoHangDoing.objects(Q(char_level__gte=char_level-PLUNDER_LEVEL_DIFF) & Q(char_level__lte=char_level+PLUNDER_LEVEL_DIFF) & Q(id__ne=self.char_id))
        choosing_id_list = [c.id for c in choosing_list]
        ids = []
        while True:
            if len(ids) >= 20 or not choosing_id_list:
                break

            c = random.choice(choosing_id_list)
            choosing_id_list.remove(c)
            if c == self.char_id:
                continue

            if c not in ids:
                ids.append(c)

        random.shuffle(ids)
        ids = ids[:10]

        res = []
        for i in ids:
            char = Char(i)
            f = Formation(i)
            res.append([i, char.cacheobj.name, char.power, f.in_formation_hero_original_ids(), False])

        robot_ids = []
        robot_amount = 10 - len(ids)

        if len(robot_ids) < robot_amount:
            # 添加机器人
            min_level = char_level - 20
            if min_level <= 1:
                min_level = 1
            real_chars = get_char_ids_by_level_range(cache_char.server_id, min_level, char_level + 10)

            for c in real_chars:
                if c == self.char_id:
                    continue

                if c in ids:
                    continue

                robot_ids.append(c)
                if len(robot_ids) >= robot_amount:
                    break

        for i in robot_ids:
            char = Char(i)
            f = Formation(i)
            res.append([i, char.cacheobj.name, char.power, f.in_formation_hero_original_ids(), True])

        final_ids = [r[0] for r in res]
        this_stages = MongoStage.objects.filter(id__in=final_ids)
        this_stages_dict = {s.id: s.max_star_stage for s in this_stages}
        for r in res:
            _id = r[0]
            max_star_stage = this_stages_dict.get(_id, 1)
            if not max_star_stage:
                max_star_stage = 1

            got_gold = max_star_stage * 400 * random.uniform(1.0, 1.2)
            got_gold = int(got_gold)
            r.append(got_gold)

        for _id, _, _, _, is_robot, gold in res:
            c = MongoEmbededPlunderChars()
            c.is_robot = is_robot
            c.gold = gold
            self.mongo_plunder.chars[str(_id)] = c
        self.mongo_plunder.save()
        return res
开发者ID:wyrover,项目名称:sanguo-server,代码行数:81,代码来源:plunder.py

示例5: get_reward

# 需要导入模块: from core.formation import Formation [as 别名]
# 或者: from core.formation.Formation import in_formation_hero_original_ids [as 别名]
    def get_reward(self, tp):
        if not self.mongo_plunder.target_char:
            raise SanguoException(
                errormsg.PLUNDER_GET_REWARD_NO_TARGET,
                self.char_id,
                "Plunder Get Reward",
                "no Target char"
            )

        if tp in self.mongo_plunder.got_reward:
            raise SanguoException(
                errormsg.PLUNDER_GET_REWARD_ALREADY_GOT,
                self.char_id,
                "Plunder Get Reward",
                "tp {0} already got".format(tp)
            )

        need_points = PLUNDER_REWARD_NEEDS_POINT[tp]
        if self.mongo_plunder.points < need_points:
            raise SanguoException(
                errormsg.PLUNDER_GET_REWARD_POINTS_NOT_ENOUGH,
                self.char_id,
                "Plunder Get Reward",
                "points not enough. {0} < {1}".format(self.mongo_plunder.points, need_points)
            )

        self.mongo_plunder.points -= need_points
        self.mongo_plunder.got_reward.append(tp)
        self.mongo_plunder.save()

        standard_drop = make_standard_drop_from_template()
        plunder_gold = self.mongo_plunder.chars[str(self.mongo_plunder.target_char)].gold

        char = Char(self.char_id).mc
        vip_plus = VIP_FUNCTION[char.vip].plunder_addition

        got_hero_id = 0
        if tp == PLUNDER_HERO:
            f = Formation(self.mongo_plunder.target_char)
            heros = f.in_formation_hero_original_ids()
            got_hero_id = random.choice([hid for hid in heros if hid])
            p = Prison(self.char_id)
            p.prisoner_add(got_hero_id, plunder_gold/2)

        elif tp == PLUNDER_STUFF:
            stage = Stage(self.mongo_plunder.target_char)
            max_star_stage = stage.stage.max_star_stage
            if not max_star_stage:
                max_star_stage = 1

            drop_ids = [int(i) for i in STAGES[max_star_stage].normal_drop.split(',')]
            drop = get_drop(drop_ids, multi=int(PLUNDER_GOT_ITEMS_HOUR * 3600 * (1+vip_plus/100.0) / 15))
            standard_drop.update(drop)

        elif tp == PLUNDER_GOLD:
            standard_drop['gold'] = int(plunder_gold * (1+vip_plus/100.0))

        resource = Resource(self.char_id, "Plunder Reward")
        resource.add(**standard_drop)

        self.send_notify()
        if got_hero_id:
            standard_drop['heros'] = [got_hero_id]
        return standard_drop_to_attachment_protomsg(standard_drop)
开发者ID:wyrover,项目名称:sanguo-server,代码行数:66,代码来源:plunder.py


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