public string ProcRoleGetAward(GameClient client, int awardid)
        {
            JieriGiveErrorCode ec = JieriGiveErrorCode.Success;

            if (!this.InAwardTime())
            {
                ec = JieriGiveErrorCode.NotAwardTime;
            }
            else if (!this.HasEnoughBagSpaceForAwardGoods(client, awardid))
            {
                ec = JieriGiveErrorCode.NoBagSpace;
            }
            else
            {
                AwardItem           allItem  = null;
                AwardItem           occItem  = null;
                AwardEffectTimeItem timeItem = null;
                if (!this.allAwardDict.TryGetValue(awardid, out allItem) || !this.occAwardDict.TryGetValue(awardid, out occItem) || !this.timeAwardDict.TryGetValue(awardid, out timeItem))
                {
                    ec = JieriGiveErrorCode.ConfigError;
                }
                else
                {
                    lock (this._allMemberMutex)
                    {
                        JieriGiveKingItemData myData = this.GetClientGiveKingInfo(client);
                        if (myData == null || myData.TotalGive < allItem.MinAwardCondionValue || myData.GetAwardTimes > 0 || myData.Rank != awardid)
                        {
                            ec = JieriGiveErrorCode.NotMeetAwardCond;
                            goto IL_1CB;
                        }
                        string   dbReq = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, this.FromDate.Replace(':', '$'), this.ToDate.Replace(':', '$'));
                        string[] dbRsp = Global.ExecuteDBCmd(13205, dbReq, client.ServerId);
                        if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0)
                        {
                            ec = JieriGiveErrorCode.DBFailed;
                            goto IL_1CB;
                        }
                        myData.GetAwardTimes = 1;
                    }
                    if (!base.GiveAward(client, allItem) || !base.GiveAward(client, occItem) || !base.GiveEffectiveTimeAward(client, timeItem.ToAwardItem()))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("发送节日赠送王奖励的时候,发送失败,但是设置领奖成功,roleid={0}, rolename={1}, awardid={3}", client.ClientData.RoleID, client.ClientData.RoleName, awardid), null, true);
                    }
                    ec = JieriGiveErrorCode.Success;
                }
            }
IL_1CB:
            if (ec == JieriGiveErrorCode.Success)
            {
                if (client._IconStateMgr.CheckJieriGiveKing(client))
                {
                    client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }
            }
            return(string.Format("{0}:{1}", (int)ec, awardid));
        }
Beispiel #2
0
        // 客户端请求领取奖励 return `ec:awardid`
        public string ProcRoleGetAward(GameClient client, int awardid)
        {
            JieriGiveErrorCode ec = JieriGiveErrorCode.Success;

            do
            {
                if (!InAwardTime())
                {
                    ec = JieriGiveErrorCode.NotAwardTime;
                    break;
                }

                if (!HasEnoughBagSpaceForAwardGoods(client, awardid))
                {
                    ec = JieriGiveErrorCode.NoBagSpace;
                    break;
                }

                AwardItem           allItem = null, occItem = null;
                AwardEffectTimeItem timeItem = null;
                if (!allAwardDict.TryGetValue(awardid, out allItem) || !occAwardDict.TryGetValue(awardid, out occItem) ||
                    !timeAwardDict.TryGetValue(awardid, out timeItem))
                {
                    ec = JieriGiveErrorCode.ConfigError;
                    break;
                }

                lock (_allMemberMutex)
                {
                    JieriGiveKingItemData myData = GetClientGiveKingInfo(client);
                    if (myData == null || myData.TotalGive < allItem.MinAwardCondionValue || myData.GetAwardTimes > 0 || myData.Rank != awardid)
                    {
                        ec = JieriGiveErrorCode.NotMeetAwardCond;
                        break;
                    }
                    string   dbReq = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, FromDate.Replace(':', '$'), ToDate.Replace(':', '$'));
                    string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_GET_JIERI_GIVE_KING_AWARD, dbReq, client.ServerId);
                    if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0)
                    {
                        ec = JieriGiveErrorCode.DBFailed;
                        break;
                    }

                    myData.GetAwardTimes = 1;
                }

                if (!GiveAward(client, allItem) || !GiveAward(client, occItem) || !GiveEffectiveTimeAward(client, timeItem.ToAwardItem()))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发送节日赠送王奖励的时候,发送失败,但是设置领奖成功,roleid={0}, rolename={1}, awardid={3}", client.ClientData.RoleID, client.ClientData.RoleName, awardid));
                }
                ec = JieriGiveErrorCode.Success;
            } while (false);

            if (ec == JieriGiveErrorCode.Success)
            {
                if (client._IconStateMgr.CheckJieriGiveKing(client))
                {
                    client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }
            }

            return(string.Format("{0}:{1}", (int)ec, awardid));
        }
