Ejemplo n.º 1
0
        //CHANGED NOW
        public Player.NeighborStatus GetPlayersNeighbor(int column, int row, Team.TeamColor team)
        {
            /* End of the board */
            if ((column < 0) || (row < 0) || (row >= Height) || (column >= Width))
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            /* Goal Area */
            if (row < GoalHeight)
            {
                if (team == Team.TeamColor.BLUE)
                {
                    Team.TeamCell teamCell = BlueTeam.isDiscovered(column, row);
                    if (teamCell == Team.TeamCell.FREE)
                    {
                        return(Player.NeighborStatus.GOAL_AREA);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_GOAL);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_NONGOAL);
                    }
                }
                else
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (Height - row - 1 < GoalHeight)
            {
                if (team == Team.TeamColor.RED)
                {
                    Team.TeamCell teamCell = RedTeam.isDiscovered(column, row);
                    if (teamCell == Team.TeamCell.FREE)
                    {
                        return(Player.NeighborStatus.GOAL_AREA);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_GOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_GOAL);
                    }
                    if (teamCell == Team.TeamCell.DISCOVERED_NONGOAL)
                    {
                        return(Player.NeighborStatus.DISCOVERED_NONGOAL);
                    }
                }
                else
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }

            /* Other player */
            foreach (Player p in RedTeam.members)
            {
                if (p.Column == column && p.Row == row)
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (RedTeam.leader.Column == column && RedTeam.leader.Row == row)
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            foreach (Player p in BlueTeam.members)
            {
                if (p.Column == column && p.Row == row)
                {
                    return(Player.NeighborStatus.BLOCKED);
                }
            }
            if (BlueTeam.leader.Column == column && BlueTeam.leader.Row == row)
            {
                return(Player.NeighborStatus.BLOCKED);
            }

            /* Piece */
            foreach (Piece p in Pieces)
            {
                if (p.column == column && p.row == row)
                {
                    return(Player.NeighborStatus.PIECE);
                }
            }

            /* Free cell */
            return(Player.NeighborStatus.FREE);
        }
Ejemplo n.º 2
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);
        }