當前位置: 首頁>>代碼示例>>Python>>正文


Python Formation.in_formation_staffs方法代碼示例

本文整理匯總了Python中core.formation.Formation.in_formation_staffs方法的典型用法代碼示例。如果您正苦於以下問題:Python Formation.in_formation_staffs方法的具體用法?Python Formation.in_formation_staffs怎麽用?Python Formation.in_formation_staffs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.formation.Formation的用法示例。


在下文中一共展示了Formation.in_formation_staffs方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_staffs

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import in_formation_staffs [as 別名]
    def load_staffs(self):
        from core.staff import StaffManger
        from core.formation import Formation

        self.formation_staffs = []

        sm = StaffManger(self.server_id, self.char_id)
        fm = Formation(self.server_id, self.char_id)

        for k in fm.in_formation_staffs():
            self.formation_staffs.append(sm.get_staff_object(k))
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:13,代碼來源:club.py

示例2: after_change

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import in_formation_staffs [as 別名]
    def after_change(self, uid):
        from core.formation import Formation
        from core.plunder import Plunder
        from core.championship import Championship

        self.load_units()
        unit = self.get_unit_object(uid)
        all_units = self.get_units_data()

        all_units_object = [self.get_unit_object(k) for k, _ in all_units.iteritems()]

        changed_units = {}

        for u in all_units_object:
            if u.config.race == unit.config.race:
                changed_units[u.id] = u

        self.send_notify_with_unit_objs(changed_units.values())

        fm = Formation(self.server_id, self.char_id)

        _changed = False
        for k, v in fm.in_formation_staffs().iteritems():
            if v['unit_id'] in changed_units:
                _changed = True
                break

        if _changed:
            club = Club(self.server_id, self.char_id, load_staffs=False)
            club.force_load_staffs(send_notify=True)

        _p = Plunder(self.server_id, self.char_id)
        if _p.find_way_id_by_unit_id(uid):
            _p.send_formation_notify()

        _c = Championship(self.server_id, self.char_id)
        if _c.find_way_id_by_unit_id(uid):
            _c.send_formation_notify()
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:40,代碼來源:unit.py

示例3: _single_response

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import in_formation_staffs [as 別名]
    def _single_response(_char):
        context['show'] = True
        context['char_id'] = _char.id
        context['char_name'] = _char.name
        context['server_id'] = _char.server_id

        _club = Club(_char.server_id, _char.id)
        _bag = Bag(_char.server_id, _char.id)
        _vip = VIP(_char.server_id, _char.id)
        _sm = StaffManger(_char.server_id, _char.id)
        _fm = Formation(_char.server_id, _char.id)
        _te = Territory(_char.server_id, _char.id)
        _union = Union(_char.server_id, _char.id)

        context['last_login'] = arrow.get(_club.last_login).to(settings.TIME_ZONE).format("YYYY-MM-DD HH:mm:ss")
        context['club_level'] = _club.level
        context['vip_level'] = _vip.doc['vip']
        context['vip_exp'] = _vip.doc['exp']
        context['power'] = _club.power

        context['diamond'] = _club.diamond
        context['gold'] = _club.gold
        context['crystal'] = _club.crystal
        context['gas'] = _club.gas
        context['item_30007'] = _bag.get_amount_by_item_id(30007)
        context['item_30008'] = _bag.get_amount_by_item_id(30008)
        context['item_30009'] = _bag.get_amount_by_item_id(30009)
        context['item_30015'] = _te.get_work_card_amount()

        _res = MongoResource.db(_char.server_id).find_one({'_id': _char.id})
        if not _res:
            _res = {'resource': {}}
        context['item_30022'] = _res['resource'].get('30022', 0)
        context['item_30023'] = _res['resource'].get('30023', 0)
        context['item_30019'] = _res['resource'].get('30019', 0)

        _union_id = _union.get_joined_union_id()
        if not _union_id:
            context['union'] = {}
        else:
            context['union'] = {
                'id': _union_id,
                'name': _union.union_doc['name'],
                'joined_at': arrow.get(_union.member_doc['joined_at']).to(settings.TIME_ZONE).format(
                    "YYYY-MM-DD HH:mm:ss"),
                'contribution': _union.member_doc['contribution']
            }

        in_formation_staffs = _fm.in_formation_staffs()
        staffs_data = []
        equip_data = []

        for k, v in in_formation_staffs.iteritems():
            staff_obj = _sm.get_staff_object(k)
            staff_name = ConfigItemNew.get(staff_obj.oid).name

            staffs_data.append({
                'id': staff_obj.id,
                'oid': staff_obj.oid,
                'name': staff_name,
                'level': staff_obj.level,
                'step': staff_obj.step,
                'star': staff_obj.star,
                'power': staff_obj.power,
                'unit_id': v['unit_id'],
                'position': v['position'],
            })

            for bag_slot_id in [staff_obj.equip_special, staff_obj.equip_decoration, staff_obj.equip_keyboard,
                                staff_obj.equip_monitor, staff_obj.equip_mouse]:

                if not bag_slot_id:
                    continue

                equip = _bag.get_slot(bag_slot_id)
                equip_data.append({
                    'oid': equip['item_id'],
                    'level': equip['level'],
                    'name': ConfigItemNew.get(equip['item_id']).name,
                    'staff_name': staff_name
                })

        context['staffs'] = staffs_data
        context['equips'] = equip_data

        return render_to_response(
            'dianjing_statistics_char.html',
            context=context
        )
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:91,代碼來源:statistics.py