Beispiel #3
0
        // 客户端请求赠送物品给对方 return `ec:totalgive:totalrecv:awardflag`
        public string ProcRoleGiveToOther(GameClient client, string receiverRolename, int goodsID, int goodsCnt)
        {
            int receiverRoleid    = -1;
            JieriGiveErrorCode ec = JieriGiveErrorCode.Success;

            do
            {
                if (!InActivityTime())
                {
                    ec = JieriGiveErrorCode.ActivityNotOpen;
                    break;
                }

                if (string.IsNullOrEmpty(receiverRolename) || receiverRolename == client.ClientData.RoleName)
                {
                    ec = JieriGiveErrorCode.ReceiverCannotSelf;
                    break;
                }

                if (!IsGiveGoodsID(goodsID))
                {
                    ec = JieriGiveErrorCode.GoodsIDError;
                    break;
                }

                if (goodsCnt <= 0 || Global.GetTotalGoodsCountByID(client, goodsID) < goodsCnt)
                {
                    ec = JieriGiveErrorCode.GoodsNotEnough;
                    break;
                }

                string   dbReq = string.Format("{0}:{1}:{2}:{3}", client.ClientData.RoleID, receiverRolename, goodsID, goodsCnt);
                string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_ROLE_JIERI_GIVE_TO_OTHER, dbReq, client.ServerId);
                if (dbRsp == null || dbRsp.Length != 1)
                {
                    ec = JieriGiveErrorCode.DBFailed;
                    break;
                }

                receiverRoleid = Convert.ToInt32(dbRsp[0]);
                if (receiverRoleid == -1)
                {
                    ec = JieriGiveErrorCode.ReceiverNotExist;
                    break;
                }
                else if (receiverRoleid <= 0)
                {
                    ec = JieriGiveErrorCode.DBFailed;
                    break;
                }

                bool bUsedBinding_just_placeholder = false, bUsedTimeLimited_just_placeholder = false;
                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsID, goodsCnt, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder))
                {
                    ec = JieriGiveErrorCode.GoodsNotEnough;
                    break;
                }

                ec = JieriGiveErrorCode.Success;
            } while (false);

            RoleGiveRecvInfo info = GetRoleGiveRecvInfo(client.ClientData.RoleID);

            if (ec == JieriGiveErrorCode.Success)
            {
                // 增加自己的赠送数量
                lock (info)
                {
                    info.TotalGive += goodsCnt;
                }

                // 检测自己是否需要刷新节日赠送图标
                if (client._IconStateMgr.CheckJieriGive(client))
                {
                    client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }

                // 触发节日赠送王活动
                JieRiGiveKingActivity gkActivity = HuodongCachingMgr.GetJieriGiveKingActivity();
                if (gkActivity != null)
                {
                    gkActivity.OnGive(client, goodsID, goodsCnt);
                }

                /*
                 * // 增加对方的接收数量
                 * RoleGiveRecvInfo otherInfo = GetRoleGiveRecvInfo(receiverRoleid);
                 * lock (otherInfo)
                 * {
                 *  otherInfo.TotalRecv += goodsCnt;
                 * }*/

                // 触发节日收取活动
                JieriRecvActivity recvAct = HuodongCachingMgr.GetJieriRecvActivity();
                if (recvAct != null)
                {
                    recvAct.OnRecv(receiverRoleid, goodsCnt);
                }

                // 触发节日收取王活动
                JieRiRecvKingActivity rkActivity = HuodongCachingMgr.GetJieriRecvKingActivity();
                if (rkActivity != null)
                {
                    rkActivity.OnRecv(receiverRoleid, goodsID, goodsCnt, client.ServerId);
                }

                //根据瑞祥需求,赠送后,直接扣除,并不把物品给对方
            }

            lock (info)
            {
                return(string.Format("{0}:{1}:{2}:{3}", (int)ec, info.TotalGive, info.TotalRecv, info.AwardFlag));
            }
        }
Beispiel #4
0
        // 返回 ec:totalgive:totalrecv:awardflag
        public string ProcRoleGetAward(GameClient client, int awardid)
        {
            JieriGiveErrorCode ec = JieriGiveErrorCode.Success;

            do
            {
                if (!InAwardTime())
                {
                    ec = JieriGiveErrorCode.NotAwardTime;
                    break;
                }

                if (!HasEnoughBagSpaceForAwardGoods(client, awardid))
                {
                    ec = JieriGiveErrorCode.NoBagSpace;
                    break;
                }

                AwardItem           allItem = null, occItem = null;
                AwardEffectTimeItem timeItem = null;
                if (!allAwardDict.TryGetValue(awardid, out allItem) || !occAwardDict.TryGetValue(awardid, out occItem) ||
                    !timeAwardDict.TryGetValue(awardid, out timeItem))
                {
                    ec = JieriGiveErrorCode.ConfigError;
                    break;
                }

                RoleGiveRecvInfo info = GetRoleGiveRecvInfo(client.ClientData.RoleID);
                // 注意,这里可以不用所info,因为TotalGive和AwardFlag只能由玩家自己操作
                if (!IsReachConition(info, allItem.MinAwardCondionValue) || (info.AwardFlag & (1 << awardid)) != 0)
                {
                    ec = JieriGiveErrorCode.NotMeetAwardCond;
                    break;
                }

                int newAwardFlag = info.AwardFlag | (1 << awardid);
                // 天数信息直接取info中保存的,防止查询的和领取时恰好跨天
                string   dbReq = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", client.ClientData.RoleID, info.TodayStart.Replace(':', '$'), info.TodayEnd.Replace(':', '$'), ActivityType, info.TodayIdxInActPeriod, newAwardFlag);
                string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_SPR_GET_JIERI_GIVE_AWARD, dbReq, client.ServerId);
                if (dbRsp == null || dbRsp.Length < 1 || Convert.ToInt32(dbRsp[0]) <= 0)
                {
                    ec = JieriGiveErrorCode.DBFailed;
                    break;
                }

                info.AwardFlag = newAwardFlag;
                if (!GiveAward(client, allItem) || !GiveAward(client, occItem) || !GiveEffectiveTimeAward(client, timeItem.ToAwardItem()))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("节日赠送活动奖品发送失败,但是已经设置为已发放,roleid={0}, rolename={1}, awardid={3}", client.ClientData.RoleID, client.ClientData.RoleName, awardid));
                }

                ec = JieriGiveErrorCode.Success;
            } while (false);

            // 检查更新图标
            if (ec == JieriGiveErrorCode.Success)
            {
                FlushIcon(client);
            }

            return(string.Format("{0}:{1}", (int)ec, awardid));
        }
