Ejemplo n.º 1
0
        public void Initialize(NWPlayer player, int questID)
        {
            var status = DataService.PCQuestStatus.GetByPlayerAndQuestID(player.GlobalID, questID);
            PCQuestKillTargetProgress pcKT = new PCQuestKillTargetProgress
            {
                RemainingToKill = _amount,
                NPCGroupID      = (int)_group,
                PCQuestStatusID = status.ID,
                PlayerID        = player.GlobalID
            };

            DataService.SubmitDataChange(pcKT, DatabaseActionType.Insert);
        }
        public void GetByID_OneItem_ReturnsPCQuestKillTargetProgress()
        {
            // Arrange
            var id = Guid.NewGuid();
            PCQuestKillTargetProgress entity = new PCQuestKillTargetProgress {
                ID = id
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <PCQuestKillTargetProgress>(entity));

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(id));
        }
Ejemplo n.º 3
0
        private void CreateExtendedQuestDataEntries(PCQuestStatus status, int questID, int sequenceID)
        {
            // Create entries for the PC kill targets.
            List <QuestKillTargetList> killTargets = _db.StoredProcedure <QuestKillTargetList>("GetQuestKillTargetsByQuestSequenceID",
                                                                                               new SqlParameter("QuestID", questID),
                                                                                               new SqlParameter("SequenceID", sequenceID));

            foreach (QuestKillTargetList kt in killTargets)
            {
                PCQuestKillTargetProgress pcKT = new PCQuestKillTargetProgress
                {
                    RemainingToKill = kt.Quantity,
                    NPCGroupID      = kt.NPCGroupID,
                    PCQuestStatusID = status.PCQuestStatusID,
                    PlayerID        = status.PlayerID
                };
                _db.PCQuestKillTargetProgresses.Add(pcKT);
                _db.SaveChanges();
            }
        }
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            var id1 = Guid.NewGuid();
            var id2 = Guid.NewGuid();
            PCQuestKillTargetProgress entity1 = new PCQuestKillTargetProgress {
                ID = id1
            };
            PCQuestKillTargetProgress entity2 = new PCQuestKillTargetProgress {
                ID = id2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <PCQuestKillTargetProgress>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <PCQuestKillTargetProgress>(entity2));

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(id1));
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            var id1 = Guid.NewGuid();
            var id2 = Guid.NewGuid();
            PCQuestKillTargetProgress entity1 = new PCQuestKillTargetProgress {
                ID = id1
            };
            PCQuestKillTargetProgress entity2 = new PCQuestKillTargetProgress {
                ID = id2
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <PCQuestKillTargetProgress>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <PCQuestKillTargetProgress>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCQuestKillTargetProgress>(entity1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); });
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Quests which require items, kill targets, etc. all need to have their entries added for this player's
        /// quest progress. This method handles that.
        /// </summary>
        /// <param name="status"></param>
        private static void CreateExtendedQuestDataEntries(PCQuestStatus status)
        {
            // Retrieve the quest and state information from the cache.
            var quest = DataService.Get <Quest>(status.QuestID);
            var state = DataService.Single <QuestState>(x => x.QuestID == quest.ID && x.ID == status.CurrentQuestStateID);

            // Retrieve the kill targets and required items necessary for this quest state.
            var killTargets   = DataService.Where <QuestKillTarget>(x => x.QuestStateID == state.ID);
            var requiredItems = DataService.Where <QuestRequiredItem>(x => x.QuestStateID == state.ID);

            // Create entries for the PC kill targets.
            foreach (var kt in killTargets)
            {
                PCQuestKillTargetProgress pcKT = new PCQuestKillTargetProgress
                {
                    RemainingToKill = kt.Quantity,
                    NPCGroupID      = kt.NPCGroupID,
                    PCQuestStatusID = status.ID,
                    PlayerID        = status.PlayerID
                };
                DataService.SubmitDataChange(pcKT, DatabaseActionType.Insert);
            }

            // Create entries for PC items required.
            foreach (var item in requiredItems)
            {
                PCQuestItemProgress itemProgress = new PCQuestItemProgress
                {
                    Resref                = item.Resref,
                    PlayerID              = status.PlayerID,
                    PCQuestStatusID       = status.ID,
                    Remaining             = item.Quantity,
                    MustBeCraftedByPlayer = item.MustBeCraftedByPlayer
                };
                DataService.SubmitDataChange(itemProgress, DatabaseActionType.Insert);
            }

            // Submit changes to the cache/DB.
            DataService.SubmitDataChange(status, DatabaseActionType.Update);
        }
Ejemplo n.º 7
0
        private void CreateExtendedQuestDataEntries(PCQuestStatus status)
        {
            var quest         = _data.Get <Quest>(status.QuestID);
            var state         = _data.Single <QuestState>(x => x.QuestID == quest.ID && x.ID == status.CurrentQuestStateID);
            var killTargets   = _data.Where <QuestKillTarget>(x => x.QuestStateID == state.ID);
            var requiredItems = _data.Where <QuestRequiredItem>(x => x.QuestStateID == state.ID);

            // Create entries for the PC kill targets.
            foreach (var kt in killTargets)
            {
                PCQuestKillTargetProgress pcKT = new PCQuestKillTargetProgress
                {
                    RemainingToKill = kt.Quantity,
                    NPCGroupID      = kt.NPCGroupID,
                    PCQuestStatusID = status.ID,
                    PlayerID        = status.PlayerID
                };
                _data.SubmitDataChange(pcKT, DatabaseActionType.Insert);
            }

            // Create entries for PC items required.
            foreach (var item in requiredItems)
            {
                PCQuestItemProgress itemProgress = new PCQuestItemProgress
                {
                    Resref                = item.Resref,
                    PlayerID              = status.PlayerID,
                    PCQuestStatusID       = status.ID,
                    Remaining             = item.Quantity,
                    MustBeCraftedByPlayer = item.MustBeCraftedByPlayer
                };
                _data.SubmitDataChange(itemProgress, DatabaseActionType.Insert);
            }

            _data.SubmitDataChange(status, DatabaseActionType.Update);
        }