Ejemplo n.º 1
0
def hang_get_reward(request):
    affairs = Affairs(request._char_id)
    drop = affairs.get_hang_reward()

    msg = HangGetRewardResponse()
    msg.ret = 0
    msg.drop.MergeFrom(drop)

    return pack_msg(msg)
Ejemplo n.º 2
0
def hang_get_reward(request):
    affairs = Affairs(request._char_id)
    drop = affairs.get_hang_reward()

    msg = HangGetRewardResponse()
    msg.ret = 0
    msg.drop.MergeFrom(drop)

    return pack_msg(msg)
Ejemplo n.º 3
0
def hang_start(request):
    req = request._proto

    affairs = Affairs(request._char_id)
    drop = affairs.start_hang(req.city_id)

    msg = HangStartResponse()
    msg.ret = 0
    if drop:
        msg.drop.MergeFrom(drop)

    return pack_msg(msg)
Ejemplo n.º 4
0
def hang_start(request):
    req = request._proto

    affairs = Affairs(request._char_id)
    drop = affairs.start_hang(req.city_id)

    msg = HangStartResponse()
    msg.ret = 0
    if drop:
        msg.drop.MergeFrom(drop)

    return pack_msg(msg)
Ejemplo n.º 5
0
def finish(request):
    from_char_id = int(request.POST['from_char_id'])
    from_char_name = request.POST['from_char_name']
    to_char_id = int(request.POST['to_char_id'])
    from_win = request.POST['from_win'] == '1'
    standard_drop = json.loads(request.POST['standard_drop'])

    affairs = Affairs(to_char_id)
    affairs.got_plundered(from_char_id, from_char_name, from_win,
                          standard_drop)

    return {
        'ret': 0,
    }
Ejemplo n.º 6
0
    def get_plunder_gold(self, level):
        from core.affairs import Affairs
        if not self.char_id:
            return 0

        affairs = Affairs(self.char_id)
        ho = affairs.get_hang_obj()
        gold = ho.gold

        level_diff = self.level - level
        if level_diff > 8:
            level_diff = 8
        if level_diff < -8:
            level_diff = -8

        result = level_diff * 0.025 + PLUNDER_GOT_GOLD_PARAM_BASE_ADJUST
        return int(result * gold)
Ejemplo n.º 7
0
def pve_finish(char_id, stage_id, win, star, **kwargs):
    achievement = Achievement(char_id)
    if win:
        achievement.trig(7, stage_id)
        if star:
            achievement.trig(9, 1)

        t = Task(char_id)
        t.trig(1)
    else:
        achievement.trig(8, 1)


    # 城镇
    # 自动开启第一个城镇,并且自动开始挂机
    if win:
        if STAGES[stage_id].battle_end:
            affairs = Affairs(char_id)
            new_opened = affairs.open_city(STAGES[stage_id].battle)
            if STAGES[stage_id].battle == FIRST_CITY_ID and new_opened:
                affairs.start_hang(FIRST_CITY_ID)
Ejemplo n.º 8
0
def pve_finish(char_id, stage_id, win, star, **kwargs):
    achievement = Achievement(char_id)
    if win:
        achievement.trig(7, stage_id)
        if star:
            achievement.trig(9, 1)

        t = Task(char_id)
        t.trig(1)
    else:
        achievement.trig(8, 1)

    # 开启城镇
    if win:
        if STAGES[stage_id].battle_open:
            affairs = Affairs(char_id)
            affairs.open_city(STAGES[stage_id].battle)

    # 判断活动
    if win:
        ActivityStatic(char_id).trig(3001)
Ejemplo n.º 9
0
def pve_finish(char_id, stage_id, win, star, **kwargs):
    achievement = Achievement(char_id)
    if win:
        achievement.trig(7, stage_id)
        if star:
            achievement.trig(9, 1)

        t = Task(char_id)
        t.trig(1)
    else:
        achievement.trig(8, 1)


    # 开启城镇
    if win:
        if STAGES[stage_id].battle_open:
            affairs = Affairs(char_id)
            affairs.open_city(STAGES[stage_id].battle)

    # 判断活动
    if win:
        ActivityStatic(char_id).trig(3001)
Ejemplo n.º 10
0
    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))
Ejemplo n.º 11
0
 def get_levy_drop(self):
     a = Affairs(self.char_id)
     return a.get_drop(passed_time=3600*2)
Ejemplo n.º 12
0
def login_notify(char_id):
    message_clean(char_id)
    function_open = FunctionOpen(char_id)
    function_open.send_notify()

    hero_objs = char_heros_obj(char_id)

    Char(char_id).send_notify()

    hero_notify(char_id, hero_objs)
    Item(char_id).send_notify()

    f = Formation(char_id)
    f.send_socket_notify()
    f.send_formation_notify()

    Plunder(char_id).send_notify()

    p = Prison(char_id)
    p.send_prisoners_notify()

    if Arena.FUNC_ID not in function_open.mf.freeze:
        arena = Arena(char_id)
        arena.send_notify()
        arena.login_process()

    f = Friend(char_id)
    f.send_friends_notify()
    f.send_friends_amount_notify()

    CheckIn(char_id).send_notify()

    stage = Stage(char_id)
    stage.send_already_stage_notify()
    stage.send_new_stage_notify()

    stage_elite = EliteStage(char_id)
    stage_elite.send_notify()
    stage_elite.send_remained_times_notify()

    stage_activity = ActivityStage(char_id)
    stage_activity.send_notify()
    stage_activity.send_remained_times_notify()

    HeroPanel(char_id).send_notify()
    Task(char_id).send_notify()
    Achievement(char_id).send_notify()
    HeroSoul(char_id).send_notify()
    Levy(char_id).send_notify()
    Attachment(char_id).send_notify()

    PurchaseAction(char_id).send_notify()

    SystemBroadcast(char_id).send_global_broadcast()

    affairs = Affairs(char_id)
    affairs.send_city_notify()
    affairs.send_hang_notify()

    # mail notify 要放在最后,因为 其他功能初始化时可能会产生登录邮件
    Mail(char_id).send_notify()
