Beispiel #1
0
        public static void __Resize(int x, int y, int z)
        {
            var old_map = __Map;

            __Map = new Game.Tile[x, y, z];

            // LOOKS LIKE THE WHOLE ZONE SINGLETON THING ISNT HANDLED IN A FUCKY WAY -- HOORAY! (still need to investigate!)
            Game.Zone zone_instance = __GetZoneInstance(Game13.default_zone);

            for (int ix = 0; ix < x; ix++)
            {
                for (int iy = 0; iy < y; iy++)
                {
                    for (int iz = 0; iz < z; iz++)
                    {
                        if (ix < old_map.GetLength(0) && iy < old_map.GetLength(1) && iz < old_map.GetLength(2))
                        {
                            __Map[ix, iy, iz] = old_map[ix, iy, iz];
                        }
                        else
                        {
                            Game.Tile tile_instance = Base_Tile.RawCreate(Game13.default_tile, ix + 1, iy + 1, iz + 1);

                            zone_instance.contents.Add(tile_instance);
                        }
                    }
                }
            }
        }
        public bool WillTokenPlacedWinGameForPlayer(
            Object player,
            Game.Tile tile)
        {
            int directlyConnectingCount = 0;

            //Count Backwards
            int currentIndex = _tiles.IndexOf(tile) - 1;

            while (currentIndex >= 0 && _tiles[currentIndex].OwningPlayer == player)
            {
                directlyConnectingCount++;
                currentIndex--;
            }

            //Count Forwards
            currentIndex = _tiles.IndexOf(tile) + 1;
            while (currentIndex < _tiles.Count && _tiles[currentIndex].OwningPlayer == player)
            {
                directlyConnectingCount++;
                currentIndex++;
            }

            return(directlyConnectingCount >= 3);
        }
Beispiel #3
0
        static public bool IsDirectlyWinnableOnTileForPlayer(Game.Board board, Game.Tile tile, Object player)
        {
            //Get all the tile connections on this given tile.
            var connections = board.GetAllTileConnectionsForTile(tile.ColumnNo, tile.RowNo);

            //check each of them for a win, and return true if any of them is a winning connection
            var directlyWinnable = new List <Tile>();

            foreach (TileConnection tc in connections)
            {
                if (tc.WillTokenPlacedWinGameForPlayer(player, tile))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        public static Game.Tile RawCreate(Type t, int x, int y, int z)
        {
            if (!t.IsSubclassOf(typeof(Base_Tile)))
            {
                throw new Exception("Bad tile type!");
            }

            use_next = true;

            next_x = x;
            next_y = y;
            next_z = z;

            Game.Tile result = Lang13.Call(t);

            use_next = false;

            return(result);
        }
Beispiel #5
0
 /// <summary>
 /// An immediatley placable tile is a tile that would be filled by the next token dropped on that column
 /// </summary>
 /// <param name="tile"></param>
 /// <returns></returns>
 static public bool IsTileImmediatleyPlacable(Game.Board board, Game.Tile tile)
 {
     if (tile.OwningPlayer != null)
     {
         //if there is already a token on the tile then it can't be placeable
         return(false);
     }
     else if (tile.RowNo == 0)
     {
         //if we are on the bottom row, then we must be placable
         return(true);
     }
     else if (board[tile.ColumnNo][tile.RowNo - 1].OwningPlayer != null)
     {
         //else if the tile below us is filled, then we are placable
         return(true);
     }
     else
     {
         //otherwise we are not
         return(false);
     }
 }
Beispiel #6
0
        static private bool CheckTwoTurnCompulsionWinForTile(Game.GameCore game, Object player, Game.Tile tile)
        {
            //Create a copy of the game to test with, ensuring that it is the player we are checking's turn
            var testGame = game.Copy(player);

            //Drop a token on the column
            testGame.DropTokenOnColumn(tile.Column.ColumnNo);

            //Check if the other player will compulsed to make a blocking move, which will be the case if
            //we have a winning move
            var winPossibilities = FindDirectWinningPossibilities(testGame.Board, player);

            //Check that we can make a winning move
            var won = false;

            winPossibilities.ForEach(winingTile => {
                var blockedGame = testGame.Copy();
                blockedGame.DropTokenOnColumn(winingTile.Column.ColumnNo); //simulate the opponent dropping a blocking tile
                var finishingMovePosibilities = FindDirectWinningPossibilities(blockedGame.Board, player);
                if (finishingMovePosibilities.Count > 0)
                {
                    //make sure that we don't give the game away though
                    var opponentWins = FindDirectWinningPossibilities(testGame.Board, game.GetOtherPlayer(player));
                    if (opponentWins.Count() == 0)
                    {
                        won = true; //c# question: how do we return out of the parent function here?
                    }
                }
            });

            return(won);
        }
Beispiel #7
0
        //ToDo: ???TestME
        /// <summary>
        /// Method looks for all connections that include the given tile which would could possibly
        /// be used to win. So this doesn't include any opponent tiles, but will include empty
        /// and own tiles.
        /// </summary>
        /// <param name="board"></param>
        /// <param name="tile"></param>
        static private List <TileConnection> FindAllPossibleWinnableConnectionsForPlayerTile(Game.Board board, Game.Tile tile)
        {
            var allTileConnections = new List <List <Game.Tile> > {
                board.Columns[tile.ColumnNo].Tiles,            //Check vertical
                board.GetRow(tile.RowNo),                      //Check horizontal
                board.GetPositiveDiagonalTilesFromStartingRow( //Check positive diagonal
                    tile.GetPositiveDiagonalStartingRowNo()),
                board.GetNegativeDiagonalTilesFromStartingRow( //Check negative diagonal
                    tile.GetNegativeDiagonalStartingRowNo())
            };

            var winnableConnections = new List <TileConnection>();

            allTileConnections.ForEach(tileSet => {
                var winnableConnection = (new TileConnection(tileSet)).GetWinnableConnectionAround(tile);
                if (winnableConnection != null)
                {
                    winnableConnections.Add(winnableConnection);
                }
            });
            return(winnableConnections);
        }
Beispiel #8
0
 public UIBoardTile(UIBoardColumn uiColumn, Game.Tile tile)
 {
     _uiColumn = uiColumn;
     _tile     = tile;
     this.Size = TileSize;
 }