Esempio n. 1
0
        public override bool TakeAction()
        {
            if (_chatType == ChatType.Guild && string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9203_ChaTypeNotGuildMember;
                return(false);
            }

            //查找背包中的聊天道具
            var chatLeng    = ConfigEnvSet.GetInt("Chat.ContentLeng");
            int chatItemId  = ConfigEnvSet.GetInt("UserItem.ChatItemID");
            int charItemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, chatItemId);

            //判断是否有聊天道具
            if (charItemNum <= 0)
            {
                ErrorCode = 3;
                ErrorInfo = LanguageManager.GetLang().St9203_ItemEmpty;
                return(false);
            }

            if (_content.IndexOf("<label") >= 0 || _content.IndexOf("<image") >= 0)
            {
                chatLeng += 150;
            }
            if (_content.Trim().Length == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_contentNotEmpty;
                return(false);
            }
            //LogHelper.WriteError(string.Format("contentLength={0};length={1};content={2}", _content.Length, chatLeng, _content));
            if (_content.Length >= chatLeng)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9201_TheInputTextTooLong;
                return(false);
            }

            if (!TjxChatService.IsAllow(ContextUser, _chatType))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St9203_ChatNotSend;
                return(false);
            }

            NoviceHelper.WingFestival(ContextUser.UserID, _content);
            NoviceHelper.WingZhongYuanFestival(ContextUser, _content);
            //使用聊天道具
            UserItemHelper.UseUserItem(ContextUser.UserID, chatItemId, 1);
            var chatService = new TjxChatService(ContextUser);

            chatService.Send(_chatType, _content);

            return(true);
        }
Esempio n. 2
0
        public override bool TakeAction()
        {
            var chatService = new TjxChatService(ContextUser);

            _currVersion           = chatService.CurrVersion;
            _chatArray             = chatService.Receive();
            ContextUser.ChatVesion = _currVersion;
            //查找背包中的聊天道具
            int chatItemId = ConfigEnvSet.GetInt("UserItem.ChatItemID");

            _charItemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, chatItemId);
            return(true);
        }
Esempio n. 3
0
        public override void BuildPacket()
        {
            this.PushIntoStack(pageCount);
            this.PushIntoStack(useritemList.Count);
            foreach (var item in useritemList)
            {
                ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(item.ItemID);
                itemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, item.ItemID);
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(item.UserItemID.ToNotNullString());
                dsItem.PushIntoStack(item.ItemID);
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString());
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack(itemNum);
                dsItem.PushIntoStack(itemInfo == null ? 0 : itemInfo.EffectNum);

                this.PushIntoStack(dsItem);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 检查是否完成
        /// 1.对话任务=>直接更新成可完成
        /// 2.副本战斗=>战斗结束需要回写玩家任务表目标数量
        /// </summary>
        public static void CheckStoryCompleted(string userID)
        {
            List <UserTask> userTaskList = new GameDataCacheSet <UserTask>().FindAll(userID, m => m.TaskType < TaskType.Daily && (m.TaskState == TaskState.Taked || m.TaskState == TaskState.NoTake));

            foreach (UserTask userTask in userTaskList)
            {
                StoryTaskInfo taskInfo = new ConfigCacheSet <StoryTaskInfo>().FindKey(userTask.TaskID);

                if (taskInfo == null)
                {
                    continue;
                }

                if (userTask.TaskState == TaskState.NoTake)
                {
                    GameUser gameUser = new GameDataCacheSet <GameUser>().FindKey(userID);
                    short    lv       = gameUser == null ? (short)0 : gameUser.UserLv;
                    userTask.TaskState = taskInfo.TaskLv <= lv ? TaskState.AllowTake : TaskState.NoTake;
                    //userTask.Update();
                    continue;
                }

                bool isUpdate = false;
                switch (taskInfo.TermsType)
                {
                case PlotTermsType.Shouji:
                case PlotTermsType.Delivery:
                    int currNum = UserItemHelper.CheckItemNum(userID, taskInfo.TargetItemID);
                    if (currNum >= taskInfo.TargetItemNum)
                    {
                        userTask.TaskState = TaskState.Completed;
                        isUpdate           = true;
                    }
                    break;

                case PlotTermsType.StoryBattle:
                    var userPlot = UserPlotHelper.GetUserPlotInfo(userID, taskInfo.PlotID);
                    if (userPlot != null && userPlot.PlotStatus == PlotStatus.Completed)
                    {
                        userTask.TaskState = TaskState.Completed;
                        isUpdate           = true;
                    }
                    break;

                case PlotTermsType.Battle:
                    string[] monsterNumList = taskInfo.TargetMonsterNum.ToNotNullString().Split(new[] { ',' });
                    string[] userNumList    = userTask.TaskTargetNum.ToNotNullString().Split(new[] { ',' });
                    bool     flag           = true;
                    for (int i = 0; i < monsterNumList.Length; i++)
                    {
                        int mNum = monsterNumList[i].ToInt();
                        int uNum = userNumList.Length > 0 ? userNumList[i].ToInt() : 0;
                        if (uNum < mNum)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        userTask.TaskState = TaskState.Completed;
                        isUpdate           = true;
                    }
                    break;

                case PlotTermsType.Dialogue:
                    userTask.TaskState = TaskState.Completed;
                    isUpdate           = true;
                    break;

                default:
                    break;
                }
                if (isUpdate)
                {
                    //userTask.Update();
                }
            }
        }