Ejemplo n.º 13
0
def login_notify(char_id):
    message_clean(char_id)
    function_open = FunctionOpen(char_id)
    function_open.send_notify()

    hero_objs = char_heros_obj(char_id)

    Char(char_id).send_notify()
    VIP(char_id).send_notify()

    hero_notify(char_id, hero_objs)
    Item(char_id).send_notify()

    f = Formation(char_id)
    f.send_socket_notify()
    f.send_formation_notify()

    Plunder(char_id).send_notify()

    p = Prison(char_id)
    p.send_prisoners_notify()

    a = Arena(char_id)
    a.send_notify()
    a.login_process()

    f = Friend(char_id)
    f.send_friends_notify()
    f.send_friends_amount_notify()

    CheckIn(char_id).send_notify()

    stage = Stage(char_id)
    stage.send_already_stage_notify()
    stage.send_new_stage_notify()

    stage_elite = EliteStage(char_id)
    stage_elite.send_notify()
    stage_elite.send_times_notify()

    stage_activity = ActivityStage(char_id)
    stage_activity.check(send_notify=False)
    stage_activity.send_notify()
    stage_activity.send_remained_times_notify()

    HeroPanel(char_id).send_notify()
    Task(char_id).send_notify()
    Achievement(char_id).send_notify()
    HeroSoul(char_id).send_notify()
    Levy(char_id).send_notify()
    Attachment(char_id).send_notify()

    BasePurchaseAction(char_id).send_notify()

    SystemBroadcast(char_id).send_global_broadcast()
    ChatMessagePublish(char_id).send_notify()

    affairs = Affairs(char_id)
    affairs.send_city_notify()
    affairs.send_hang_notify()

    HorseFreeTimesManager(char_id).send_notify()
    Horse(char_id).send_notify()

    union.send_notify(char_id)

    ae = ActivityEntry(char_id, 50006)
    if ae and ae.is_valid():
        ae.enable(ae.get_current_value(char_id))

    ActivityStatic(char_id).send_notify()

    # mail notify 要放在最后,因为 其他功能初始化时可能会产生登录邮件
    Mail(char_id).send_notify()
Ejemplo n.º 14
0
def hang_sync(request):
    affairs = Affairs(request._char_id)
    affairs.send_hang_notify()
    return None
Ejemplo n.º 15
0
 def get_levy_drop(self):
     a = Affairs(self.char_id)
     return a.get_drop(passed_time=3600 * 2)
Ejemplo n.º 16
0
def login_notify(char_id):
    message_clean(char_id)
    function_open = FunctionOpen(char_id)
    function_open.send_notify()

    hero_objs = char_heros_obj(char_id)

    Char(char_id).send_notify()
    VIP(char_id).send_notify()

    hero_notify(char_id, hero_objs)
    Item(char_id).send_notify()

    f = Formation(char_id)
    f.send_socket_notify()
    f.send_formation_notify()


    Plunder(char_id).send_notify()

    p = Prison(char_id)
    p.send_prisoners_notify()

    a = Arena(char_id)
    a.send_notify()
    a.login_process()

    f = Friend(char_id)
    f.send_friends_notify()
    f.send_friends_amount_notify()

    CheckIn(char_id).send_notify()

    stage = Stage(char_id)
    stage.send_already_stage_notify()
    stage.send_new_stage_notify()

    stage_elite = EliteStage(char_id)
    stage_elite.send_notify()
    stage_elite.send_times_notify()

    stage_activity = ActivityStage(char_id)
    stage_activity.check(send_notify=False)
    stage_activity.send_notify()
    stage_activity.send_remained_times_notify()

    HeroPanel(char_id).send_notify()
    Task(char_id).send_notify()
    Achievement(char_id).send_notify()
    HeroSoul(char_id).send_notify()
    Levy(char_id).send_notify()
    Attachment(char_id).send_notify()

    BasePurchaseAction(char_id).send_notify()

    SystemBroadcast(char_id).send_global_broadcast()
    ChatMessagePublish(char_id).send_notify()

    affairs = Affairs(char_id)
    affairs.send_city_notify()
    affairs.send_hang_notify()

    HorseFreeTimesManager(char_id).send_notify()
    Horse(char_id).send_notify()

    union.send_notify(char_id)


    ae = ActivityEntry(char_id, 50006)
    if ae and ae.is_valid():
        ae.enable(ae.get_current_value(char_id))

    ActivityStatic(char_id).send_notify()

    # mail notify 要放在最后,因为 其他功能初始化时可能会产生登录邮件
    Mail(char_id).send_notify()
Ejemplo n.º 17
0
def _plunder_finished(from_char_id, to_char_id, from_win, standard_drop, **kwargs):
    affairs = Affairs(to_char_id)
    affairs.got_plundered(from_char_id, from_win, standard_drop)
Ejemplo n.º 18
0
def hang_sync(request):
    affairs = Affairs(request._char_id)
    affairs.send_hang_notify()
    return None