Example #1
0
        public static int GiveRoleShareAward(GameClient client)
        {
            int ret = 0;

            if (ShareManager.CanGetShareAward(client))
            {
                if (Global.CanAddGoodsDataList(client, ShareManager.ShareGoodslist))
                {
                    List <GoodsData> goodlist = ShareManager.ShareGoodslist;
                    foreach (GoodsData item in goodlist)
                    {
                        Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, item.GCount, item.Quality, "", item.Forge_level, item.Binding, 0, "", true, 1, "分享", "1900-01-01 12:00:00", item.AddPropIndex, item.BornIndex, item.Lucky, item.Strong, item.ExcellenceInfo, item.AppendPropLev, item.ChangeLifeLevForEquip, item.WashProps, null, 0, true);
                    }
                    Global.SaveRoleParamsStringToDB(client, "DailyShare", string.Format("{0},{1}", TimeUtil.NowDateTime().DayOfYear, 1), true);
                    client.ClientData.AddAwardRecord(RoleAwardMsg.FenXiang, goodlist, false);
                    GameManager.ClientMgr.NotifyGetAwardMsg(client, RoleAwardMsg.FenXiang, "");
                }
                else
                {
                    ret = -3;
                }
            }
            else if (!ShareManager.HasDoneShare(client))
            {
                ret = -1;
            }
            else
            {
                ret = -2;
            }
            return(ret);
        }
Example #2
0
        public static TCPProcessCmdResults ProcessShareCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int resoult = 0;
                int extdata = 0;
                switch (nID)
                {
                case 663:
                    ShareManager.UpdateRoleShareState(client);
                    if (ShareManager.HasDoneShare(client))
                    {
                        if (ShareManager.CanGetShareAward(client))
                        {
                            extdata = 1;
                        }
                        else
                        {
                            extdata = 2;
                        }
                    }
                    else
                    {
                        extdata = 0;
                    }
                    break;

                case 664:
                    resoult = ShareManager.GiveRoleShareAward(client);
                    if (resoult == 0 || resoult == -2)
                    {
                        extdata = 2;
                    }
                    else if (resoult == -1)
                    {
                        extdata = 0;
                    }
                    else
                    {
                        extdata = 1;
                    }
                    break;

                case 665:
                    if (ShareManager.HasDoneShare(client))
                    {
                        if (ShareManager.CanGetShareAward(client))
                        {
                            extdata = 1;
                        }
                        else
                        {
                            extdata = 2;
                        }
                    }
                    else
                    {
                        extdata = 0;
                    }
                    break;
                }
                string strcmd = string.Format("{0}:{1}", resoult, extdata);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessShareCMD", false, false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }