public ReqQuest FinishQuest(UserQuest quest)
    {
        ReqQuest component = new ReqQuest();

        component.FinishQuest(quest);
        return(component);
    }
Esempio n. 2
0
        public async Task <JsonResult> Data()
        {
            var user = await _udb.Users.Include(u => u.quest).SingleOrDefaultAsync(u => u.UserName == User.Identity.Name);

            if (user.quest == null)
            {
                user.quest = new UserQuest();
                await _udb.SaveChangesAsync();
            }
            var desc = new GameChoiceDescriptor(user.quest);

            return(Json(new {
                nickname = user.NickName,
                progress = user.quest.Progress,
                profession = UserQuest.ProfessionName(user.quest.Profession),
                stats = user.quest.Progress == UserQuest.GameProgress.Act1AfterChoose ? await GetProfessionStatsAsync() : null,
                isdead = user.quest.IsDead,
                deathcount = user.quest.DeathCount,
                act2choice = desc.GetAct2Choice(),
                act3choice = desc.GetAct3Choice(),
                act4choice = desc.GetAct4Choice(),
                act5choice = desc.GetAct5Choice(),
                act5bchoice = desc.GetAct5bChoice(),
                act6choice = desc.GetAct6Choice() == "true",
                question = desc.GetCurrentQuestion(),
            }));
        }
        public ActionResult AddToProfile([Bind(Include = "Quest_ID,Title,Description,ETA_ID,TopicID,isFlagged,Labors")] int?id)
        {
            //get - set user id, get - set quest ID, set UserQuest table to defualt, change quest to ACTIVE (true)
            string    userId    = User.Identity.GetUserId();
            UserQuest userquest = new UserQuest();

            userquest.Quest_ID   = (int)id;
            userquest.Id         = userId;
            userquest.isActive   = true;
            userquest.isComplete = false;
            userquest.rating     = null;
            userquest.Target     = null;

            db.UserQuests.Add(userquest);
            db.SaveChanges();

            List <Labor> LaborsToAdd = (from x in db.Labors where x.Quest_ID == id select x).ToList();

            foreach (Labor labor in LaborsToAdd)
            {
                UserLabor userlabor = new UserLabor();
                userlabor.Labor_ID    = labor.Labor_ID;
                userlabor.Id          = userId;
                userlabor.UserQuestid = userquest.UserQuestid;
                userlabor.isComplete  = false;

                db.UserLabors.Add(userlabor);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "UserQuests", new { Id = userId }));
            //return RedirectToAction("Index", "UserQuests");
        }
Esempio n. 4
0
 public void RemoveQuest(UserQuest quest)
 {
     if (this._allQuests != null)
     {
         this._allQuests.Remove(quest);
     }
 }
Esempio n. 5
0
            public string GetProgressString(IEnumerable <UserItemCount> userItems)
            {
                if (Hidden && !Satisfy(userItems))
                {
                    return("");
                }
                if (userItems.All(uic => !Related(uic)))
                {
                    return("");
                }
                StringBuilder sb = new StringBuilder();

                sb.AppendFormat("称号【{0}】:", UserQuest.ProfessionName(Title));
                foreach (var cond in NameCountMap)
                {
                    var item = userItems.FirstOrDefault(uic => uic.ItemName == cond.Key);
                    if (item != null)
                    {
                        int progress  = item.ItemCount;
                        int threshold = cond.Value;
                        if (progress > threshold)
                        {
                            progress = threshold;
                        }
                        sb.AppendFormat($"{cond.Key} {progress}/{threshold};");
                    }
                    else
                    {
                        sb.AppendFormat($"??? 0/{cond.Value};");
                    }
                }
                return(sb.ToString());
            }
Esempio n. 6
0
        public ActionResult AddToProfile([Bind(Include = "QuestID, Title, Description,TopicID,Labors")] int?id)
        {
            string    userId    = User.Identity.GetUserId();
            UserQuest userquest = new UserQuest();

            userquest.QuestID    = (int)id;
            userquest.Id         = userId;
            userquest.isActive   = true;
            userquest.isComplete = false;
            userquest.Target     = null;

            db.UserQuests.Add(userquest);
            db.SaveChanges();

            List <Labor> LaborsToAdd = (from x in db.Labors where x.QuestID == id select x).ToList();

            foreach (Labor labor in LaborsToAdd)
            {
                UserLabor userlabor = new UserLabor();
                userlabor.LaborID     = labor.LaborID;
                userlabor.Id          = userId;
                userlabor.UserQuestID = userquest.UserQuestID;
                userlabor.isComplete  = false;
                userlabor.Target      = null;

                db.UserLabors.Add(userlabor);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "UserQuests", new { Id = userId }));
        }
 public void SetUserQuest(UserQuest quest)
 {
     this.userQuest = quest;
     bool isFinished = quest.IsFinished;
     this.progressGO.SetActive(!isFinished);
     this.finishedGO.SetActive(isFinished);
     this.UpdateQuestInfo();
 }
Esempio n. 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserQuest userQuest = db.UserQuests.Find(id);

            db.UserQuests.Remove(userQuest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
 public ActionResult Edit([Bind(Include = "UserQuestid,Quest_ID,Id,isActive,isComplete,rating,Target")] UserQuest userQuest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userQuest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id       = new SelectList(db.Users, "Id", "Email", userQuest.Id); // replaced db.ApplicationUsers with db.Users
     ViewBag.Quest_ID = new SelectList(db.Quests, "Quest_ID", "Title", userQuest.Quest_ID);
     return(View(userQuest));
 }
Esempio n. 10
0
        public ActionResult Create([Bind(Include = "UserQuestID,QuestID,Id,isActive,isComplete,Target")] UserQuest userQuest)
        {
            if (ModelState.IsValid)
            {
                db.UserQuests.Add(userQuest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Id      = new SelectList(db.Users, "Id", "Email", userQuest.Id);
            ViewBag.QuestID = new SelectList(db.Quests, "QuestID", "Title", userQuest.QuestID);
            return(View(userQuest));
        }
Esempio n. 11
0
 public ActionResult Edit([Bind(Include = "UserQuestID,QuestID,Id,isActive,isComplete,Target")] UserQuest userQuest)
 {
     userQuest.Id = User.Identity.GetUserId();
     if (ModelState.IsValid)
     {
         db.Entry(userQuest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", "UserQuests", new { Id = userQuest.Id }));
     }
     ViewBag.Id      = new SelectList(db.Users, "Id", "Email", userQuest.Id);
     ViewBag.QuestID = new SelectList(db.Quests, "QuestID", "Title", userQuest.QuestID);
     return(View(userQuest));
 }
Esempio n. 12
0
        // GET: UserQuests/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserQuest userQuest = db.UserQuests.Find(id);

            if (userQuest == null)
            {
                return(HttpNotFound());
            }
            return(View(userQuest));
        }
Esempio n. 13
0
            public string GetProgressString(IEnumerable <UserItemCount> userItems)
            {
                var progress = userItems.Where(uic => this.Name.Contains(uic.ItemName)).Sum(uic => uic.ItemCount);

                if (progress == 0)
                {
                    return("");
                }
                if (progress > Count)
                {
                    progress = Count;
                }
                return($"称号【{UserQuest.ProfessionName(Title)}】: {progress}/{Count}");
            }
Esempio n. 14
0
        // GET: UserQuests/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserQuest userQuest = db.UserQuests.Include(x => x.UserLabors).Include(z => z.Quest).FirstOrDefault(q => q.UserQuestid == id);


            if (userQuest == null)
            {
                return(HttpNotFound());
            }
            return(View(userQuest));
        }
Esempio n. 15
0
        // GET: UserQuests/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserQuest userQuest = db.UserQuests.Find(id);

            if (userQuest == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id      = new SelectList(db.Users, "Id", "Email", userQuest.Id);
            ViewBag.QuestID = new SelectList(db.Quests, "QuestID", "Title", userQuest.QuestID);
            return(View(userQuest));
        }
Esempio n. 16
0
            public string GetProgressString(IEnumerable <UserItemCount> userItems)
            {
                var item = userItems.FirstOrDefault(uic => uic.ItemName == Name);

                if (item == null)
                {
                    return("");
                }
                int progress = item.ItemCount;

                if (progress > Count)
                {
                    progress = Count;
                }
                return($"称号【{UserQuest.ProfessionName(Title)}】: {progress}/{Count}");
            }
Esempio n. 17
0
            public string GetProgressString(IEnumerable <UserItemCount> userItems)
            {
                var progress = userItems.Where(i => i.ItemPool.ContainsKey(PoolName)).Sum(i => i.ItemPool[PoolName]);

                if (progress == 0)
                {
                    return("");
                }
                if (progress > Count)
                {
                    progress = Count;
                }
                var tmp = (Count > 1) ? "抽取卡池次数" : "";

                return($"称号【{UserQuest.ProfessionName(Title)}】:{tmp} {progress}/{Count}");
            }
Esempio n. 18
0
    internal void tryFinishQuest(int questid)
    {
        if (quest_dic.ContainsKey(questid))
        {
            UserQuest uq = this.quest_dic[questid];
            if (uq == null || uq.IsFinished == false)
            {
                return;
            }

            var ret = ServerRequestManager.instance.FinishQuest(uq);
            if (ret != null && ret.responseData != null && ret.responseData.eid == 0)
            {
                z.log("[完成任务成功] " + uq.title);
                refreshquestUi();
            }
        }
    }
Esempio n. 19
0
        private string BuildNickName(UserQuest.UserProfession title, string nickname, string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(string.Empty);
            }
            StringBuilder sb = new StringBuilder();

            if (title != UserQuest.UserProfession.None)
            {
                sb.AppendFormat("[{0}] ", UserQuest.ProfessionName(title));
            }
            if (string.IsNullOrEmpty(nickname))
            {
                nickname = username;
            }
            sb.Append(nickname);
            return(sb.ToString());
        }
Esempio n. 20
0
    public void UpdateQuest(UserQuestUpdater[] quests)
    {
        UpdateQuest_c__AnonStorey78 storey = new UpdateQuest_c__AnonStorey78();

        UserQuestUpdater[] updaterArray = quests;
        for (int i = 0; i < updaterArray.Length; i++)
        {
            storey.newCondition = updaterArray[i];
            UserQuest quest = this._allQuests.Find(new Predicate <UserQuest>(storey.m_4E));
            if (quest != null)
            {
                quest.UpdateCondition(storey.newCondition.condition);
                if (quest.IsFinished)
                {
                    //TutorialManager.instance.CheckTutorialTaskFinishWithQuestFinish(quest.taskCid);
                }
            }
        }
    }
Esempio n. 21
0
        public async Task <ActionResult> Revive(string choice)
        {
            var quest = await GetQuestAsync(true);

            if (!quest.IsDead)
            {
                return(BadRequest());
            }
            var profession = UserQuest.GetProfession(choice);

            if (profession == UserQuest.UserProfession.None || profession == UserQuest.UserProfession.Shiro)
            {
                return(BadRequest());
            }
            quest.Profession = profession;
            quest.IsDead     = false;
            quest.AddTitle(quest.Profession);
            await _udb.SaveChangesAsync();

            return(Json(new { success = true }));
        }
        public void AssignQuestUser(Guid userId, Guid questId)
        {
            var quest = _questQueryService.GetById(questId);

            var userQuest = new UserQuest
            {
                UserId          = userId,
                QuestId         = questId,
                UserQuestStatus = UserQuestStatus.Assigned,
                QuestСomplexity = quest.QuestСomplexity
            };

            userQuest.CreatedOn = userQuest.UpdatedOn = DateTime.UtcNow;

            using (var contextScope = ContextScopeFactory.Create())
            {
                _userQuestRepository.Insert(_mapper.Map <Faw.Models.Domain.UserQuest>(userQuest));

                contextScope.SaveChanges();
            }
        }
Esempio n. 23
0
 public void AddUserQuests(UserQuest[] quests)
 {
     if (this._allQuests == null)
     {
         this._allQuests = new List<UserQuest>();
     }
     if ((quests != null) && (quests.Length > 0))
     {
         this._allQuests.AddRange(quests.ToList<UserQuest>());
     }
     if (quests != null)
     {
         foreach (UserQuest quest in quests)
         {
             if (quest.IsFinished)
             {
                // TutorialManager.instance.CheckTutorialTaskFinishWithQuestFinish(quest.taskCid);
             }
         }
     }
 }
Esempio n. 24
0
 internal bool m_4E(UserQuest n)
 {
     return(n.taskCid == this.newCondition.taskCid);
 }
Esempio n. 25
0
 public string GetSql(UserQuest item)
 {
     return(string.Format(" [UserId]={0},[QuestAction]='{1}' Where [Id] = {2}", item.UserId, item.QuestAction, item.ID));
 }
 public ReqQuest FinishQuest(UserQuest quest)
 {
     ReqQuest component = new ReqQuest();
     component.FinishQuest(quest);
     return component;
 }
 public ReqQuest FinishQuest(UserQuest quest)
 {
     ReqQuest component = GameObjectUtil.InstantiateItemAsChildOf(this.questPrefab, base.gameObject).GetComponent<ReqQuest>();
     component.FinishQuest(quest);
     return component;
 }
Esempio n. 28
0
        public async Task <List <string> > HandleForItemsAsync(IEnumerable <GachaItem> items)
        {
            var user = await db_.Users.Include("quest").SingleOrDefaultAsync(u => u.UserName == context_.User.Identity.Name);

            if (user.quest == null)
            {
                user.quest = new UserQuest {
                    UserId = user.Id
                };
            }
            var quest            = user.quest;
            var itemCounts       = items.GroupBy(i => i.Id).ToDictionary(g => g.Key, g => new { Item = g.FirstOrDefault(), Count = g.Count() });
            var itemIds          = itemCounts.Keys;
            var allUserRareItems = await GetUserMissionItemsAsync(user);

            var bonus = new GachaBonus();

            bonus.AddExp(items.Count());
            var result = new List <string>();

            foreach (var item in itemCounts.Values)
            {
                var userItem = allUserRareItems.FirstOrDefault(i => i.ItemName == item.Item.Name);
                var conds    = userItem == null?Enumerable.Empty <IGachaTitleCondition>() : titleConditions.Where(c => c.Related(userItem)).ToList();

                if (conds.Count() > 0)
                {
                    int minBonusTimes = -1;
                    foreach (var cond in conds)
                    {
                        if (cond.Satisfy(allUserRareItems))
                        {
                            if (!quest.HasTitle(cond.Title))
                            {
                                quest.AddTitle(cond.Title);
                                result.Add(string.Format("获得称号【{0}】", UserQuest.ProfessionName(cond.Title)));
                            }

                            int bonusTimes = item.Count;
                            int threshold  = cond.GetThresholdForItem(item.Item.Name);
                            if (userItem.ItemCount - item.Count < threshold)
                            {
                                bonusTimes = userItem.ItemCount - threshold;
                            }
                            if (minBonusTimes < 0 || bonusTimes < minBonusTimes)
                            {
                                minBonusTimes = bonusTimes;
                            }
                        }
                    }
                    if (item.Item.Rarity > 1 && item.Item.Rarity < 5 && conds.All(c => c.Satisfy(allUserRareItems)))
                    {
                        bonus.IncreaseMultiple((item.Item.Rarity - 1) * 4, minBonusTimes); // r2: 4, r3: 8, r4: 12
                    }
                }
                else if (item.Item.Rarity > 1 && item.Item.Rarity < 5)
                {
                    bonus.IncreaseMultiple((item.Item.Rarity - 1) * 4, item.Count); // r2: 4, r3: 8, r4: 12
                }
                if (item.Item.Rarity >= 5)
                {
                    for (int i = 0; i < item.Count; ++i)
                    {
                        bonus.AddPointRandom(30, 50);
                    }
                }
            }
            bonus.ApplyBonus(user, expUtil_);
            await db_.SaveChangesAsync();

            result.Add(bonus.GetResult());
            return(result);
        }
 public void FinishQuest(UserQuest quest)
 {
     this.finishingQuest = quest;
     base.path = "task/getAward/" + quest.taskCid;
     base.SetupParams(null, new BaseWWWRequest.OnSuccess(this.onReqChangeSuccess), new BaseWWWRequest.OnFail(this.onReqChangeFail), true, ServerType.ChoosedServer, this.needZip);
 }
Esempio n. 30
0
 public void FinishQuest(UserQuest quest)
 {
     this.finishingQuest = quest;
     base.path           = "task/getAward/" + quest.taskCid;
     base.SetupParams(null, new BaseWWWRequest.OnSuccess(this.onReqChangeSuccess), new BaseWWWRequest.OnFail(this.onReqChangeFail), true, ServerType.ChoosedServer, false);
 }
Esempio n. 31
0
 internal bool m_4E(UserQuest n)
 {
     return (n.taskCid == this.newCondition.taskCid);
 }
Esempio n. 32
0
 public static string getQuestConStr(UserQuest q)
 {
     string r = "";
      int num1 = 0;
      int num2 = 0;
      foreach (var c in q.condition)
      {
          num1 += c.totalAmount;
          num2 += c.finishedAmount;
      }
      r += "" + num2 + "/" + num1;
      return r;
 }
Esempio n. 33
0
        public static string getQuestRewardStr(UserQuest q)
        {
            string r = "";
             ResourceTypes[] typesArray = new ResourceTypes[] { ResourceTypes.Oil, ResourceTypes.Ammo, ResourceTypes.Steel, ResourceTypes.Aluminium };
             for (int i = 0; i < 4 && i < q.award.Count; i++)
             {
                 string key = ((int)typesArray[i]) + string.Empty;
                 if (q.award.ContainsKey(key))
                 {
                     r += tools.helper.getresourcetype(typesArray[i]) + ":" + q.award[key] + " ";
                 }
             }
             r += "\r\n";
             if (q.AwardShipId > 0)
             {
                 ShipConfig config = AllShipConfigs.instance.getShip(q.AwardShipId);
                 if (config != null)
                 {
                     r += tools.helper.getshiptype(config.type) + ":" + config.title;
                 }
             }
             else
             {
                 if (q.AwardItemId > 0)
                 {
                     r += tools.helper.getItemtypestr(q.AwardItemId) + " X" + q.GetItemAmount(q.AwardItemId);

                 }
                 else
                 {
                     if (q.AwardEquipId > 0)
                     {
                         EquipmentConfig ec = GameConfigs.instance.GetEquipmentByCid(q.AwardEquipId);
                         if (ec != null)
                         {
                             r += tools.helper.getEquipmentTypeString(ec.type) + ":" + ec.title;
                         }
                     }
                 }
             }
             return r;
        }
Esempio n. 34
0
 public void RemoveQuest(UserQuest quest)
 {
     if (this._allQuests != null)
     {
         this._allQuests.Remove(quest);
     }
 }