Beispiel #5
0
        public string ProcRoleGiveToOther(GameClient client, string receiverRolename, int goodsID, int goodsCnt)
        {
            int receiverRoleid    = -1;
            JieriGiveErrorCode ec = JieriGiveErrorCode.Success;

            if (!this.InActivityTime())
            {
                ec = JieriGiveErrorCode.ActivityNotOpen;
            }
            else if (string.IsNullOrEmpty(receiverRolename) || receiverRolename == client.ClientData.RoleName)
            {
                ec = JieriGiveErrorCode.ReceiverCannotSelf;
            }
            else if (!base.IsGiveGoodsID(goodsID))
            {
                ec = JieriGiveErrorCode.GoodsIDError;
            }
            else if (goodsCnt <= 0 || Global.GetTotalGoodsCountByID(client, goodsID) < goodsCnt)
            {
                ec = JieriGiveErrorCode.GoodsNotEnough;
            }
            else
            {
                string dbReq = string.Format("{0}:{1}:{2}:{3}", new object[]
                {
                    client.ClientData.RoleID,
                    receiverRolename,
                    goodsID,
                    goodsCnt
                });
                string[] dbRsp = Global.ExecuteDBCmd(13200, dbReq, client.ServerId);
                if (dbRsp == null || dbRsp.Length != 1)
                {
                    ec = JieriGiveErrorCode.DBFailed;
                }
                else
                {
                    receiverRoleid = Convert.ToInt32(dbRsp[0]);
                    if (receiverRoleid == -1)
                    {
                        ec = JieriGiveErrorCode.ReceiverNotExist;
                    }
                    else if (receiverRoleid <= 0)
                    {
                        ec = JieriGiveErrorCode.DBFailed;
                    }
                    else
                    {
                        bool bUsedBinding_just_placeholder     = false;
                        bool bUsedTimeLimited_just_placeholder = false;
                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsID, goodsCnt, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                        {
                            ec = JieriGiveErrorCode.GoodsNotEnough;
                        }
                        else
                        {
                            GameManager.logDBCmdMgr.AddMessageLog(0, Global.GetGoodsNameByID(goodsID), "节日赠送", client.ClientData.RoleName, receiverRolename, "日志", goodsCnt, client.ClientData.ZoneID, client.strUserID, receiverRoleid, client.ServerId, "");
                            ec = JieriGiveErrorCode.Success;
                        }
                    }
                }
            }
            RoleGiveRecvInfo info = base.GetRoleGiveRecvInfo(client.ClientData.RoleID);

            if (ec == JieriGiveErrorCode.Success)
            {
                lock (info)
                {
                    info.TotalGive += goodsCnt;
                }
                if (client._IconStateMgr.CheckJieriGive(client))
                {
                    client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                    client._IconStateMgr.SendIconStateToClient(client);
                }
                JieRiGiveKingActivity gkActivity = HuodongCachingMgr.GetJieriGiveKingActivity();
                if (gkActivity != null)
                {
                    gkActivity.OnGive(client, goodsID, goodsCnt);
                }
                JieriRecvActivity recvAct = HuodongCachingMgr.GetJieriRecvActivity();
                if (recvAct != null)
                {
                    recvAct.OnRecv(receiverRoleid, goodsCnt);
                }
                JieRiRecvKingActivity rkActivity = HuodongCachingMgr.GetJieriRecvKingActivity();
                if (rkActivity != null)
                {
                    rkActivity.OnRecv(receiverRoleid, goodsID, goodsCnt, client.ServerId);
                }
            }
            string result;

            lock (info)
            {
                result = string.Format("{0}:{1}:{2}:{3}", new object[]
                {
                    (int)ec,
                    info.TotalGive,
                    info.TotalRecv,
                    info.AwardFlag
                });
            }
            return(result);
        }