/// <summary> /// Create a new game window /// </summary> /// <param name="players"></param> /// <param name="options"></param> public static GameController NewGame(List<Player> players, GameOptions options) { // Create a new game, with the players and options Game game = new Game(players, options); // Give the game to a new controller, which will set up the form and other things GameController controller = new GameController(game); // Count the window windowCount++; return controller; }
/// <summary> /// Create a new game with players and options /// </summary> /// <param name="gamePlayers"></param> /// <param name="gameOptions"></param> public Game(List<Player> gamePlayers, GameOptions gameOptions) : this() { // store parameters players = gamePlayers; options = gameOptions; // Create entries for each player in the hash table foreach (Player p in players) { playersCards.Add(p, new GamePlayer(p)); } }
public GameView(Game newGame, GameController gameController) { InitializeComponent(); toolTip = new ToolTip(); // Must redefine the background image to make the optimizing code work properly BackgroundImage = Properties.Resources.GameView; // Save the parameters game = newGame; controller = gameController; // Create picture boxes for each card, and store them in a hash table foreach (Card c in game.Deck) { cardsViews.Add(c, createPictureBoxForCard(c)); } // Add controls to their arrays playerLabels.Add(player1Label); playerLabels.Add(player2Label); playerLabels.Add(player3Label); playerLabels.Add(player4Label); playerComputerBadges.Add(player1ComputerBadge); playerComputerBadges.Add(player2ComputerBadge); playerComputerBadges.Add(player3ComputerBadge); playerComputerBadges.Add(player4ComputerBadge); // Set player name and type labels for (int i = 0; i < 4; i++) { if (i < game.Players.Count) { playerLabels[i].Text = game.Players[i].Name; playerComputerBadges[i].Image = Player.PlayerTypeBadge(game.Players[i].Type); } else { playerLabels[i].Visible = false; playerComputerBadges[i].Visible = false; } } // Set the game info message gameInfoMessage.Text = GameOptions.ScoringSystemToString(game.Options.ScoringSystem) + (game.Options.StopPlayingAfterFirst ? ",\r\nStopping after winner" : ""); // Handle the form closing event FormClosing += new FormClosingEventHandler(GameView_FormClosing); // Set up the end game highlight flashing timer endGameHighlightTimer.Interval = 500; endGameHighlightTimer.Tick += new EventHandler(endGameHighlightTimer_Tick); // Check if there's too many cards tooManyCards = game.NumberOfPlayers * game.Options.CardsForEachPlayer > 50; #if DEBUG debugControls.Visible = true; #endif }