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 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(); }
private IEnumerable <IHouseFurnitureObject> getFurniture(House house) { var furnitures = houseFurnitureRepository. Where(f => f.HouseID == house.ID) .Include(f => f.HouseChest) .Include(f => f.House) .ToList(); foreach (var furniture in furnitures) { yield return(HouseFurnitureObjectFactory.CreateHouseFurniture(furniture)); } }
public HouseBaseFurnitureViewModel(HouseFurniture furniture, HouseRights houseRights) { var furnitureObject = HouseFurnitureObjectFactory.CreateHouseFurniture(furniture); Quality = furniture.Quality; MaintainceCost = furnitureObject.CalculateDecay(); Name = furnitureObject.ToHumanReadable().FirstUpper(); HouseID = furniture.HouseID; FurnitureTypeID = furniture.FurnitureTypeID; CanUpgrade = furnitureObject.CanUpgrade() && houseRights.CanModifyHouse; CanManage = houseRights.CanModifyHouse; if (CanUpgrade) { UpgradeCost = furnitureObject.GetUpgradeCost(); } }