示例#1
0
        public Status[,] boardtable; // column row


        public Status getCellStatus(int col, int row)
        {
            if ((col < 0) || (row < 0) || (row >= Height) || (col >= Width))
            {
                return(Status.END_OF_BOARD);
            }

            #region Player Occupation
            /* Check if RED player occupaes a cell */
            if (RedTeam.isTaken(col, row) == Team.TeamCell.PLAYER)
            {
                return(Board.Status.RED_PLAYER);
            }
            else if (RedTeam.isTaken(col, row) == Team.TeamCell.PLAYER_PIECE)
            {
                return(Board.Status.RED_PLAYER_WITH_PIECE);
            }

            /* Check if BLUE player occupaes a cell */
            if (BlueTeam.isTaken(col, row) == Team.TeamCell.PLAYER)
            {
                return(Board.Status.BLUE_PLAYER);
            }
            else if (BlueTeam.isTaken(col, row) == Team.TeamCell.PLAYER_PIECE)
            {
                return(Board.Status.BLUE_PLAYER_WITH_PIECE);
            }
            #endregion

            #region Check if PIECE occupaes a cell
            /* Check if PIECE occupaes a cell */
            foreach (var item in Pieces)
            {
                if (item.isTaken(col, row))
                {
                    if (item.isSham)
                    {
                        return(Board.Status.SHAM);
                    }
                    else
                    {
                        return(Board.Status.PIECE);
                    }
                }
            }
            #endregion

            #region Goal
            /* Checks if GOAL belongs to a SPECIFIC type of goal */
            foreach (var item in UndiscoveredRedGoals)
            {
                if (item.isTaken(col, row))
                {
                    return(Board.Status.UNDISCOVERED_GOAL);
                }
            }

            foreach (var item in UndiscoveredBlueGoals)
            {
                if (item.isTaken(col, row))
                {
                    return(Board.Status.UNDISCOVERED_GOAL);
                }
            }

            foreach (var item in DiscoveredRedGoals)
            {
                if (item.isTaken(col, row))
                {
                    return(Board.Status.DISCOVERED_GOAL);
                }
            }

            foreach (var item in DiscoveredBlueGoals)
            {
                if (item.isTaken(col, row))
                {
                    return(Board.Status.DISCOVERED_GOAL);
                }
            }

            foreach (var item in NonGoals)
            {
                if (item.isTaken(col, row))
                {
                    return(Board.Status.DISCOVERED_NON_GOAL);
                }
            }

            #endregion

            /* Is goal BLUE area */
            if (row < GoalHeight)
            {
                Team.TeamCell teamCell = BlueTeam.isDiscovered(col, row);
                if (teamCell == Team.TeamCell.FREE)
                {
                    return(Board.Status.BLUE_GOALS_CELL);
                }
                if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                {
                    return(Board.Status.DISCOVERED_GOAL);
                }
                if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                {
                    return(Board.Status.DISCOVERED_NON_GOAL);
                }
            }
            /* Is goal RED area */
            if (Height - row - 1 < GoalHeight)
            {
                Team.TeamCell teamCell = RedTeam.isDiscovered(col, row);
                if (teamCell == Team.TeamCell.FREE)
                {
                    return(Board.Status.RED_GOALS_CELL);
                }
                if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                {
                    return(Board.Status.DISCOVERED_GOAL);
                }
                if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                {
                    return(Board.Status.DISCOVERED_NON_GOAL);
                }
            }

            return(Board.Status.TASK_CELL);
        }