示例#1
0
    private OpRes addItemToSomeOne(ParamGrant param, List <ParamItem> item_list, GMUser user)
    {
        List <int> playerList = new List <int>();
        bool       res        = Tool.parseNumList(param.m_playerId, playerList);

        if (!res)
        {
            return(OpRes.op_res_param_not_valid);
        }

        try
        {
            bool addSucc = false;

            for (int j = 0; j < playerList.Count; j++)
            {
                int    playerid = playerList[j];
                string guid     = getGUIDById(playerid, user);
                if (guid != "")
                {
                    addSucc = false;

                    for (int i = 0; i < item_list.Count; i++)
                    {
                        DBAddBenefit tmp = new DBAddBenefit();
                        tmp.m_playerGUID = guid;
                        tmp.m_grantType  = (int)GrantType.gran_type_item;
                        tmp.m_count      = item_list[i].m_itemCount;
                        tmp.m_exParam1   = item_list[i].m_itemId;
                        if (!addBenefitToDB(tmp, user))
                        {
                            param.m_failedPlayer += playerid + " ";
                            param.m_failedItem   += tmp.m_exParam1 + " ";
                        }
                        else
                        {
                            if (!addSucc)
                            {
                                param.m_successPlayer += playerid + " ";
                                addSucc = true;
                            }
                        }
                    }
                }
                else
                {
                    param.m_failedPlayer += playerid + " ";
                    param.m_failedItem   += "* ";
                }
            }
        }
        catch (System.Exception ex)
        {
        }
        return(param.m_successPlayer == "" ? OpRes.op_res_failed : OpRes.opres_success);
    }
示例#2
0
    // 给某个玩家列表发放福利
    protected OpRes addReardToPlayerList(ParamGrant param, int count, int m_grantType, GMUser user)
    {
        List <int> playerList = new List <int>();
        bool       res        = Tool.parseNumList(param.m_playerId, playerList);

        if (!res)
        {
            return(OpRes.op_res_param_not_valid);
        }

        try
        {
            for (int i = 0; i < playerList.Count; i++)
            {
                int    playerid = playerList[i];
                string guid     = getGUIDById(playerid, user);
                if (guid != "")
                {
                    DBAddBenefit tmp = new DBAddBenefit();
                    tmp.m_playerGUID = guid;
                    tmp.m_grantType  = m_grantType;
                    tmp.m_count      = count;
                    if (!addBenefitToDB(tmp, user))
                    {
                        param.m_failedPlayer += playerid + " ";
                    }
                    else
                    {
                        param.m_successPlayer += playerid + " ";
                    }
                }
                else
                {
                    param.m_failedPlayer += playerid + " ";
                }
            }
        }
        catch (System.Exception ex)
        {
        }
        return(param.m_successPlayer == "" ? OpRes.op_res_failed : OpRes.opres_success);
    }
