Ejemplo n.º 1
0
        public static int SendAward(DBManager dbMgr, int roleID, int awardID)
        {
            FacebookAwardData awardData = FacebookManager.getFacebookAward(awardID);
            int result;

            if (awardData == null)
            {
                result = -6;
            }
            else
            {
                if (awardData.OnlyNum > 0)
                {
                    int totalNum = DBQuery.FacebookOnlyNum(dbMgr, roleID, awardID);
                    if (totalNum > 0)
                    {
                        return(-5);
                    }
                }
                if (awardData.DayMaxNum > 0)
                {
                    int totalNum = DBQuery.FacebookDayNum(dbMgr, roleID, awardID);
                    if (totalNum >= awardData.DayMaxNum)
                    {
                        return(-5);
                    }
                }
                string mailGoodsString = "";
                if (null != awardData.AwardGoods)
                {
                    foreach (GoodsData goods in awardData.AwardGoods)
                    {
                        int useCount = goods.GCount;
                        mailGoodsString += string.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_{10}_{11}_{12}_{13}_{14}_{15}", new object[]
                        {
                            goods.GoodsID,
                            goods.Forge_level,
                            goods.Quality,
                            goods.Props,
                            useCount,
                            0,
                            0,
                            goods.Jewellist,
                            goods.AddPropIndex,
                            goods.Binding,
                            goods.BornIndex,
                            goods.Lucky,
                            goods.Strong,
                            goods.ExcellenceInfo,
                            goods.AppendPropLev,
                            goods.ChangeLifeLevForEquip
                        });
                        if (mailGoodsString.Length > 0)
                        {
                            mailGoodsString += "|";
                        }
                    }
                }
                string[] fields = new string[]
                {
                    "-1",
                    awardData.MailUser,
                    roleID.ToString(),
                    "",
                    awardData.MailTitle.ToString(),
                    awardData.MailContent.ToString(),
                    "0",
                    "0",
                    "0",
                    mailGoodsString
                };
                int addGoodsCount = 0;
                int mailID        = Global.AddMail(dbMgr, fields, out addGoodsCount);
                if (mailID > 0)
                {
                    string gmCmd     = string.Format("{0}|{1}", roleID.ToString(), mailID);
                    string gmCmdData = string.Format("-notifymail {0}", gmCmd);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                    result = mailID;
                }
                else
                {
                    result = -8;
                }
            }
            return(result);
        }