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); }