Esempio n. 5
0
        public override void BuildPacket()
        {
            int rankID = 0;

            this.PushIntoStack(userTaskList.Count);
            foreach (UserTask userTask in userTaskList)
            {
                SaveLog("任务ID:" + userTask.TaskID + ", 任务排行:" + MathUtils.Addition(rankID, 1));
                StoryTaskInfo taskInfo           = new ConfigCacheSet <StoryTaskInfo>().FindKey(userTask.TaskID);
                CityNpcInfo   reNpcInfo          = null;
                CityNpcInfo   deNpcInfo          = null;
                PlotInfo      plotInfo           = null;
                PlotNPCInfo   npcInfo            = null;
                ItemBaseInfo  itemInfo           = null;
                string[]      monsterList        = new string[0];
                string[]      monsterNumList     = new string[0];
                string[]      monsterCurrNumList = new string[0];
                if (taskInfo != null)
                {
                    reNpcInfo          = new ConfigCacheSet <CityNpcInfo>().FindKey(taskInfo.ReleaseNpcID);
                    deNpcInfo          = new ConfigCacheSet <CityNpcInfo>().FindKey(taskInfo.DeliveryNpcID);
                    plotInfo           = new ConfigCacheSet <PlotInfo>().FindKey(taskInfo.PlotID);
                    npcInfo            = new ConfigCacheSet <PlotNPCInfo>().FindKey(taskInfo.PlotNpcID);
                    itemInfo           = new ConfigCacheSet <ItemBaseInfo>().FindKey(taskInfo.TargetItemID);
                    monsterList        = taskInfo.TargetMonsterID.ToNotNullString().Split(new char[] { ',' });
                    monsterNumList     = taskInfo.TargetMonsterNum.ToNotNullString().Split(new char[] { ',' });
                    monsterCurrNumList = userTask.TaskTargetNum.ToNotNullString().Split(new char[] { ',' });
                }

                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.TaskID);
                dsItem.PushIntoStack(taskInfo == null ? string.Empty : taskInfo.TaskName.ToNotNullString());
                dsItem.PushIntoStack(taskInfo == null ? LanguageManager.GetLang().shortInt : taskInfo.TaskLv);
                dsItem.PushIntoStack((short)userTask.TaskState);
                dsItem.PushIntoStack(taskInfo == null ? string.Empty : taskInfo.TaskDescp.ToNotNullString());
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.ReleaseNpcID);
                dsItem.PushIntoStack(reNpcInfo == null ? string.Empty : reNpcInfo.NpcName.ToNotNullString());
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.DeliveryNpcID);
                dsItem.PushIntoStack(deNpcInfo == null ? string.Empty : deNpcInfo.NpcName.ToNotNullString());
                dsItem.PushIntoStack(taskInfo == null ? LanguageManager.GetLang().shortInt : (short)taskInfo.TermsType);

                dsItem.PushIntoStack(plotInfo != null ? plotInfo.CityID : 0);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.PlotID);
                dsItem.PushIntoStack(plotInfo != null ? (short)plotInfo.PlotType : (short)0);
                dsItem.PushIntoStack(plotInfo != null ? plotInfo.PlotName.ToNotNullString() : string.Empty);
                dsItem.PushIntoStack(npcInfo == null ? string.Empty : npcInfo.NpcName.ToNotNullString());

                dsItem.PushIntoStack(monsterList.Length);
                for (int i = 0; i < monsterList.Length; i++)
                {
                    int         monsterID   = monsterList[i].ToInt();
                    int         monsterNum  = monsterNumList[i].ToInt();
                    int         currNum     = monsterCurrNumList.Length > i ? monsterCurrNumList[i].ToInt() : 0;
                    MonsterInfo monsterInfo = new ConfigCacheSet <MonsterInfo>().FindKey(monsterID);

                    DataStruct dsItem1 = new DataStruct();
                    dsItem1.PushIntoStack(monsterInfo != null ? monsterInfo.GeneralName.ToNotNullString() : string.Empty);
                    dsItem1.PushIntoStack(monsterNum);
                    dsItem1.PushIntoStack(currNum);
                    dsItem.PushIntoStack(dsItem1);
                }

                dsItem.PushIntoStack(itemInfo != null ? itemInfo.ItemName.ToNotNullString() : string.Empty);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.TargetItemNum);
                dsItem.PushIntoStack(UserItemHelper.CheckItemNum(ContextUser.UserID, taskInfo == null ? 0 : taskInfo.TargetItemID));
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.Experience);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.GameCoin);

                this.PushIntoStack(dsItem);
            }
        }
