Exemplo n.º 1
0
        /// <summary>
        /// Gets a room generator object.
        /// </summary>
        /// <param name="model">
        /// Model of room generator obejct to get.
        /// </param>
        public async Task <RoomGenModel> GetRoomGen(RoomGenModel model)
        {
            var prot = new RoomProt {
                RoomType = model.Type
            };

            //get a room prototype with a given type
            prot = await _protDataAccess.Get(prot);

            var result = new RoomGenModel
            {
                Enchanting = prot.Enchanting == 1,
                Enemy      = prot.Enemy == 1,
                Items      = prot.Items,
                Rarity     = prot.Rarity,
                Type       = prot.RoomType,
            };

            if (result.Items > 0)
            {
                result.TradeI = prot.TradeI.Value == 1;

                if (result.TradeI.Value)
                {
                    result.AvailableA = prot.AvailableA.Value == 1;
                    result.AvailableP = prot.AvailableP.Value == 1;
                    result.AvailableW = prot.AvailableW.Value == 1;
                    result.Restock    = prot.Restock.Value == 1;
                }
            }

            if (result.Enchanting)
            {
                result.TradeE = prot.TradeE.Value == 1;
                if (result.TradeE.Value)
                {
                    result.Restock = prot.Restock.Value == 1;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the shop with items.
        /// </summary>
        /// <param name="room">
        /// Room in which shop is placed.
        /// </param>
        /// <param name="roomType">
        /// prototype of the room.
        /// </param>
        /// <returns>
        /// Room with shop filled.
        /// </returns>
        private async Task <RoomModel> FillShop(RoomModel room, RoomProt roomType)
        {
            //filling shop with items associated with the room
            if (roomType.Items > 0)
            {
                room = await FillArmours(room);

                room = await FillPotions(room);

                room = await FillWeapons(room);
            }
            //deciding if the enchant in room is saved or buyable
            if (roomType.Enchanting == 1)
            {
                if (room.ShopEvent.BuyableEnchantement != null)
                {
                    if (room.ShopEvent.BuyableEnchantement.Type != null)
                    {
                        room.ShopEvent.BuyableEnchantement = await Get(room.ShopEvent.BuyableEnchantement);
                    }
                    else
                    {
                        room.ShopEvent.BuyableEnchantement = null;
                    }
                }
                else
                {
                    if (room.ShopEvent.FreeEnchantement?.Type != null)
                    {
                        room.ShopEvent.FreeEnchantement = await Get(room.ShopEvent.FreeEnchantement);
                    }
                    else
                    {
                        room.ShopEvent.FreeEnchantement = null;
                    }
                }
            }

            return(room);
        }