コード例 #1
0
		private void AcceptGame()
		{
			game.AcceptCards();

			game.GameEndedEvent += new DominionBase.Game.GameEndedEventHandler(game_GameEndedEvent);

			wMain.Settings.PlayerSettings.ForEach(ps => glMain.AddPlayerColor(ps.Name, ps.UIColor));
			glMain.NewSection(String.Format("Game started with {0} players", game.Players.Count));

			game.Table.TokenPiles.TokenCollectionsChanged += new DominionBase.TokenCollections.TokenCollectionsChangedEventHandler(TokenPiles_TokenCollectionsChanged);
			game.Table.Trash.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Trash_PileChanged);
			Trash_PileChanged(game.Table.Trash, new DominionBase.Piles.PileChangedEventArgs(DominionBase.Piles.PileChangedEventArgs.Operation.Reset));
			game.GameMessage += new DominionBase.Game.GameMessageEventHandler(game_GameMessage);

			foreach (DominionBase.Players.Player player in game.Players.FindAll(p => p.PlayerType == DominionBase.Players.PlayerType.Human))
				player.Choose = player_Choose;

			if (game.Players.Any(player => player.PlayerType == DominionBase.Players.PlayerType.Human))
				_Player = game.Players.OfType<DominionBase.Players.Human>().First();
			else
				_Player = null;

			String message = "Using the following cards";
			if (game.Settings.Preset != null)
				message = String.Format("{0} from the preset \"{1}\"", message, game.Settings.Preset.Name);
			glMain.Log(String.Format("{0}:", message));
			IEnumerable<DominionBase.Piles.Supply> kingdomSupplies = game.Table.Supplies.Where(kvp => kvp.Value.Randomizer.Location == DominionBase.Cards.Location.Kingdom).Select(kvp => kvp.Value).OrderBy(s => s.Name);
			glMain.Log("   ", kingdomSupplies.Take(5));
			glMain.Log("   ", kingdomSupplies.Skip(5));

			int prosperityPiles = game.Table.Supplies.Count(kvp => kvp.Value.Location == DominionBase.Cards.Location.Kingdom && kvp.Value.Source == DominionBase.Cards.Source.Prosperity);
			int darkAgesPiles = game.Table.Supplies.Count(kvp => kvp.Value.Location == DominionBase.Cards.Location.Kingdom && kvp.Value.Source == DominionBase.Cards.Source.DarkAges);
			int kingdomPiles = game.Table.Supplies.Count(kvp => kvp.Value.Location == DominionBase.Cards.Location.Kingdom && kvp.Value.Tokens.Count(t => t.GetType() == DominionBase.Cards.Cornucopia.TypeClass.BaneToken) == 0);
			glMain.Log(String.Format("Prosperity Kingdom card ratio is {0}/{1} = {2:P0}", 
				prosperityPiles,
				kingdomPiles,
				((float)prosperityPiles) / kingdomPiles
				));
			glMain.Log(String.Format("   Colony / Platinum {0}selected",
				game.Settings.ColonyPlatinumUsage == DominionBase.ColonyPlatinumUsage.Used ? "" : "<u>not</u> "
				));
			glMain.Log(String.Format("Dark Ages Kingdom card ratio is {0}/{1} = {2:P0}",
				darkAgesPiles,
				kingdomPiles,
				((float)darkAgesPiles) / kingdomPiles
				));
			glMain.Log(String.Format("   Shelters {0}selected",
				game.Settings.ShelterUsage == DominionBase.ShelterUsage.Used ? "" : "<u>not</u> "
				));

			glMain.Log("Turn order is: ", String.Join(", ", game.Players.Select(p => p == _Player ? String.Format("{0} (You)", p.Name) : p.Name)));


			Type[] specialTypes = new Type[] { 
				DominionBase.Cards.Promotional.TypeClass.BlackMarketSupply, 
				DominionBase.Cards.Cornucopia.TypeClass.PrizeSupply, 
				DominionBase.Cards.DarkAges.TypeClass.Madman,
				DominionBase.Cards.DarkAges.TypeClass.Mercenary,
				DominionBase.Cards.DarkAges.TypeClass.Spoils };

			foreach (Type specialType in specialTypes)
			{
				if (game.Table.SpecialPiles.ContainsKey(specialType))
				{
					_MatEventHandlers[specialType] = new DominionBase.Piles.Pile.PileChangedEventHandler(GamePile_PileChanged);
					game.Table.SpecialPiles[specialType].PileChanged += _MatEventHandlers[specialType];
					GamePile_PileChanged(game.Table.SpecialPiles[specialType], new DominionBase.Piles.PileChangedEventArgs(DominionBase.Piles.PileChangedEventArgs.Operation.Reset));
				}
			}

			if (game.Table.Supplies.ContainsKey(DominionBase.Cards.Prosperity.TypeClass.TradeRoute))
			{
				if (dpGameStuff.Children.Count > 0)
				{
					Border bDiv = new Border();
					bDiv.BorderThickness = new Thickness(2);
					bDiv.BorderBrush = Brushes.Black;
					Panel.SetZIndex(bDiv, 1);
					DockPanel.SetDock(bDiv, Dock.Left);
					dpGameStuff.Children.Add(bDiv);
				}

				Label lTradeRoute = new Label();
				lTradeRoute.Content = "Trade Route Tokens:";
				lTradeRoute.FontSize = 16d;
				lTradeRoute.FontWeight = FontWeights.Bold;
				lTradeRoute.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
				lTradeRoute.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure);
				DockPanel.SetDock(lTradeRoute, Dock.Left);
				dpGameStuff.Children.Add(lTradeRoute);

				_TradeRouteLabel = new Label();
				_TradeRouteLabel.Content = "0";
				_TradeRouteLabel.FontWeight = FontWeights.Bold;
				_TradeRouteLabel.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
				_TradeRouteLabel.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
				_TradeRouteLabel.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure);
				_TradeRouteLabel.Padding = new Thickness(0, 0, 5, 0);
				_TradeRouteLabel.BorderThickness = new Thickness(0, 0, 1, 0);
				DockPanel.SetDock(_TradeRouteLabel, Dock.Left);
				dpGameStuff.Children.Add(_TradeRouteLabel);
			}

			if (dpGameStuff.Children.Count > 0)
				bStuffDivider.Visibility = System.Windows.Visibility.Visible;
			else
				bStuffDivider.Visibility = System.Windows.Visibility.Collapsed;

			foreach (DominionBase.Players.Player player in game.Players)
			{
				TabItem tiPlayer = new TabItem();

				DockPanel dpHeader = new DockPanel();
				Image iHeader = new Image();
				iHeader.Stretch = Stretch.None;
				iHeader.Margin = new Thickness(0, 0, 5, 0);
				DockPanel.SetDock(iHeader, Dock.Left);
				switch (player.PlayerType)
				{
					case DominionBase.Players.PlayerType.Human:
						iHeader.Source = (BitmapImage)this.Resources["imHuman"];
						break;

					case DominionBase.Players.PlayerType.Computer:
						iHeader.Source = (BitmapImage)this.Resources["imComputer"];
						break;
				}
				dpHeader.Children.Add(iHeader);
				TextBlock tbHeader = new TextBlock();
				tbHeader.Text = player.Name;
				dpHeader.Children.Add(tbHeader);
				tiPlayer.Header = dpHeader;

				tcAreas.Items.Add(tiPlayer);
				Controls.ucPlayerDisplay ucpdPlayer = new Controls.ucPlayerDisplay();
				tiPlayer.Content = ucpdPlayer;
				ucpdPlayer.IsUIPlayer = (player.PlayerType == DominionBase.Players.PlayerType.Human);
				ucpdPlayer.Player = player;

				PlayerSettings playerSettings = _Settings.PlayerSettings.FirstOrDefault(ps => ps.Name == player.Name);
				if (playerSettings != null)
				{
					ColorHls hlsValue = HLSColor.RgbToHls(playerSettings.UIColor);
					Color cPlayer = HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.125), hlsValue.S * 0.95, hlsValue.A);
					GradientStopCollection gsc = new GradientStopCollection();
					gsc.Add(new GradientStop(cPlayer, 0));
					gsc.Add(new GradientStop(playerSettings.UIColor, 0.25));
					gsc.Add(new GradientStop(playerSettings.UIColor, 0.75));
					gsc.Add(new GradientStop(cPlayer, 1));
					gsc.Freeze();
					tiPlayer.Background = new LinearGradientBrush(gsc, 0);
					//tiPlayer.Background = new SolidColorBrush(playerSettings.UIColor);
					ucpdPlayer.ColorFocus = playerSettings.UIColor;
				}

				ToolTip tt = new System.Windows.Controls.ToolTip();
				Controls.ucPlayerOverview ucpo = new Controls.ucPlayerOverview();
				ucpo.Player = player;
				tt.Content = ucpo;
				ToolTipService.SetToolTip(dpHeader, tt);
				if (Settings.ToolTipShowDuration == ToolTipShowDuration.Off)
					ToolTipService.SetIsEnabled(dpHeader, false);
				else
				{
					ToolTipService.SetIsEnabled(dpHeader, true);
					ToolTipService.SetShowDuration(dpHeader, (int)Settings.ToolTipShowDuration);
				}
				dpHeader.MouseDown += new MouseButtonEventHandler(tiPlayer_MouseDown);
				dpHeader.MouseUp += new MouseButtonEventHandler(tiPlayer_MouseUp);

				player.Revealed.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Revealed_PileChanged);
				player.BenefitReceiving += new DominionBase.Players.Player.BenefitReceivingEventHandler(player_BenefitReceiving);
				//player.DiscardPile.PileChanged += new DominionBase.Pile.PileChangedEventHandler(DiscardPile_PileChanged);
				player.CardPlaying += new DominionBase.Players.Player.CardPlayingEventHandler(player_CardPlaying);
				player.CardPlayed += new DominionBase.Players.Player.CardPlayedEventHandler(player_CardPlayed);
				player.CardUndoPlaying += new DominionBase.Players.Player.CardUndoPlayingEventHandler(player_CardUndoPlaying);
				player.CardUndoPlayed += new DominionBase.Players.Player.CardUndoPlayedEventHandler(player_CardUndoPlayed);
				player.CardBuying += new DominionBase.Players.Player.CardBuyingEventHandler(player_CardBuying);
				player.CardBought += new DominionBase.Players.Player.CardBoughtEventHandler(player_CardBought);
				player.CardBuyFinished += new DominionBase.Players.Player.CardBuyFinishedEventHandler(player_CardBuyFinished);
				player.CardGaining += new DominionBase.Players.Player.CardGainingEventHandler(player_CardGaining);
				player.CardGainedInto += new DominionBase.Players.Player.CardGainedIntoEventHandler(player_CardGainedInto);
				player.CardGainFinished += new DominionBase.Players.Player.CardGainFinishedEventHandler(player_CardGainFinished);
				player.TokenPlaying += new DominionBase.Players.Player.TokenPlayingEventHandler(player_TokenPlaying);
				player.TokenPlayed += new DominionBase.Players.Player.TokenPlayedEventHandler(player_TokenPlayed);
				player.Trashing += new DominionBase.Players.Player.TrashingEventHandler(player_Trashing);
				player.TrashedFinished += new DominionBase.Players.Player.TrashedFinishedEventHandler(player_Trashed);
				player.PhaseChanged += new DominionBase.Players.Player.PhaseChangedEventHandler(player_PhaseChangedEvent);
				player.PlayerModeChanged += new DominionBase.Players.Player.PlayerModeChangedEventHandler(player_PlayerModeChangedEvent);
				player.CardsDrawn += new DominionBase.Players.Player.CardsDrawnEventHandler(player_CardsDrawn);
				player.TurnStarting += new DominionBase.Players.Player.TurnStartingEventHandler(player_TurnStarting);
				player.Shuffling += new DominionBase.Players.Player.ShufflingEventHandler(player_Shuffle);
				player.CardsAddedToDeck += new DominionBase.Players.Player.CardsAddedToDeckEventHandler(player_CardsAddedToDeck);
				player.CardsAddedToHand += new DominionBase.Players.Player.CardsAddedToHandEventHandler(player_CardsAddedToHand);
				player.CardsDiscarded += new DominionBase.Players.Player.CardsDiscardedEventHandler(player_CardsDiscarded);
				player.PlayerMats.CardMatsChanged += new DominionBase.Piles.CardMats.CardMatsChangedEventHandler(PlayerMats_DecksChanged);
				player.TokenPiles.TokenCollectionsChanged += new DominionBase.TokenCollections.TokenCollectionsChangedEventHandler(PlayerTokenPiles_TokenCollectionsChanged);
				player.BenefitsChanged += new DominionBase.Players.Player.BenefitsChangedEventHandler(player_BenefitsChanged);

				if (player == _Player)
				{
					tcAreas.SelectedItem = tiPlayer;
					player.CardReceived += new DominionBase.Players.Player.CardReceivedEventHandler(player_CardReceived);
				}
			}

			game.FinalizeSetup();

			LayoutSupplyPiles();

			miNewGame.IsEnabled = false;
			miLoadGame.IsEnabled = false;
			miEndGame.IsEnabled = true;
			miSaveGame.IsEnabled = false;

			gameThread = new Thread(game.StartAsync);
			gameThread.Start();

			UpdateDisplay();
		}