Esempio n. 6
0
        public override bool TakeAction()
        {
            DialHelper.CheckDialNum(ContextUser.UserID);
            UserDial userDial = new PersonalCacheStruct <UserDial>().FindKey(ContextUser.UserID);

            if (userDial == null || string.IsNullOrEmpty(userDial.UserItemID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ops == 1)
            {
                string errContent = string.Empty;
                if (UserPackHelper.PackIsFull(ContextUser, BackpackType.BeiBao, 0, out errContent))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = errContent;
                    return(false);
                }
                int itemid   = UserItemHelper.GetUserItemInfoID(ContextUser.UserID, userDial.UserItemID);
                var itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(itemid);
                if (itemInfo == null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough;
                    return(false);
                }
                // 根据宝箱取得该宝箱对应的钥匙ID
                int itemNum = UserItemHelper.CheckItemNum(ContextUser.UserID, itemInfo.EffectNum);
                if (itemNum <= 0)
                {
                    ItemBaseInfo itemKey = new ShareCacheStruct <ItemBaseInfo>().FindKey(itemInfo.EffectNum);
                    if (itemKey == null)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1107_UserItemNotEnough;
                        return(false);
                    }
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_ChestKeyNotEnough, itemKey.ItemName);
                    return(false);
                }
                UserItemHelper.UseUserItem(ContextUser.UserID, itemid, 1);
                UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.EffectNum, 1);
                postion = DialHelper.ChestDialPrizePostion(ContextUser);
                postion = MathUtils.Addition(postion, (short)1);

                // 是否还可以继续使用
                //var package = UserItemPackage.Get(ContextUser.UserID);
                bool hasBox = UserItemHelper.IsEnoughBeiBaoItem(ContextUser.UserID, itemid, 1);
                bool hasKey = UserItemHelper.IsEnoughBeiBaoItem(ContextUser.UserID, itemInfo.EffectNum, 1);
                // 如果钥匙和宝箱的数各 >= 1
                if (hasBox && hasKey)
                {
                    hasNextBox = 1;
                }
            }

            //int useGold = 0;
            //if (ops == 1)
            //{
            //    //if (!DialHelper.IsDialFree(ContextUser.UserID))
            //    //{
            //    //    ErrorCode = LanguageManager.GetLang().ErrorCode;
            //    //    ErrorInfo = LanguageManager.GetLang().St12004_FreeNotEnough;
            //    //    return false;
            //    //}
            //}
            //else if (ops == 2)
            //{
            //    useGold = GameConfigSet.SweepstakesRequiredGold;
            //    ErrorCode = ops;
            //    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_SpendSparDraw, useGold, 1);
            //    return false;
            //}
            //else if (ops == 3)
            //{
            //    if (DialHelper.IsDialFree(ContextUser.UserID))
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St12004_FreeNumEnough;
            //        return false;
            //    }
            //    useGold = GameConfigSet.SweepstakesRequiredGold;
            //    if (ContextUser.GoldNum < useGold)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
            //        return false;
            //    }
            //    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
            //}
            //else if (ops == 4)
            //{
            //    useGold = GameConfigSet.FiveRequiredGold;
            //    ErrorCode = ops;
            //    ErrorInfo = string.Format(LanguageManager.GetLang().St12004_SpendSparDraw, useGold, 5);
            //    return false;
            //}
            //else if (ops == 5)
            //{
            //    if (DialHelper.IsDialFree(ContextUser.UserID))
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St12004_FreeNumEnough;
            //        return false;
            //    }
            //    useGold = GameConfigSet.FiveRequiredGold;
            //    if (ContextUser.GoldNum < useGold)
            //    {
            //        ErrorCode = LanguageManager.GetLang().ErrorCode;
            //        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
            //        return false;
            //    }
            //    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold);
            //}
            //ErrorCode = ops;
            //postion = DialHelper.DialPrizePostion(ContextUser.UserID, ops);
            //postion = MathUtils.Addition(postion, (short)1);
            return(true);
        }
