예제 #1
0
        public MethodResult CanUpgradeFurniture(House house, FurnitureTypeEnum furnitureType)
        {
            if (house == null)
            {
                return(new MethodResult("House does not exist!"));
            }
            var furniture = houseFurnitureRepository.GetFurniture(house.ID, furnitureType);

            if (furniture == null)
            {
                return(new MethodResult("Furniture does not exist!"));
            }


            var furnitureObject = HouseFurnitureObjectFactory.CreateHouseFurniture(furniture);

            if (furnitureObject.CanUpgrade() == false)
            {
                return(new MethodResult("You cannot further upgrade this furniture"));
            }


            var cost  = furnitureObject.GetUpgradeCost();
            var chest = houseFurnitureRepository.GetHouseChest(house.ID);

            if (houseChestService.HasItem(chest, ProductTypeEnum.UpgradePoints, 1, cost) == false)
            {
                return(new MethodResult($"You do not have {cost} Upgrade Points to upgrade {furnitureObject.ToHumanReadable()}."));
            }

            return(MethodResult.Success);
        }
 public FurnitureForCreateViewModel GetFurnitureForCreate(FurnitureTypeEnum furnitureType)
 {
     return(new FurnitureForCreateViewModel()
     {
         Name = furnitureType.ToHumanReadable().FirstUpper(),
         FurnitureTypeID = (int)furnitureType,
         Price = HouseFurnitureObject.GetUpgradeCost(furnitureType, 1)
     });
 }
예제 #3
0
 public HouseFurnitureObject(HouseFurniture furniture)
 {
     ID              = furniture.ID;
     FurnitureType   = (FurnitureTypeEnum)furniture.FurnitureTypeID;
     Quality         = furniture.Quality;
     HouseID         = furniture.HouseID;
     HouseEntity     = furniture.House;
     FurnitureEntity = furniture;
 }
예제 #4
0
        public void UpgradeFurniture(House house, FurnitureTypeEnum furnitureType)
        {
            var furniture       = houseFurnitureRepository.GetFurniture(house.ID, furnitureType);
            var furnitureObject = HouseFurnitureObjectFactory.CreateHouseFurniture(furniture);

            payForUpgrade(house, furnitureObject);
            furnitureObject.Upgrade();

            houseRepository.SaveChanges();
        }
예제 #5
0
        public void BuildFurniture(House house, FurnitureTypeEnum furnitureType)
        {
            var furniture = new HouseFurniture()
            {
                House           = house,
                FurnitureTypeID = (int)furnitureType,
                Quality         = 1
            };

            houseFurnitureRepository.Add(furniture);
            ConditionalSaveChanges(houseFurnitureRepository);
        }
예제 #6
0
        public static int GetUpgradeCost(FurnitureTypeEnum furnitureType, int quality)
        {
            switch (furnitureType)
            {
            case FurnitureTypeEnum.Bed:
                return(HouseBedObject.GetUpgradeCost(quality));

            case FurnitureTypeEnum.Chest:
                return(HouseChestObject.GetUpgradeCost(quality));
            }
            throw new ArgumentException();
        }
        public HouseFurnitureDummyCreator SetFurnitureType(FurnitureTypeEnum furnitureType)
        {
            houseFurniture.FurnitureTypeID = (int)furnitureType;
            switch (furnitureType)
            {
            case FurnitureTypeEnum.Chest:
                houseFurniture.HouseChest = new HouseChest()
                {
                    Capacity       = 20,
                    FurnitureID    = houseFurniture.ID,
                    HouseFurniture = houseFurniture
                };
                break;
            }

            return(this);
        }
예제 #8
0
        public MethodResult CanBuildFurniture(House house, FurnitureTypeEnum furnitureType, Entity entity)
        {
            var result = CanModifyHouse(house, entity);

            if (result.IsError)
            {
                return(result);
            }

            if (houseFurnitureRepository.IsFurnitureBuilt(house.ID, furnitureType))
            {
                return(new MethodResult($"{furnitureType.ToHumanReadable().FirstUpper()} is already built!"));
            }

            var cost  = HouseFurnitureObject.GetUpgradeCost(furnitureType, 1);
            var chest = houseFurnitureRepository.GetHouseChest(house.ID);

            if (houseChestService.HasItem(chest, ProductTypeEnum.ConstructionMaterials, 1, cost) == false)
            {
                return(new MethodResult($"You do not have {cost} Construction materials to create {furnitureType.ToHumanReadable()}."));
            }

            return(MethodResult.Success);
        }
예제 #9
0
 public static string ToHumanReadable(this FurnitureTypeEnum furnitureType)
 {
     return(furnitureType.ToString());
 }
 public bool IsFurnitureBuilt(long houseID, FurnitureTypeEnum furnitureType)
 {
     return(Any(f => f.HouseID == houseID && f.FurnitureTypeID == (int)furnitureType));
 }
 public HouseFurniture GetFurniture(long houseID, FurnitureTypeEnum furnitureType)
 {
     return(FirstOrDefault(f => f.HouseID == houseID && f.FurnitureTypeID == (int)furnitureType));
 }
예제 #12
0
 public static HouseFurniture GetFurniture(this House house, FurnitureTypeEnum furnitureType)
 {
     return(house.HouseFurnitures.FirstOrDefault(f => f.FurnitureTypeID == (int)furnitureType));
 }