示例4: equipment_level_up

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import in_formation_staffs [as 別名]
    def equipment_level_up(self, slot_id, times=1):
        from core.staff import StaffManger
        from core.formation import Formation
        from core.plunder import Plunder

        this_slot = self.doc['slots'][slot_id]
        item_id = this_slot['item_id']

        if get_item_type(item_id) != TYPE_EQUIPMENT:
            raise GameException(ConfigErrorMessage.get_error_id("INVALID_OPERATE"))

        equip = Equipment.load_from_slot_data(this_slot)
        level = equip.level

        if equip.is_special:
            if level >= ConfigEquipmentSpecialLevel.MAX_LEVEL:
                raise GameException(ConfigErrorMessage.get_error_id("EQUIPMENT_SELF_REACH_MAX_LEVEL"))

            station_level_limit = Plunder(self.server_id, self.char_id).get_station_level() * 2
            if level >= station_level_limit:
                raise GameException(ConfigErrorMessage.get_error_id("EQUIPMENT_SPECIAL_REACH_MAX_LEVEL"))

            max_level = min(ConfigEquipmentSpecialLevel.MAX_LEVEL, station_level_limit)
        else:
            config = ConfigEquipmentNew.get(item_id)
            if level >= config.max_level:
                raise GameException(ConfigErrorMessage.get_error_id("EQUIPMENT_SELF_REACH_MAX_LEVEL"))

            club_level_limit = get_club_property(self.server_id, self.char_id, 'level') * 2
            if level >= club_level_limit:
                raise GameException(ConfigErrorMessage.get_error_id("EQUIPMENT_REACH_MAX_LEVEL"))

            max_level = min(config.max_level, club_level_limit)

        can_add_level = max_level - level
        if times > can_add_level:
            times = can_add_level

        def do_level_up(_add):
            _item_needs = equip.get_level_up_needs_items(_add)

            resource_classified = ResourceClassification.classify(_item_needs)
            resource_classified.check_exist(self.server_id, self.char_id)
            resource_classified.remove(self.server_id, self.char_id,
                                       message="Bag.equipment_level_up:{0}".format(item_id))

        old_level = level
        error_code = 0

        for i in range(times, 0, -1):
            try:
                do_level_up(i)
            except GameException as e:
                error_code = e.error_id
            else:
                level += i
                break

        if level > old_level:
            self.doc['slots'][slot_id]['level'] = level

            MongoBag.db(self.server_id).update_one(
                {'_id': self.char_id},
                {'$set': {
                    'slots.{0}.level'.format(slot_id): level
                }}
            )

            ValueLogEquipmentLevelUpTimes(self.server_id, self.char_id).record(value=level - old_level)
            self.send_notify(slot_ids=[slot_id])

            sm = StaffManger(self.server_id, self.char_id)
            staff_id = sm.find_staff_id_with_equip(slot_id)
            if staff_id:
                s_obj = sm.get_staff_object(staff_id)
                s_obj.calculate()
                s_obj.make_cache()
                sm.send_notify(ids=[staff_id])

                fm = Formation(self.server_id, self.char_id)
                if staff_id in fm.in_formation_staffs():
                    Club(self.server_id, self.char_id).send_notify()

                    task_condition_trig_signal.send(
                        sender=None,
                        server_id=self.server_id,
                        char_id=self.char_id,
                        condition_name='core.formation.Formation'
                    )

        return error_code, level != old_level, Equipment.load_from_slot_data(self.doc['slots'][slot_id])
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:93,代碼來源:bag.py

