Exemplo n.º 1
0
    def load_formation_staffs(self):
        # NOTE: 这段代码其实是从 Club.force_load_staffs 抄来的
        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

        self.formation_staffs = []
        """:type: list[core.staff.Staff]"""

        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 = self.in_formation_staffs()

        for k, v in in_formation_staffs.iteritems():
            obj = Staff(self.server_id, self.char_id, k, staffs[k])
            self.formation_staffs.append(obj)

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

        club = Club(self.server_id, self.char_id, load_staffs=False)
        club.formation_staffs = self.formation_staffs

        working_staff_oids = self.working_staff_oids()

        for obj in self.formation_staffs:
            obj.check_qianban(working_staff_oids)
            obj.add_self_talent_effect(club)

        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()

        club.add_talent_effects(talent_effects_1)
        club.add_talent_effects(talent_effects_2)
        club.add_talent_effects(talent_effects_3)
        club.add_talent_effects(talent_effects_4)

        config_inspire_level_addition, config_inspire_step_addition = ins.get_addition_config(
        )

        for obj in self.formation_staffs:
            obj.config_inspire_level_addition = config_inspire_level_addition
            obj.config_inspire_step_addition = config_inspire_step_addition
            obj.calculate()
Exemplo n.º 2
0
    def load_formation_staffs(self):
        # NOTE: 这段代码其实是从 Club.force_load_staffs 抄来的
        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

        self.formation_staffs = []
        """:type: list[core.staff.Staff]"""

        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 = self.in_formation_staffs()

        for k, v in in_formation_staffs.iteritems():
            obj = Staff(self.server_id, self.char_id, k, staffs[k])
            self.formation_staffs.append(obj)

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

        club = Club(self.server_id, self.char_id, load_staffs=False)
        club.formation_staffs = self.formation_staffs

        working_staff_oids = self.working_staff_oids()

        for obj in self.formation_staffs:
            obj.check_qianban(working_staff_oids)
            obj.add_self_talent_effect(club)

        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()

        club.add_talent_effects(talent_effects_1)
        club.add_talent_effects(talent_effects_2)
        club.add_talent_effects(talent_effects_3)
        club.add_talent_effects(talent_effects_4)

        config_inspire_level_addition, config_inspire_step_addition = ins.get_addition_config()

        for obj in self.formation_staffs:
            obj.config_inspire_level_addition = config_inspire_level_addition
            obj.config_inspire_step_addition = config_inspire_step_addition
            obj.calculate()
Exemplo n.º 3
0
    def get_addition_config(self):
        sm = StaffManger(self.server_id, self.char_id)
        # XXX 不能用 get_staff_object
        all_staffs = sm.get_staffs_data()

        levels = 0
        steps = 0

        for s in self.all_staffs():
            data = all_staffs[s]
            levels += data['level']
            steps += data['step']

        config_level_addition = ConfigInspireAddition.get_by_level(levels)
        config_step_addition = ConfigInspireAddition.get_by_step(steps)

        return config_level_addition, config_step_addition
Exemplo n.º 4
0
    def get_addition_config(self):
        sm = StaffManger(self.server_id, self.char_id)
        # XXX 不能用 get_staff_object
        all_staffs = sm.get_staffs_data()

        levels = 0
        steps = 0

        for s in self.all_staffs():
            data = all_staffs[s]
            levels += data['level']
            steps += data['step']

        config_level_addition = ConfigInspireAddition.get_by_level(levels)
        config_step_addition = ConfigInspireAddition.get_by_step(steps)

        return config_level_addition, config_step_addition
Exemplo n.º 5
0
    def working_staff_oids(self):
        from core.inspire import Inspire
        oids = []

        sm = StaffManger(self.server_id, self.char_id)
        # XXX: 这里不能用 get_staff_object
        # 因为get_staff_obj 可能用调用到 Club.force_load_staffs
        # 在 Club.force_load_staffs 中又会调用 这个方法
        # 然后就死循环了
        all_staffs = sm.get_staffs_data()

        working_staffs = self.in_formation_staffs().keys()
        working_staffs.extend(Inspire(self.server_id, self.char_id).all_staffs())

        for s in working_staffs:
            oids.append(all_staffs[s]['oid'])

        return oids
Exemplo n.º 6
0
    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)