//internal enum TileBorders { Top, Bottom, Right, Left }; public Board() { foreach (int j in new Range(0, 8)) { foreach (int i in new Range(0, 11)) { Tile t = new Tile(null, (i + 1).ToString() + Enum.GetName(typeof(ColumnLetters), j)); tiles[i, j] = t; AvailableTiles.Add(tiles[i, j]); } } }
private void recursiveSetHotel(Tile t, StockCard.Type hotel, ArrayList calledTiles) { if (calledTiles != null) { calledTiles.Add(t); } else { calledTiles = new ArrayList(); } ArrayList BorderingTiles = Board.GetNeighborsforTile(t); ArrayList toCall = new ArrayList(); foreach (Tile borderingTile in BorderingTiles) { if (!calledTiles.Contains(borderingTile)) { toCall.Add(borderingTile); } } foreach (Tile tile in toCall) { recursiveSetHotel(tile, hotel, calledTiles); } t.Hotel = hotel; }
private void placeTile(Player p, Tile t) { Board.PlacedTiles.Add(t); t.Owner = null; t.Placed = true; //remove tile from player's stash p.takeTile(t); p.TilesLeftToPlay--; //update UI GameWindow.Instance.updateUI(p); }
internal void StartGame() { gameInProgress = true; // Add button listeners foreach (Tile t in Board.Tiles) { t.Button.Click += tileButton_Click; } foreach (Button b in GameWindow.Instance.Controls["stockgroupbox"].Controls) { b.Click += stockButton_Click; } // add event listeners to special card buttons SpecialCard.getButton(SpecialCard.Type.Buy5).Click += new EventHandler(Buy5Button_Click); SpecialCard.getButton(SpecialCard.Type.Free3).Click += new EventHandler(Free3Button_Click); SpecialCard.getButton(SpecialCard.Type.Pick5).Click += new EventHandler(Pick5Button_Click); SpecialCard.getButton(SpecialCard.Type.Play3).Click += new EventHandler(Play3Button_Click); SpecialCard.getButton(SpecialCard.Type.Trade2).Click += new EventHandler(Trade2Button_Click); GameWindow.Instance.Controls["doneButton"].Click += doneButton_Click; // Add players PlayerSelection playerSelection = new PlayerSelection(); playerSelection.ShowDialog(); // get players and have them draw a random tile Dictionary<Tile, Player> d = new Dictionary<Tile, Player>(); foreach (String name in playerSelection.names) { Player p = new Player(name); //Just use the first tile the player drew as his pick to determine order d.Add((Tile)p.Tiles[0], p); } Tile[] tiles = new Tile[d.Count]; d.Keys.CopyTo(tiles, 0); Array.Sort(tiles); //Array.Reverse(tiles); foreach (Tile tile in tiles) { AddPlayer(d[tile]); placeTile(d[tile], tile); } // add players to the UI foreach (int i in new Range(0, Players.Count - 1)) { Player p = Players[(String)PlayerOrder[i % Players.Count]]; p.Label.Location = new System.Drawing.Point(8, 19 + (i * 15)); GameWindow.Instance.PlayersGroupBox.Controls.Add(p.Label); } doTurn(Players[(string)PlayerOrder[0]]); }
public Tile takeTile(Tile t) { if (!Tiles.Contains(t)) { throw new Exception("Couldn't find tile: " + t + " in player's tiles."); } else { Tiles.Remove(t); return t; } }
public void giveTile(Tile t) { if (Tiles.Count == 6 && hasSpecial(SpecialCard.Type.Pick5)) { throw new Exception("Tried to add too many tiles."); } else { Tiles.Add(t); t.Owner = this; } }
internal ArrayList GetNeighborsforTile(Tile t) { return GetNeighborsforTile(t.Name); }