Esempio 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()
Esempio 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()
Esempio n. 3
0
def set_staff(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    slot_id = request._proto.slot_id
    staff_id = request._proto.staff_id

    ins = Inspire(server_id, char_id)
    ins.set_staff(slot_id, staff_id)

    response = InspireSetStaffResponse()
    response.ret = 0
    return ProtobufResponse(response)
Esempio n. 4
0
def set_staff(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    slot_id = request._proto.slot_id
    staff_id = request._proto.staff_id

    ins = Inspire(server_id, char_id)
    ins.set_staff(slot_id, staff_id)

    response = InspireSetStaffResponse()
    response.ret = 0
    return ProtobufResponse(response)
Esempio n. 5
0
def challenge_match_handler(server_id, char_id, challenge_id, star, **kwargs):
    TaskMain(server_id, char_id).trig(challenge_id)
    if star > 0:
        Formation(server_id, char_id).try_open_slots()
        Inspire(server_id, char_id).try_open_slots()
        TaskDaily(server_id, char_id).try_open()
        Plunder(server_id, char_id).try_initialize()
        ActivityChallenge(server_id, char_id).trig_notify(challenge_id)
Esempio n. 6
0
    def __init__(self, server_id, char_id):
        from core.formation import Formation
        from core.plunder import Plunder
        from core.inspire import Inspire
        from core.championship import Championship

        self.server_id = server_id
        self.char_id = char_id

        self.formation = Formation(server_id, char_id)

        p = Plunder(server_id, char_id)
        self.plunder_formation_1 = p.get_way_object(1)
        self.plunder_formation_2 = p.get_way_object(2)
        self.plunder_formation_3 = p.get_way_object(3)

        c = Championship(server_id, char_id)
        self.championship_formation_1 = c.get_way_object(1)
        self.championship_formation_2 = c.get_way_object(2)
        self.championship_formation_3 = c.get_way_object(3)

        self.inspire = Inspire(server_id, char_id)
Esempio n. 7
0
    def __init__(self, server_id, char_id):
        from core.formation import Formation
        from core.plunder import Plunder
        from core.inspire import Inspire
        from core.championship import Championship

        self.server_id = server_id
        self.char_id = char_id

        self.formation = Formation(server_id, char_id)

        p = Plunder(server_id, char_id)
        self.plunder_formation_1 = p.get_way_object(1)
        self.plunder_formation_2 = p.get_way_object(2)
        self.plunder_formation_3 = p.get_way_object(3)

        c = Championship(server_id, char_id)
        self.championship_formation_1 = c.get_way_object(1)
        self.championship_formation_2 = c.get_way_object(2)
        self.championship_formation_3 = c.get_way_object(3)

        self.inspire = Inspire(server_id, char_id)
Esempio n. 8
0
def game_start_handler(server_id, char_id, **kwargs):
    MessagePipe(char_id).clean()

    msg = UTCNotify()
    msg.timestamp = arrow.utcnow().timestamp
    MessagePipe(char_id).put(msg=msg)

    msg = SocketServerNotify()
    ss = random.choice(settings.SOCKET_SERVERS)
    msg.ip = ss['host']
    msg.port = ss['tcp']
    MessagePipe(char_id).put(msg=msg)

    _Resource.send_notify(server_id, char_id)

    UnitManager(server_id, char_id).send_notify()

    Bag(server_id, char_id).send_notify()

    StaffManger(server_id, char_id).send_notify()
    StaffRecruit(server_id, char_id).send_notify()

    f = Formation(server_id, char_id)
    f.send_formation_notify()
    f.send_slot_notify()

    club = Club(server_id, char_id)
    club.set_login()
    club.send_notify()

    msg = CreateDaysNotify()
    msg.days = days_passed(club.create_at)
    msg.create_at = club.create_at
    MessagePipe(char_id).put(msg=msg)

    chall = Challenge(server_id, char_id)
    chall.send_chapter_notify()
    chall.send_challenge_notify()

    FriendManager(server_id, char_id).send_notify()
    MailManager(server_id, char_id).send_notify()

    TaskMain(server_id, char_id).send_notify()
    TaskDaily(server_id, char_id).send_notify()

    Chat(server_id, char_id).send_notify()

    Notification(server_id, char_id).send_notify()

    FinanceStatistics(server_id, char_id).send_notify()

    TalentManager(server_id, char_id).send_notify()

    Dungeon(server_id, char_id).send_notify()

    a = Arena(server_id, char_id)
    a.send_notify()
    a.send_honor_notify()

    t = Tower(server_id, char_id)
    t.send_notify()
    t.send_goods_notify()

    Territory(server_id, char_id).send_notify()
    TerritoryStore(server_id, char_id).send_notify()
    TerritoryFriend(server_id, char_id).send_remained_times_notify()

    Store(server_id, char_id).send_notify()
    VIP(server_id, char_id).send_notify()
    Collection(server_id, char_id).send_notify()

    Energy(server_id, char_id).send_notify()

    w = Welfare(server_id, char_id)
    w.send_signin_notify()
    w.send_new_player_notify()
    w.send_level_reward_notify()
    w.send_energy_reward_notify()

    Union(server_id, char_id).send_all_notify()

    Purchase(server_id, char_id).send_notify()

    ac = ActivityNewPlayer(server_id, char_id)
    ac.send_notify()
    ac.send_daily_buy_notify()

    ActivityOnlineTime(server_id, char_id).send_notify()
    ActivityChallenge(server_id, char_id).send_notify()
    ActivityPurchaseDaily(server_id, char_id).send_notify()
    ActivityPurchaseContinues(server_id, char_id).send_notify()
    ActivityLevelGrowing(server_id, char_id).send_notify()

    p = Plunder(server_id, char_id)

    p.send_search_notify()
    p.send_result_notify()
    p.send_revenge_notify()
    p.send_station_notify()
    p.send_formation_notify()
    p.send_plunder_times_notify()
    p.send_plunder_daily_reward_notify()

    SpecialEquipmentGenerator(server_id, char_id).send_notify()

    Party(server_id, char_id).send_notify()

    ins = Inspire(server_id, char_id)
    ins.try_open_slots(send_notify=False)
    ins.send_notify()

    cs = Championship(server_id, char_id)
    cs.try_initialize(send_notify=False)
    cs.send_notify()

    WinningPlunder(server_id, char_id).send_notify()
    WinningArena(server_id, char_id).send_notify()
    WinningChampionship(server_id, char_id).send_notify()
    Worship(server_id, char_id).send_notify()
    CommonArenaWinningChat(server_id, char_id).send_notify()
    CommonPlunderWinningChat(server_id, char_id).send_notify()
    CommonChampionshipChat(server_id, char_id).send_notify()

    send_system_notify(server_id, char_id)
    BroadCast(server_id, char_id).try_cast_login_notify()
Esempio n. 9
0
class StaffWorkingChecker(object):
    def __init__(self, server_id, char_id):
        from core.formation import Formation
        from core.plunder import Plunder
        from core.inspire import Inspire
        from core.championship import Championship

        self.server_id = server_id
        self.char_id = char_id

        self.formation = Formation(server_id, char_id)

        p = Plunder(server_id, char_id)
        self.plunder_formation_1 = p.get_way_object(1)
        self.plunder_formation_2 = p.get_way_object(2)
        self.plunder_formation_3 = p.get_way_object(3)

        c = Championship(server_id, char_id)
        self.championship_formation_1 = c.get_way_object(1)
        self.championship_formation_2 = c.get_way_object(2)
        self.championship_formation_3 = c.get_way_object(3)

        self.inspire = Inspire(server_id, char_id)

    def is_not_working(self, staff_id, raise_exception=True):
        if self.formation.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id("STAFF_IN_FORMATION"))

            return False

        if self.plunder_formation_1.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_PLUNDER_FORMATION"))

            return False

        if self.plunder_formation_2.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_PLUNDER_FORMATION"))

            return False
        if self.plunder_formation_3.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_PLUNDER_FORMATION"))

            return False

        if self.championship_formation_1.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.championship_formation_2.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.championship_formation_3.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id(
                        "STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.inspire.is_staff_in(staff_id):
            if raise_exception:
                raise GameException(
                    ConfigErrorMessage.get_error_id("INSPIRE_STAFF_IN"))

            return False

        return True
Esempio n. 10
0
def game_start_handler(server_id, char_id, **kwargs):
    MessagePipe(char_id).clean()

    msg = UTCNotify()
    msg.timestamp = arrow.utcnow().timestamp
    MessagePipe(char_id).put(msg=msg)


    msg = SocketServerNotify()
    ss = random.choice(settings.SOCKET_SERVERS)
    msg.ip = ss['host']
    msg.port = ss['tcp']
    MessagePipe(char_id).put(msg=msg)

    _Resource.send_notify(server_id, char_id)

    UnitManager(server_id, char_id).send_notify()

    Bag(server_id, char_id).send_notify()

    StaffManger(server_id, char_id).send_notify()
    StaffRecruit(server_id, char_id).send_notify()

    f = Formation(server_id, char_id)
    f.send_formation_notify()
    f.send_slot_notify()

    club = Club(server_id, char_id)
    club.set_login()
    club.send_notify()

    msg = CreateDaysNotify()
    msg.days = days_passed(club.create_at)
    msg.create_at = club.create_at
    MessagePipe(char_id).put(msg=msg)

    chall = Challenge(server_id, char_id)
    chall.send_chapter_notify()
    chall.send_challenge_notify()

    FriendManager(server_id, char_id).send_notify()
    MailManager(server_id, char_id).send_notify()

    TaskMain(server_id, char_id).send_notify()
    TaskDaily(server_id, char_id).send_notify()

    Chat(server_id, char_id).send_notify()

    Notification(server_id, char_id).send_notify()

    FinanceStatistics(server_id, char_id).send_notify()

    TalentManager(server_id, char_id).send_notify()

    Dungeon(server_id, char_id).send_notify()

    a = Arena(server_id, char_id)
    a.send_notify()
    a.send_honor_notify()

    t = Tower(server_id, char_id)
    t.send_notify()
    t.send_goods_notify()

    Territory(server_id, char_id).send_notify()
    TerritoryStore(server_id, char_id).send_notify()
    TerritoryFriend(server_id, char_id).send_remained_times_notify()

    Store(server_id, char_id).send_notify()
    VIP(server_id, char_id).send_notify()
    Collection(server_id, char_id).send_notify()

    Energy(server_id, char_id).send_notify()

    w = Welfare(server_id, char_id)
    w.send_signin_notify()
    w.send_new_player_notify()
    w.send_level_reward_notify()
    w.send_energy_reward_notify()

    Union(server_id, char_id).send_all_notify()

    Purchase(server_id, char_id).send_notify()

    ac = ActivityNewPlayer(server_id, char_id)
    ac.send_notify()
    ac.send_daily_buy_notify()

    ActivityOnlineTime(server_id, char_id).send_notify()
    ActivityChallenge(server_id, char_id).send_notify()
    ActivityPurchaseDaily(server_id, char_id).send_notify()
    ActivityPurchaseContinues(server_id, char_id).send_notify()
    ActivityLevelGrowing(server_id, char_id).send_notify()

    p = Plunder(server_id, char_id)

    p.send_search_notify()
    p.send_result_notify()
    p.send_revenge_notify()
    p.send_station_notify()
    p.send_formation_notify()
    p.send_plunder_times_notify()
    p.send_plunder_daily_reward_notify()

    SpecialEquipmentGenerator(server_id, char_id).send_notify()

    Party(server_id, char_id).send_notify()

    ins = Inspire(server_id, char_id)
    ins.try_open_slots(send_notify=False)
    ins.send_notify()

    cs = Championship(server_id, char_id)
    cs.try_initialize(send_notify=False)
    cs.send_notify()

    WinningPlunder(server_id, char_id).send_notify()
    WinningArena(server_id, char_id).send_notify()
    WinningChampionship(server_id, char_id).send_notify()
    Worship(server_id, char_id).send_notify()
    CommonArenaWinningChat(server_id, char_id).send_notify()
    CommonPlunderWinningChat(server_id, char_id).send_notify()
    CommonChampionshipChat(server_id, char_id).send_notify()

    send_system_notify(server_id, char_id)
    BroadCast(server_id, char_id).try_cast_login_notify()
Esempio n. 11
0
class StaffWorkingChecker(object):
    def __init__(self, server_id, char_id):
        from core.formation import Formation
        from core.plunder import Plunder
        from core.inspire import Inspire
        from core.championship import Championship

        self.server_id = server_id
        self.char_id = char_id

        self.formation = Formation(server_id, char_id)

        p = Plunder(server_id, char_id)
        self.plunder_formation_1 = p.get_way_object(1)
        self.plunder_formation_2 = p.get_way_object(2)
        self.plunder_formation_3 = p.get_way_object(3)

        c = Championship(server_id, char_id)
        self.championship_formation_1 = c.get_way_object(1)
        self.championship_formation_2 = c.get_way_object(2)
        self.championship_formation_3 = c.get_way_object(3)

        self.inspire = Inspire(server_id, char_id)

    def is_not_working(self, staff_id, raise_exception=True):
        if self.formation.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_FORMATION"))

            return False

        if self.plunder_formation_1.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_PLUNDER_FORMATION"))

            return False

        if self.plunder_formation_2.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_PLUNDER_FORMATION"))

            return False
        if self.plunder_formation_3.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_PLUNDER_FORMATION"))

            return False

        if self.championship_formation_1.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.championship_formation_2.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.championship_formation_3.is_staff_in_formation(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("STAFF_IN_CHAMPIONSHIP_FORMATION"))

            return False

        if self.inspire.is_staff_in(staff_id):
            if raise_exception:
                raise GameException(ConfigErrorMessage.get_error_id("INSPIRE_STAFF_IN"))

            return False

        return True
Esempio n. 12
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)