Пример #1
0
 public override bool TakeAction()
 {
     var package = UserItemPackage.Get(ContextUser.UserID);
     UserItemInfo useritem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID));
     if (useritem != null)
     {
         ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(useritem.ItemID);
         if (itemInfo != null && itemInfo.DemandLv > ContextUser.VipLv)
         {
             ErrorCode = LanguageManager.GetLang().ErrorCode;
             ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
             return false;
         }
     }
     ItemUseHelper itemuse = new ItemUseHelper();
     itemuse.UseItem(userItemID, Uid);
     if (itemuse.result && itemuse.content != string.Empty)
     {
         ErrorCode = 0;
     }
     if (!itemuse.result)
     {
         ErrorCode = LanguageManager.GetLang().ErrorCode;
     }
     ErrorInfo = itemuse.content.Trim(',');
     return true;
 }
Пример #2
0
        public override bool TakeAction()
        {
            StoryTaskInfo storyTask = new ShareCacheStruct<StoryTaskInfo>().FindKey(taskID);
            if (storyTask != null && storyTask.TaskLv <= ContextUser.UserLv)
            {
                UserTask userTask = new PersonalCacheStruct<UserTask>().FindKey(ContextUser.UserID, taskID);
                if (userTask != null && userTask.TaskState == TaskState.Close)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1433_RewardAlreadyReceive;
                    return false;
                }
                int collectNum = TrumpHelper.GetUserItemNum(ContextUser.UserID, storyTask.TargetItemID);
                if (collectNum < storyTask.TargetItemNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1462_ItemNumNotEnough;
                    return false;
                }
                ItemUseHelper itemuse = new ItemUseHelper();

                if (!itemuse.GeneralPrize(ContextUser, storyTask.Reward.ToList()))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1433_StoryTaskGridNotEnough;
                    return false;
                }
                if (itemuse.DoPrize(ContextUser, storyTask.Reward.ToList()))
                {
                    UserItemHelper.UseUserItem(ContextUser.UserID, storyTask.TargetItemID, storyTask.TargetItemNum);
                    if (userTask != null && userTask.TaskState != TaskState.Close)
                    {
                        userTask.TaskState = TaskState.Close;
                    }

                    if (userTask == null)
                    {
                        userTask = new UserTask
                        {
                            UserID = ContextUser.UserID,
                            TaskID = taskID,
                            TaskType = storyTask.TaskType,
                            TaskStar = TaskStar.Star5,
                            TaskState = TaskState.Close,
                            TaskTargetNum = "0",
                            CompleteNum = 0,
                            CreateDate = DateTime.Now
                        };
                        new PersonalCacheStruct<UserTask>().Add(userTask);
                    }

                    ErrorCode = 0;
                    ErrorInfo = itemuse.content.Trim(',');
                }
            }
            return true;
        }
Пример #3
0
        public override bool TakeAction()
        {
            ItemUseHelper itemuse = new ItemUseHelper();
            itemuse.UseItem(userItemID, Uid);
            if (itemuse.result && itemuse.content != string.Empty)
            {
                content = itemuse.content.Trim(',');
            }
            if (!itemuse.result)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = itemuse.content;
                return false;
            }

            // 使用还可以继续使用该礼包
            int itemid = UserItemHelper.GetUserItemInfoID(ContextUser.UserID, userItemID);
            bool hasGift = UserItemHelper.IsEnoughBeiBaoItem(ContextUser.UserID, itemid, 1);
            if (hasGift)
            {
                hasNextGift = 1;
            }
            return true;
        }