示例#1
0
        public async Task <ActionResult <QuestChain> > Get(int id)
        {
            QuestChain questChain = await _db.QuestChains.FirstOrDefaultAsync(x => x.Id == id);

            if (questChain == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(questChain));
        }
示例#2
0
        public async Task <ActionResult <QuestChain> > Post(QuestChain questChain)
        {
            if (questChain == null)
            {
                return(BadRequest());
            }

            _db.QuestChains.Add(questChain);
            await _db.SaveChangesAsync();

            return(Ok(questChain));
        }
示例#3
0
        public static void RemoveChain(PlayerMobile pm, QuestChain chain)
        {
            if (ChainData.ContainsKey(pm) && ChainData[pm].ContainsKey(chain))
            {
                ChainData[pm].Remove(chain);

                if (ChainData[pm].Count == 0)
                {
                    ChainData.Remove(pm);
                }
            }
        }
示例#4
0
        public async Task <ActionResult <QuestChain> > Delete(int id)
        {
            QuestChain questChain = _db.QuestChains.FirstOrDefault(x => x.Id == id);

            if (questChain == null)
            {
                return(NotFound());
            }
            _db.QuestChains.Remove(questChain);
            await _db.SaveChangesAsync();

            return(Ok(questChain));
        }
示例#5
0
        public static void AddChain(PlayerMobile pm, QuestChain id, BaseChain chain)
        {
            if (pm == null)
            {
                return;
            }

            if (!ChainData.ContainsKey(pm) || ChainData[pm] == null)
            {
                ChainData[pm] = new Dictionary <QuestChain, BaseChain>();
            }

            ChainData[pm].Add(id, chain);
        }
示例#6
0
        public async Task <ActionResult <QuestChain> > Put(QuestChain questChain)
        {
            if (questChain == null)
            {
                return(BadRequest());
            }
            if (!_db.QuestChains.Any(x => x.Id == questChain.Id))
            {
                return(NotFound());
            }

            _db.Update(questChain);
            await _db.SaveChangesAsync();

            return(Ok(questChain));
        }
        public void TestCanAddSingleItem()
        {
            ISessionFactory fac     = RomViewContainer.Container.GetInstance <ISessionFactory>();
            ISession        session = fac.OpenSession();
            ITransaction    tx      = session.BeginTransaction();

            CallSessionContext.Bind(session);

            try
            {
                IRepository <QuestDefinition> rep =
                    RomViewContainer.Container.GetInstance <IRepository <QuestDefinition> >();
                IQuestRepository repository = new QuestRepository(rep);

                QuestChain chain = new QuestChain()
                {
                    Name = "Saving a Marriage"
                };

                IRepository <QuestChain> chainRep = RomViewContainer.Container.GetInstance <IRepository <QuestChain> >();
                try
                {
                    chain = chainRep.SaveOrUpdate(chain);
                }
                catch
                {
                }

                QuestDefinition def = new QuestDefinition()
                {
                    RomId             = 423924,
                    Name              = "Act First and Report Later",
                    MinLevel          = 25,
                    Level             = 27,
                    StarterId         = 117396,
                    EnderId           = 117396,
                    Gold              = 1515,
                    XP                = 17301,
                    TP                = 1730,
                    RewardCategory    = RewardCategory.Armor,
                    RewardSubCategory = RewardSubCategory.Head,
                    ChainIndex        = 4,
                    QuestChain        = chain
                };

                IRepository <ItemDefinition> idef = RomViewContainer.Container.GetInstance <IRepository <ItemDefinition> >();

                ItemRepository irep = new ItemRepository(idef);
                ItemDefinition item = irep.GetByRomId(228250);
                item.ItemType       = "armor";
                item.ItemSubType    = "cloth";
                item.ItemSubSubType = "head";
                item.Value          = 196;
                irep.UpdateItem(item);

                QuestReward reward = new QuestReward()
                {
                    Item        = item,
                    RewardIndex = 1,
                    RewardType  = "Cloth",
                    Quest       = def
                };
                def.Rewards.Add(reward);

                item                = irep.GetByRomId(228251);
                item.ItemType       = "armor";
                item.ItemSubType    = "leather";
                item.ItemSubSubType = "head";
                item.Value          = 261;
                irep.UpdateItem(item);

                reward = new QuestReward()
                {
                    Item = item, RewardIndex = 2, RewardType = "Leather", Quest = def
                };
                def.Rewards.Add(reward);

                repository.Add(def);
            }
            finally
            {
                tx.Rollback();
                session.Close();
            }
        }