Exemplo n.º 1
0
        public override int GetHashCode()
        {
            int hashCode = 1516578759;

            hashCode = (hashCode * -1521134295) + IsSponsorSpot.GetHashCode();
            hashCode = (hashCode * -1521134295) + Applicability.GetHashCode();
            hashCode = (hashCode * -1521134295) + CompetitorType.GetHashCode();
            hashCode = (hashCode * -1521134295) + RestrictionType.GetHashCode();
            return(hashCode);
        }
        public void InvadeEarthCityWithDefender(string userNames, CompetitorType competitorType, IEarthDefender defender, bool simulationOnly)
        {
            if (competitorType == CompetitorType.NotSpecified)
            {
                throw new Exception("You need to specify what kind of competitor you are (testing manually, TDD, or continuous tester).  Please set the TypeOfCompetitor value!");
            }

            if (userNames == "PLEASE FILL ME IN" || string.IsNullOrEmpty(userNames))
            {
                throw new Exception("You need to fill in your username(s)");
            }

            userNames = string.Format("({0}) {1}", competitorType, userNames);

            KnownCities.ResetCities();

            var command       = new ServerCommand();
            int currentCityId = command.GetCurrentCityId(userNames);

            if (currentCityId >= KnownCities.All.Length)
            {
                Console.WriteLine("You have finished the game.");
                return;
            }

            var  outputText    = new StringBuilder();
            bool defenceFailed = false;

            for (int cityId = 0; cityId <= currentCityId; cityId++)
            {
                var city = KnownCities.All[cityId];
                defenceFailed = invadeCity(city, defender, outputText, cityId != currentCityId);

                if (defenceFailed)
                {
                    break;
                }
            }

            if (simulationOnly)
            {
                Console.WriteLine("Simulation complete.");
                return;
            }

            var nextCity = command.ReportInvasionResultAndGetNextCity(userNames, defenceFailed);

            Console.WriteLine(outputText.ToString());

            if (defenceFailed == false)
            {
                var briefing = new InvasionBriefing();
                briefing.ShowBriefingForCity(nextCity);
            }
        }
        public void InvadeEarthCityWithDefender(string userNames, CompetitorType competitorType, IEarthDefender defender, bool simulationOnly)
        {
            if (competitorType == CompetitorType.NotSpecified)
                throw new Exception("You need to specify what kind of competitor you are (testing manually, TDD, or continuous tester).  Please set the TypeOfCompetitor value!");

            if (userNames == "PLEASE FILL ME IN" || string.IsNullOrEmpty(userNames))
                throw new Exception("You need to fill in your username(s)");

            userNames = string.Format("({0}) {1}", competitorType, userNames);

            KnownCities.ResetCities();

            var command = new ServerCommand();
            int currentCityId = command.GetCurrentCityId(userNames);

            if (currentCityId >= KnownCities.All.Length)
            {
                Console.WriteLine("You have finished the game.");
                return;
            }

            var outputText = new StringBuilder();
            bool defenceFailed = false;

            for (int cityId = 0; cityId <= currentCityId; cityId++)
            {
                var city = KnownCities.All[cityId];
                defenceFailed = invadeCity(city, defender, outputText, cityId != currentCityId);

                if (defenceFailed)
                    break;
            }

            if (simulationOnly)
            {
                Console.WriteLine("Simulation complete.");
                return;
            }

            var nextCity = command.ReportInvasionResultAndGetNextCity(userNames, defenceFailed);

            Console.WriteLine(outputText.ToString());

            if (defenceFailed == false)
            {
                var briefing = new InvasionBriefing();
                briefing.ShowBriefingForCity(nextCity);
            }
        }
        public void ShowBriefing(CompetitorType competitorType, string userNames)
        {
            if (competitorType == CompetitorType.NotSpecified)
                throw new Exception("You need to specify what kind of competitor you are (testing manually, TDD, or continuous tester).  Please set the TypeOfCompetitor value!");

            if (userNames == "PLEASE FILL ME IN" || string.IsNullOrEmpty(userNames))
                throw new Exception("You need to fill in your username(s)");

            userNames = string.Format("({0}) {1}", competitorType, userNames);

            var cityQuery = new ServerCommand();
            int currentCityId = cityQuery.GetCurrentCityId(userNames);

            ShowBriefingForCity(currentCityId);
        }
        public void ShowBriefing(CompetitorType competitorType, string userNames)
        {
            if (competitorType == CompetitorType.NotSpecified)
            {
                throw new Exception("You need to specify what kind of competitor you are (testing manually, TDD, or continuous tester).  Please set the TypeOfCompetitor value!");
            }

            if (userNames == "PLEASE FILL ME IN" || string.IsNullOrEmpty(userNames))
            {
                throw new Exception("You need to fill in your username(s)");
            }

            userNames = string.Format("({0}) {1}", competitorType, userNames);

            var cityQuery     = new ServerCommand();
            int currentCityId = cityQuery.GetCurrentCityId(userNames);

            ShowBriefingForCity(currentCityId);
        }
Exemplo n.º 6
0
        public Result <List <GameCategory> > FilterByCompetitorType(CompetitorType competitorType)
        {
            Result <List <GameCategory> > retVal = null;

            try
            {
                List <GameCategory> categories = Uow.GameCompetitionTypes
                                                 .GetAll()
                                                 .Where(gc => gc.CompetitionType.CompetitorType == competitorType)
                                                 .Select(gc => gc.Game.Category)
                                                 .Distinct()
                                                 .ToList();

                retVal = ResultHandler <List <GameCategory> > .Sucess(categories);
            }
            catch (Exception ex)
            {
                log.Error(String.Format("Error retreiving list of game categories by competitor type. competitor type: {0}", competitorType), ex);
                retVal = ResultHandler <List <GameCategory> > .Erorr("Error retreiving list of game categories by competitor type");
            }
            return(retVal);
        }
Exemplo n.º 7
0
        public Result <List <Game> > FilterByCategoryAndCompetitionType(int gameCategoryID, CompetitorType competitorType)
        {
            Result <List <Game> > retVal = null;

            try
            {
                List <Game> games = Uow.GameCompetitionTypes
                                    .GetAll()
                                    .Where(g => g.Game.GameCategoryID == gameCategoryID &&
                                           g.CompetitionType.CompetitorType == competitorType)
                                    .Select(gc => gc.Game)
                                    .ToList();

                retVal = ResultHandler <List <Game> > .Sucess(games);
            }
            catch (Exception ex)
            {
                log.Error(String.Format("Error retreiving list of games for category and comeptitor type.  categoryid: {0}, competitor type: {1}", gameCategoryID, competitorType), ex);
                retVal = ResultHandler <List <Game> > .Erorr("Error retreiving list of games for category and competitor type");
            }

            return(retVal);
        }