示例#3
0
    public override OpRes doGrantBenefit(object param, GMUser user)
    {
        ParamGrant       p         = (ParamGrant)param;
        List <ParamItem> item_list = new List <ParamItem>();

        try
        {
            Match match = Regex.Match(p.m_grantParam, Exp.TWO_NUM_BY_SPACE);
            if (!match.Success)
            {
                match = Regex.Match(p.m_grantParam, Exp.TWO_NUM_BY_SPACE_SEQ);
                if (!match.Success)
                {
                    return(OpRes.op_res_param_not_valid);
                }
            }
            parseItem(p.m_grantParam, item_list);
        }
        catch (System.Exception ex)
        {
            return(OpRes.op_res_failed);
        }

        if (item_list.Count == 0)
        {
            return(OpRes.op_res_param_not_valid);
        }

        for (int i = 0; i < item_list.Count; i++)
        {
        }

        if (p.m_target == GrantTarget.grant_target_someone)
        {
            OpRes res = addItemToSomeOne(p, item_list, user);
            if (res == OpRes.opres_success)
            {
            }
            return(res);
        }

        int level = 1;

        if (p.m_level != "")
        {
            try
            {
                // 转至level
                level = Convert.ToInt32(p.m_level);
                if (level <= 0)
                {
                    level = 1;
                }
            }
            catch (System.Exception ex)
            {
                return(OpRes.op_res_failed);
            }
        }
        IMongoQuery imq = getLevelImq(p.m_target == GrantTarget.grant_target_vip, level);

        /*string guid = firstPlayerGUID(p.m_target == GrantTarget.grant_target_vip, user, imq, getPlatformName(p.m_platIndex));
         * while (guid != "")
         * {
         *  for (int i = 0; i < item_list.Count; i++)
         *  {
         *      DBAddBenefit tmp = new DBAddBenefit();
         *      tmp.m_playerGUID = guid;
         *      tmp.m_grantType = (int)GrantType.gran_type_item;
         *      tmp.m_count = item_list[i].m_itemCount;
         *      tmp.m_exParam1 = item_list[i].m_itemId;       // 这个参数存储道具ID
         *      addBenefitToDB(tmp, user);
         *  }
         *  guid = nextPlayerGUID(user);
         * }*/
#if _OLD_BENEFIT_
        List <string> guid_list = new List <string>();
        initBenefit(p.m_target == GrantTarget.grant_target_vip, user, imq, getPlatformName(p.m_platIndex));
        bool run = nextPlayerGUIDList(user, 1000, guid_list);
        while (run)
        {
            for (int j = 0; j < guid_list.Count; j++)
            {
                for (int i = 0; i < item_list.Count; i++)
                {
                    DBAddBenefit tmp = new DBAddBenefit();
                    tmp.m_playerGUID = guid_list[j];
                    tmp.m_grantType  = (int)GrantType.gran_type_item;
                    tmp.m_count      = item_list[i].m_itemCount;
                    tmp.m_exParam1   = item_list[i].m_itemId;     // 这个参数存储道具ID
                    addBenefitToDB(tmp, user);
                }
            }
            run = nextPlayerGUIDList(user, 1000, guid_list);
        }
#else
        DBAddBenefit tmp = new DBAddBenefit();
        tmp.m_grantType = (int)GrantType.gran_type_item;
        tmp.m_exParam2  = BaseJsonSerializer.serialize(item_list);
        addFullBenefitToDB(tmp, user, p.m_platIndex);
#endif
//         OpLogMgr.getInstance().addLog(LogType.LOG_TYPE_ADD_BENEFIT_ITEM,
//             new ParamAddBenefitItem(p.m_playerId, item_list, (int)p.m_target, level, getPlatformName(p.m_platIndex, false)), user);
        return(OpRes.opres_success);
    }
示例#4
0
    public override OpRes doGrantBenefit(object param, GMUser user)
    {
        ParamGrant p     = (ParamGrant)param;
        int        count = 0;

        try
        {
            count = Convert.ToInt32(p.m_grantParam);
        }
        catch (System.Exception ex)
        {
            return(OpRes.op_res_param_not_valid);
        }

        //if (count <= 0)
        //  return OpRes.op_res_failed;

        if (p.m_target == GrantTarget.grant_target_someone)
        {
            OpRes res = addReardToPlayerList(p, count, (int)GrantType.gran_type_ticket, user);
            if (res == OpRes.opres_success)
            {
                OpLogMgr.getInstance().addLog(LogType.LOG_TYPE_ADD_BENEFIT_GIFT, new ParamAddBenefitGift(p.m_successPlayer, count, (int)GrantTarget.grant_target_someone, 0), user);
            }
            return(res);
        }

        int level = 1;

        if (p.m_level != "")
        {
            try
            {
                // 转至level
                level = Convert.ToInt32(p.m_level);
                if (level <= 0)
                {
                    level = 1;
                }
            }
            catch (System.Exception ex)
            {
                return(OpRes.op_res_failed);
            }
        }
#if _OLD_BENEFIT_
        IMongoQuery   imq       = getLevelImq(p.m_target == GrantTarget.grant_target_vip, level);
        List <string> guid_list = new List <string>();
        initBenefit(p.m_target == GrantTarget.grant_target_vip, user, imq, getPlatformName(p.m_platIndex));
        bool run = nextPlayerGUIDList(user, 1000, guid_list);
        while (run)
        {
            for (int i = 0; i < guid_list.Count; i++)
            {
                DBAddBenefit tmp = new DBAddBenefit();
                tmp.m_playerGUID = guid_list[i];
                tmp.m_grantType  = (int)GrantType.gran_type_ticket;
                tmp.m_count      = count;
                addBenefitToDB(tmp, user);
            }
            guid_list.Clear();
            run = nextPlayerGUIDList(user, 1000, guid_list);
        }
#else
        DBAddBenefit tmp = new DBAddBenefit();
        tmp.m_grantType = (int)GrantType.gran_type_ticket;
        tmp.m_count     = count;
        addFullBenefitToDB(tmp, user, p.m_platIndex);
#endif

        OpLogMgr.getInstance().addLog(LogType.LOG_TYPE_ADD_BENEFIT_GIFT,
                                      new ParamAddBenefitGift("", count, (int)p.m_target, level, getPlatformName(p.m_platIndex, false)), user);
        return(OpRes.opres_success);
    }