static void Main() { var players = GetPlayers(); var sittingDuck = new SittingDuck(); sittingDuck.SetPlayers(players); var externalTracks = new [] { new ExternalTrack(TrackConfiguration.Track1, sittingDuck.BlueZone), new ExternalTrack(TrackConfiguration.Track2, sittingDuck.RedZone), new ExternalTrack(TrackConfiguration.Track3, sittingDuck.WhiteZone) }; var internalTrack = new InternalTrack(TrackConfiguration.Track4); var externalThreats = new ExternalThreat[] { new Destroyer(3, ZoneLocation.Blue, sittingDuck), new Fighter(4, ZoneLocation.Red, sittingDuck), new Fighter(5, ZoneLocation.White, sittingDuck) }; var internalThreats = new InternalThreat[] { new SkirmishersA(3, sittingDuck), new Fissure(2, sittingDuck) //new Alien(1, sittingDuck) }; var game = new Game(sittingDuck, externalThreats, externalTracks, internalThreats, internalTrack, players); var currentTurn = 0; try { for (currentTurn = 0; currentTurn < Game.NumberOfTurns; currentTurn++) { game.PerformTurn(); } } catch (LoseException loseException) { Console.WriteLine("Killed on turn {0} by: {1}", currentTurn, loseException.Threat); } Console.WriteLine("Damage Taken:\r\nBlue: {0}\r\nRed: {1}\r\nWhite: {2}", sittingDuck.BlueZone.TotalDamage, sittingDuck.RedZone.TotalDamage, sittingDuck.WhiteZone.TotalDamage); Console.WriteLine("Threats killed: {0}. Threats survived: {1}", game.defeatedThreats.Count, game.survivedThreats.Count); Console.WriteLine("Total points: {0}", game.TotalPoints); foreach (var zone in sittingDuck.Zones) { foreach (var token in zone.AllDamageTokensTaken) { Console.WriteLine("{0} damage token taken in zone {1}. Still damaged: {2}", token, zone.ZoneLocation, zone.CurrentDamageTokens.Contains(token)); } } }
private void ResolveGame(object sender, RoutedEventArgs routedEventArgs) { var actionLists = new List <string> { FirstPlayerTextBox.Text, SecondPlayerTextBox.Text, ThirdPlayerTextBox.Text }; if (FourthPlayerCheckBox.IsChecked.HasValue && FourthPlayerCheckBox.IsChecked.Value) { actionLists.Add(FourthPlayerTextBox.Text); } if (FifthPlayerCheckBox.IsChecked.HasValue && FifthPlayerCheckBox.IsChecked.Value) { actionLists.Add(FifthPlayerTextBox.Text); } var players = actionLists.Select(CreatePlayer).ToList(); var externalThreats = threatsInGame .Where(threat => threat.Zone != null) .Select(threat => Activator.CreateInstance( threat.Type, threat.TimeAppears, threat.Zone.Value, sittingDuck)) .Cast <ExternalThreat>() .ToList(); var externalTracks = new [] { new ExternalTrack(((Track)RedTrackPicker.SelectedItem).TrackConfiguration, sittingDuck.RedZone), new ExternalTrack(((Track)WhiteTrackPicker.SelectedItem).TrackConfiguration, sittingDuck.WhiteZone), new ExternalTrack(((Track)BlueTrackPicker.SelectedItem).TrackConfiguration, sittingDuck.BlueZone) }; var internalThreats = threatsInGame .Where(threat => threat.Zone == null) .Select(threat => Activator.CreateInstance( threat.Type, threat.TimeAppears, sittingDuck)) .Cast <InternalThreat>() .ToList(); var internalTrack = new InternalTrack(((Track)InternalTrackPicker.SelectedItem).TrackConfiguration); sittingDuck.SetPlayers(players); var game = new Game(sittingDuck, externalThreats, externalTracks, internalThreats, internalTrack, players); var currentTurn = 0; try { for (currentTurn = 0; currentTurn < Game.NumberOfTurns; currentTurn++) { game.PerformTurn(); } } catch (LoseException loseException) { StatusTextBlock.Text += string.Format("Killed on turn {0} by: {1}", currentTurn, loseException.Threat); } StatusTextBlock.Text += string.Format("Damage Taken:\r\nBlue: {0}\r\nRed: {1}\r\nWhite: {2}", sittingDuck.BlueZone.TotalDamage, sittingDuck.RedZone.TotalDamage, sittingDuck.WhiteZone.TotalDamage); StatusTextBlock.Text += string.Format("Threats killed: {0}. Threats survived: {1}", game.defeatedThreats.Count, game.survivedThreats.Count); StatusTextBlock.Text += string.Format("Total points: {0}", game.TotalPoints); foreach (var zone in sittingDuck.Zones) { foreach (var token in zone.AllDamageTokensTaken) { StatusTextBlock.Text += string.Format("{0} damage token taken in zone {1}. Still damaged: {2}", token, zone.ZoneLocation, zone.CurrentDamageTokens.Contains(token)); } } }