コード例 #2
0
		private void Game_Load_Click(object sender, RoutedEventArgs e)
		{
			Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
			ofd.DefaultExt = ".save";
			ofd.Filter = "Saved game files (.save)|*.save";
			Nullable<Boolean> dialogResult = ofd.ShowDialog(this);
			if (dialogResult != true)
				return;

			this.game = new DominionBase.Game();
			this.game.Load(ofd.FileName);

			// Clean out the Image Repository before starting a new game -- 
			// so we don't allocate too much memory for cards we're not even using
			Caching.ImageRepository.Reset();
			dpGameInfo.Visibility = System.Windows.Visibility.Visible;
			glMain.TearDown();
			glMain.Clear();

			LayoutSupplyPiles();
			while (tcAreas.Items.Count > 2)
				tcAreas.Items.RemoveAt(tcAreas.Items.Count - 1);
			dpMatsandPiles.Children.Clear();
			dpGameStuff.Children.Clear();
			_TradeRouteLabel = null;

			// Try to force garbage collection to save some memory
			GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

			// -------------------------------------------------------------------------------

			game.GameEndedEvent += new DominionBase.Game.GameEndedEventHandler(game_GameEndedEvent);

			wMain.Settings.PlayerSettings.ForEach(ps => glMain.AddPlayerColor(ps.Name, ps.UIColor));
			if (game.ActivePlayer != null)
			{
				glMain.NewSection(String.Format("Game loaded from {0}.", game.StartTime));
				glMain.Log("It's ", game.ActivePlayer, "'s turn");
			}

			game.Table.TokenPiles.TokenCollectionsChanged += new DominionBase.TokenCollections.TokenCollectionsChangedEventHandler(TokenPiles_TokenCollectionsChanged);
			game.Table.Trash.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Trash_PileChanged);
			Trash_PileChanged(game.Table.Trash, new DominionBase.Piles.PileChangedEventArgs(DominionBase.Piles.PileChangedEventArgs.Operation.Reset));
			game.GameMessage += new DominionBase.Game.GameMessageEventHandler(game_GameMessage);

			foreach (DominionBase.Players.Player player in game.Players.FindAll(p => p.PlayerType == DominionBase.Players.PlayerType.Human))
				player.Choose = player_Choose;

			if (game.Players.Any(player => player.PlayerType == DominionBase.Players.PlayerType.Human))
				_Player = game.Players.OfType<DominionBase.Players.Human>().First();
			else
				_Player = null;

			// -------------------------------------------------------------------------------

			Type[] specialTypes = new Type[] { 
				DominionBase.Cards.Promotional.TypeClass.BlackMarketSupply, 
				DominionBase.Cards.Cornucopia.TypeClass.PrizeSupply, 
				DominionBase.Cards.DarkAges.TypeClass.Madman,
				DominionBase.Cards.DarkAges.TypeClass.Mercenary,
				DominionBase.Cards.DarkAges.TypeClass.Spoils };

			foreach (Type specialType in specialTypes)
			{
				if (game.Table.SpecialPiles.ContainsKey(specialType))
				{
					_MatEventHandlers[specialType] = new DominionBase.Piles.Pile.PileChangedEventHandler(GamePile_PileChanged);
					game.Table.SpecialPiles[specialType].PileChanged += _MatEventHandlers[specialType];
					GamePile_PileChanged(game.Table.SpecialPiles[specialType], new DominionBase.Piles.PileChangedEventArgs(DominionBase.Piles.PileChangedEventArgs.Operation.Reset));
				}
			}

			if (game.Table.Supplies.ContainsKey(DominionBase.Cards.Prosperity.TypeClass.TradeRoute))
			{
				if (dpGameStuff.Children.Count > 0)
				{
					Border bDiv = new Border();
					bDiv.BorderThickness = new Thickness(2);
					bDiv.BorderBrush = Brushes.Black;
					Panel.SetZIndex(bDiv, 1);
					DockPanel.SetDock(bDiv, Dock.Left);
					dpGameStuff.Children.Add(bDiv);
				}

				Label lTradeRoute = new Label();
				lTradeRoute.Content = "Trade Route Tokens:";
				lTradeRoute.FontSize = 16d;
				lTradeRoute.FontWeight = FontWeights.Bold;
				lTradeRoute.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
				lTradeRoute.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure);
				DockPanel.SetDock(lTradeRoute, Dock.Left);
				dpGameStuff.Children.Add(lTradeRoute);

				_TradeRouteLabel = new Label();
				_TradeRouteLabel.Content = game.Table.TokenPiles[DominionBase.Cards.Prosperity.TypeClass.TradeRouteToken].Count;
				_TradeRouteLabel.FontWeight = FontWeights.Bold;
				_TradeRouteLabel.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
				_TradeRouteLabel.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
				_TradeRouteLabel.Background = Caching.BrushRepository.GetBackgroundBrush(DominionBase.Cards.Category.Treasure);
				_TradeRouteLabel.Padding = new Thickness(0, 0, 5, 0);
				_TradeRouteLabel.BorderThickness = new Thickness(0, 0, 1, 0);
				DockPanel.SetDock(_TradeRouteLabel, Dock.Left);
				dpGameStuff.Children.Add(_TradeRouteLabel);
			}

			if (dpGameStuff.Children.Count > 0)
				bStuffDivider.Visibility = System.Windows.Visibility.Visible;
			else
				bStuffDivider.Visibility = System.Windows.Visibility.Collapsed;

			foreach (DominionBase.Players.Player player in game.Players)
			{
				TabItem tiPlayer = new TabItem();

				DockPanel dpHeader = new DockPanel();
				Image iHeader = new Image();
				iHeader.Stretch = Stretch.None;
				iHeader.Margin = new Thickness(0, 0, 5, 0);
				DockPanel.SetDock(iHeader, Dock.Left);
				switch (player.PlayerType)
				{
					case DominionBase.Players.PlayerType.Human:
						iHeader.Source = (BitmapImage)this.Resources["imHuman"];
						break;

					case DominionBase.Players.PlayerType.Computer:
						iHeader.Source = (BitmapImage)this.Resources["imComputer"];
						break;
				}
				dpHeader.Children.Add(iHeader);
				TextBlock tbHeader = new TextBlock();
				tbHeader.Text = player.Name;
				dpHeader.Children.Add(tbHeader);
				tiPlayer.Header = dpHeader;

				tcAreas.Items.Add(tiPlayer);
				Controls.ucPlayerDisplay ucpdPlayer = new Controls.ucPlayerDisplay();
				tiPlayer.Content = ucpdPlayer;
				ucpdPlayer.IsUIPlayer = (player == _Player);
				ucpdPlayer.Player = player;

				PlayerSettings playerSettings = _Settings.PlayerSettings.FirstOrDefault(ps => ps.Name == player.Name);
				if (playerSettings != null)
				{
					ColorHls hlsValue = HLSColor.RgbToHls(playerSettings.UIColor);
					Color cPlayer = HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.125), hlsValue.S * 0.95, hlsValue.A);
					GradientStopCollection gsc = new GradientStopCollection();
					gsc.Add(new GradientStop(cPlayer, 0));
					gsc.Add(new GradientStop(playerSettings.UIColor, 0.25));
					gsc.Add(new GradientStop(playerSettings.UIColor, 0.75));
					gsc.Add(new GradientStop(cPlayer, 1));
					gsc.Freeze();
					tiPlayer.Background = new LinearGradientBrush(gsc, 0);
					//tiPlayer.Background = new SolidColorBrush(playerSettings.UIColor);
					ucpdPlayer.ColorFocus = playerSettings.UIColor;
				}

				ToolTip tt = new System.Windows.Controls.ToolTip();
				Controls.ucPlayerOverview ucpo = new Controls.ucPlayerOverview();
				ucpo.Player = player;
				tt.Content = ucpo;
				ToolTipService.SetToolTip(dpHeader, tt);
				if (Settings.ToolTipShowDuration == ToolTipShowDuration.Off)
					ToolTipService.SetIsEnabled(dpHeader, false);
				else
				{
					ToolTipService.SetIsEnabled(dpHeader, true);
					ToolTipService.SetShowDuration(dpHeader, (int)Settings.ToolTipShowDuration);
				}
				dpHeader.MouseDown += new MouseButtonEventHandler(tiPlayer_MouseDown);
				dpHeader.MouseUp += new MouseButtonEventHandler(tiPlayer_MouseUp);

				player.Revealed.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Revealed_PileChanged);
				player.BenefitReceiving += new DominionBase.Players.Player.BenefitReceivingEventHandler(player_BenefitReceiving);
				//player.DiscardPile.PileChanged += new DominionBase.Pile.PileChangedEventHandler(DiscardPile_PileChanged);
				player.CardPlaying += new DominionBase.Players.Player.CardPlayingEventHandler(player_CardPlaying);
				player.CardPlayed += new DominionBase.Players.Player.CardPlayedEventHandler(player_CardPlayed);
				player.CardUndoPlaying += new DominionBase.Players.Player.CardUndoPlayingEventHandler(player_CardUndoPlaying);
				player.CardUndoPlayed += new DominionBase.Players.Player.CardUndoPlayedEventHandler(player_CardUndoPlayed);
				player.CardBuying += new DominionBase.Players.Player.CardBuyingEventHandler(player_CardBuying);
				player.CardBought += new DominionBase.Players.Player.CardBoughtEventHandler(player_CardBought);
				player.CardBuyFinished += new DominionBase.Players.Player.CardBuyFinishedEventHandler(player_CardBuyFinished);
				player.CardGaining += new DominionBase.Players.Player.CardGainingEventHandler(player_CardGaining);
				player.CardGainedInto += new DominionBase.Players.Player.CardGainedIntoEventHandler(player_CardGainedInto);
				player.CardGainFinished += new DominionBase.Players.Player.CardGainFinishedEventHandler(player_CardGainFinished);
				player.TokenPlaying += new DominionBase.Players.Player.TokenPlayingEventHandler(player_TokenPlaying);
				player.TokenPlayed += new DominionBase.Players.Player.TokenPlayedEventHandler(player_TokenPlayed);
				player.Trashing += new DominionBase.Players.Player.TrashingEventHandler(player_Trashing);
				player.TrashedFinished += new DominionBase.Players.Player.TrashedFinishedEventHandler(player_Trashed);
				player.PhaseChanged += new DominionBase.Players.Player.PhaseChangedEventHandler(player_PhaseChangedEvent);
				player.PlayerModeChanged += new DominionBase.Players.Player.PlayerModeChangedEventHandler(player_PlayerModeChangedEvent);
				player.CardsDrawn += new DominionBase.Players.Player.CardsDrawnEventHandler(player_CardsDrawn);
				player.TurnStarting += new DominionBase.Players.Player.TurnStartingEventHandler(player_TurnStarting);
				player.Shuffling += new DominionBase.Players.Player.ShufflingEventHandler(player_Shuffle);
				player.CardsAddedToDeck += new DominionBase.Players.Player.CardsAddedToDeckEventHandler(player_CardsAddedToDeck);
				player.CardsAddedToHand += new DominionBase.Players.Player.CardsAddedToHandEventHandler(player_CardsAddedToHand);
				player.CardsDiscarded += new DominionBase.Players.Player.CardsDiscardedEventHandler(player_CardsDiscarded);
				player.PlayerMats.CardMatsChanged += new DominionBase.Piles.CardMats.CardMatsChangedEventHandler(PlayerMats_DecksChanged);
				player.TokenPiles.TokenCollectionsChanged += new DominionBase.TokenCollections.TokenCollectionsChangedEventHandler(PlayerTokenPiles_TokenCollectionsChanged);
				player.BenefitsChanged += new DominionBase.Players.Player.BenefitsChangedEventHandler(player_BenefitsChanged);

				if (player == _Player)
				{
					tcAreas.SelectedItem = tiPlayer;
					player.CardReceived += new DominionBase.Players.Player.CardReceivedEventHandler(player_CardReceived);
				}
			}

			miNewGame.IsEnabled = false;
			miLoadGame.IsEnabled = false;
			miEndGame.IsEnabled = true;
			miSaveGame.IsEnabled = false;

			gameThread = new Thread(game.StartAsync);
			gameThread.Start();

			if (game.ActivePlayer != null)
			{
				if (game.Players[0] != game.ActivePlayer)
					glMain.NewTurn(game.TurnsTaken.TurnNumber(game.ActivePlayer));
				player_BenefitsChanged(game.ActivePlayer, new DominionBase.Players.BenefitsChangedEventArgs(game.ActivePlayer)
				{
					Actions = game.ActivePlayer.Actions,
					Buys = game.ActivePlayer.Buys,
					Currency = game.ActivePlayer.Currency,
					Player = game.ActivePlayer
				});
			}
			if (_Player.Phase == DominionBase.Players.PhaseEnum.Starting ||
					_Player.Phase == DominionBase.Players.PhaseEnum.Buy ||
					_Player.PlayerMode == DominionBase.Players.PlayerMode.Waiting)
				CheckBuyable(_Player);
			else
				ClearBuyable();
			UpdateDisplay();
		}