Esempio n. 7
0
        public override void BuildPacket()
        {
            this.PushIntoStack(_userTaskList.Count);
            foreach (UserTask userTask in _userTaskList)
            {
                StoryTaskInfo taskInfo = new ShareCacheStruct <StoryTaskInfo>().FindKey(userTask.TaskID);
                //CityNpcInfo reNpcInfo = new ShareCacheStruct<CityNpcInfo>().FindKey(taskInfo.ReleaseNpcID);

                CityNpcInfo  deNpcInfo          = null;
                PlotInfo     plotInfo           = null;
                PlotNPCInfo  npcInfo            = null;
                ItemBaseInfo itemInfo           = null;
                string[]     monsterList        = new string[0];
                string[]     monsterNumList     = new string[0];
                string[]     monsterCurrNumList = new string[0];
                if (taskInfo != null)
                {
                    deNpcInfo          = new ShareCacheStruct <CityNpcInfo>().FindKey(taskInfo.DeliveryNpcID);
                    plotInfo           = new ShareCacheStruct <PlotInfo>().FindKey(taskInfo.PlotID);
                    npcInfo            = new ShareCacheStruct <PlotNPCInfo>().FindKey(taskInfo.PlotNpcID);
                    itemInfo           = new ShareCacheStruct <ItemBaseInfo>().FindKey(taskInfo.TargetItemID);
                    monsterList        = taskInfo.TargetMonsterID.ToNotNullString().Split(new char[] { ',' });
                    monsterNumList     = taskInfo.TargetMonsterNum.ToNotNullString().Split(new char[] { ',' });
                    monsterCurrNumList = userTask.TaskTargetNum.ToNotNullString().Split(new char[] { ',' });
                }

                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.TaskID);
                dsItem.PushIntoStack(taskInfo == null ? string.Empty : taskInfo.TaskName.ToNotNullString());
                dsItem.PushIntoStack((short)userTask.TaskState);
                dsItem.PushIntoStack(taskInfo == null ? LanguageManager.GetLang().shortInt : (short)taskInfo.TaskType);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.ReleaseNpcID);
                dsItem.PushIntoStack(taskInfo == null ? LanguageManager.GetLang().shortInt : (short)taskInfo.TermsType);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.DeliveryNpcID);
                dsItem.PushIntoStack(deNpcInfo == null ? string.Empty : deNpcInfo.NpcName.ToNotNullString());

                dsItem.PushIntoStack(plotInfo == null ? 0 : plotInfo.CityID);
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.PlotID);
                dsItem.PushIntoStack(plotInfo == null ? string.Empty : plotInfo.PlotName.ToNotNullString());
                dsItem.PushIntoStack(npcInfo == null ? string.Empty : npcInfo.NpcName.ToNotNullString());


                dsItem.PushIntoStack(monsterList.Length);
                for (int i = 0; i < monsterList.Length; i++)
                {
                    int         monsterID   = monsterList[i].ToInt();
                    int         monsterNum  = monsterNumList[i].ToInt();
                    int         currNum     = monsterCurrNumList.Length > i ? monsterCurrNumList[i].ToInt() : 0;
                    MonsterInfo monsterInfo = new ShareCacheStruct <MonsterInfo>().FindKey(monsterID);

                    DataStruct dsItem1 = new DataStruct();
                    dsItem1.PushIntoStack(monsterInfo != null ? monsterInfo.GeneralName.ToNotNullString() : string.Empty);
                    dsItem1.PushIntoStack(monsterNum);
                    dsItem1.PushIntoStack(currNum);
                    dsItem.PushIntoStack(dsItem1);
                }

                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString());
                dsItem.PushIntoStack(taskInfo == null ? 0 : taskInfo.TargetItemNum);
                dsItem.PushIntoStack(UserItemHelper.CheckItemNum(ContextUser.UserID, taskInfo == null ? 0 : taskInfo.TargetItemID));
                this.PushIntoStack(dsItem);
            }
        }