Esempio n. 1
0
def members_train(context):
    """获取社团成员数据
    """
    ki_user = context.user

    uid = context.get_parameter("uid")

    group_id = ki_user.group.group_id
    if not judge_open_train(ki_user.sid, group_id):
        context.result['mc'] = MsgCode['UserModuleNotOpen']
        return

    member_data = GroupService.get_member_info_by_uid(ki_user.sid, group_id, uid)
    # 检测目标是否在公会
    if not member_data:
        context.result['mc'] = MsgCode['GroupMemberNotExist']
        return

    user = User.get(uid)
    if not isinstance(user, User):
        context.result['mc'] = MsgCode['UserNotExist']
        return
    else:
        data = {}
        data["state"] = user.group.train_list
        ids = [i for i in user.group.train_list if i not in [0,-1]]
        heros = {}
        group_data = GroupService.find(ki_user.sid, group_id)
        for hid in ids:
            heros[hid] = count_group_train_hero(hid, user, group_data["level"])

        data["heros"] = heros

        context.result["data"] = data
Esempio n. 2
0
def members_train(context):
    """获取社团成员数据
    """
    ki_user = context.user

    uid = context.get_parameter("uid")

    group_id = ki_user.group.group_id
    if not judge_open_train(ki_user.sid, group_id):
        context.result['mc'] = MsgCode['UserModuleNotOpen']
        return

    member_data = GroupService.get_member_info_by_uid(ki_user.sid, group_id,
                                                      uid)
    # 检测目标是否在公会
    if not member_data:
        context.result['mc'] = MsgCode['GroupMemberNotExist']
        return

    user = User.get(uid)
    if not isinstance(user, User):
        context.result['mc'] = MsgCode['UserNotExist']
        return
    else:
        data = {}
        data["state"] = user.group.train_list
        ids = [i for i in user.group.train_list if i not in [0, -1]]
        heros = {}
        group_data = GroupService.find(ki_user.sid, group_id)
        for hid in ids:
            heros[hid] = count_group_train_hero(hid, user, group_data["level"])

        data["heros"] = heros

        context.result["data"] = data
Esempio n. 3
0
def help(context):
    """帮助其它社员加速
    """
    ki_user = context.user

    uid = context.get_parameter("uid")
    hero_id = context.get_parameter("hero_id")

    if not judge_open_train(ki_user.sid, ki_user.group.group_id):
        context.result['mc'] = MsgCode['UserModuleNotOpen']
        return

    # 不能给自己加速啊!!!
    if ki_user.uid == uid:
        context.result['mc'] = MsgCode['ParamIllegal']
        return

    if ki_user.daily_info.group_train_express_times >= GROUP_TRAIN_HELP_TIMES:
        context.result['mc'] = MsgCode['GroupTrainTimesMax']
        return

    group_id = ki_user.group.group_id
    member_data = GroupService.get_member_info_by_uid(ki_user.sid, group_id,
                                                      uid)
    # 检测目标是否在公会
    if not member_data:
        context.result['mc'] = MsgCode['GroupMemberNotExist']
        return

    user = User.get(uid)
    if not isinstance(user, User):
        context.result['mc'] = MsgCode['UserNotExist']
        return
    else:
        helped_times = int(
            GroupService.get_train_pos_times(ki_user.sid, group_id, uid))
        if helped_times >= GROUP_TRAIN_HELP_TIMES1:
            context.result['mc'] = MsgCode['GroupTrainHisTimesMax']
            return

        if hero_id not in user.group.train_list:
            context.result['mc'] = MsgCode['GroupTrainHeroNotOn']
            return

        GroupService.update_train_express_times(ki_user.sid, group_id, uid,
                                                hero_id, ki_user.name)

        user_logic.add_game_values(ki_user, {1: GROUP_TRAIN_HELP_GOLD})

        ki_user.daily_info.group_train_express_times += 1
        ki_user.daily_info.put()

    context.result['mc'] = MsgCode['GroupTrainHelpOtherSucc']
Esempio n. 4
0
def help(context):
    """帮助其它社员加速
    """
    ki_user = context.user

    uid = context.get_parameter("uid")
    hero_id = context.get_parameter("hero_id")

    if not judge_open_train(ki_user.sid, ki_user.group.group_id):
        context.result['mc'] = MsgCode['UserModuleNotOpen']
        return

    # 不能给自己加速啊!!!
    if ki_user.uid == uid:
        context.result['mc'] = MsgCode['ParamIllegal']
        return

    if ki_user.daily_info.group_train_express_times >= GROUP_TRAIN_HELP_TIMES:
        context.result['mc'] = MsgCode['GroupTrainTimesMax']
        return

    group_id = ki_user.group.group_id
    member_data = GroupService.get_member_info_by_uid(ki_user.sid, group_id, uid)
    # 检测目标是否在公会
    if not member_data:
        context.result['mc'] = MsgCode['GroupMemberNotExist']
        return

    user = User.get(uid)
    if not isinstance(user, User):
        context.result['mc'] = MsgCode['UserNotExist']
        return
    else:
        helped_times = int(GroupService.get_train_pos_times(ki_user.sid, group_id, uid))
        if helped_times >= GROUP_TRAIN_HELP_TIMES1:
            context.result['mc'] = MsgCode['GroupTrainHisTimesMax']
            return

        if hero_id not in user.group.train_list:
            context.result['mc'] = MsgCode['GroupTrainHeroNotOn']
            return

        GroupService.update_train_express_times(ki_user.sid, group_id, uid, hero_id, ki_user.name)

        user_logic.add_game_values(ki_user, {1: GROUP_TRAIN_HELP_GOLD})

        ki_user.daily_info.group_train_express_times += 1
        ki_user.daily_info.put()

    context.result['mc'] = MsgCode['GroupTrainHelpOtherSucc']