示例5: force_load_staffs

# 需要導入模塊: from core.formation import Formation [as 別名]
# 或者: from core.formation.Formation import in_formation_staffs [as 別名]
    def force_load_staffs(self, send_notify=False):
        from core.staff import StaffManger, Staff
        from core.formation import Formation
        from core.unit import UnitManager
        from core.talent import TalentManager
        from core.collection import Collection
        from core.party import Party
        from core.inspire import Inspire
        from core.union import Union
        from core.bag import Bag

        self.formation_staffs = []

        sm = StaffManger(self.server_id, self.char_id)
        fm = Formation(self.server_id, self.char_id)
        um = UnitManager(self.server_id, self.char_id)
        ins = Inspire(self.server_id, self.char_id)

        staffs = sm.get_staffs_data()
        in_formation_staffs = fm.in_formation_staffs()

        staff_objs = {}
        """:type: dict[str, core.staff.Staff]"""
        for k, v in staffs.items():
            staff_objs[k] = Staff(self.server_id, self.char_id, k, v)

        for k, v in staff_objs.iteritems():
            if k in in_formation_staffs:
                self.formation_staffs.append(v)

                v.policy = in_formation_staffs[k]['policy']
                v.formation_position = in_formation_staffs[k]['position']
                unit_id = in_formation_staffs[k]['unit_id']
                if unit_id:
                    v.set_unit(um.get_unit_object(unit_id))

        working_staff_oids = fm.working_staff_oids()

        for k in in_formation_staffs:
            staff_objs[k].check_qianban(working_staff_oids)
            staff_objs[k].add_self_talent_effect(self)

        talent_effects_1 = TalentManager(self.server_id, self.char_id).get_talent_effects()
        talent_effects_2 = Collection(self.server_id, self.char_id).get_talent_effects()
        talent_effects_3 = fm.get_talent_effects()
        talent_effects_4 = Party(self.server_id, self.char_id).get_talent_effects()
        talent_effects_5 = Union(self.server_id, self.char_id).get_union_skill_talent_effects()

        self.add_talent_effects(talent_effects_1)
        self.add_talent_effects(talent_effects_2)
        self.add_talent_effects(talent_effects_3)
        self.add_talent_effects(talent_effects_4)
        self.add_talent_effects(talent_effects_5)

        config_inspire_level_addition, config_inspire_step_addition = ins.get_addition_config()

        bag = Bag(self.server_id, self.char_id)
        for _, v in staff_objs.iteritems():
            v.config_inspire_level_addition = config_inspire_level_addition
            v.config_inspire_step_addition = config_inspire_step_addition
            v.calculate(bag=bag, um=um)
            v.make_cache()

        if send_notify:
            self.send_notify()
            in_formation_staff_ids = fm.in_formation_staffs().keys()
            sm.send_notify(ids=in_formation_staff_ids)
開發者ID:yueyoum,項目名稱:dianjing,代碼行數:69,代碼來源:club.py


注:本文中的core.formation.Formation.in_formation_staffs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。