Exemplo n.º 1
0
        public async Task <int?> UpgradeBuilding(long buildingId)
        {
            // Building not found = -1
            // Building upgraded = 1
            // Building not upgraded null
            var building = kingdom.Buildings.FirstOrDefault(b => b.Id == buildingId);

            if (building == null)
            {
                return(-1);
            }

            if (restrictionsService.CheckGoldForUpgradeBuilding(kingdom, building) && await restrictionsService.CheckLevelForUpgrade(kingdom, building))
            {
                await buildingService.ChangeBuildingLevel(building);

                return(1);
            }
            return(null);
        }