Example #1
0
	public Game(BoardView boardView)
	{
		m_boardView = boardView;
		GameBoardBuilder builder = new GameBoardBuilder ();
		AddGameUnity (builder,Point.Make(0,4));

		m_logicBoard = builder.GetBoard ();

		m_currentSelection = m_logicBoard.Select (Point.Make(-1,-1));

		m_boardView.OnCellClicked.Register((x,y) =>{

			//TODO: Usar state pattern
			var point = Point.Make(x,y);
			Debug.Log(point);

			if(m_currentSelection.IsEmpty)
			{
				
				m_currentSelection = m_logicBoard.Select(point);
			}
			else
			{
				var visitor = new WalkVisitor(point);

				m_currentSelection.Commands.Visit(visitor);

				m_boardView.AddResult(visitor.Result);
				m_currentSelection = m_logicBoard.Select (Point.Make(-1,-1));
			}
		});

	}
Example #2
0
 public LevelFactory(ContentManager content, IBoard board, DoodadFactory doodadFactory, Session session)
 {
     this.content = content;
     this.board = board;
     this.doodadFactory = doodadFactory;
     this.session = session;
 }
Example #3
0
 public ChessEngine( IBoard board, IPlayer white, IPlayer black, ConfigChess config )
 {
     this.board = board;
     this.white = white;
     this.black = black;
     this.config = config;
 }
        // TODO: Castling checking
        public void VlidateMove(IFigure figure, IBoard board, Move move)
        {
            Position from = move.From;
            Position to = move.To;

            bool condition = (
                ((from.Col + 1) == to.Col) ||
                ((from.Col - 1) == to.Col) ||
                ((from.Row + 1) == to.Row) ||
                ((from.Row - 1) == to.Row) ||
                (((from.Row + 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
                (((from.Row - 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
                (((from.Row - 1) == to.Row) && ((from.Col - 1) == to.Col)) ||
                (((from.Row + 1) == to.Row) && ((from.Col - 1) == to.Col))
                );

            if (condition)
            {
                return;
            }
            else
            {
                throw new InvalidOperationException("King cannot move this way!");
            }
        }
 public Move GetNextFigureMove(IPlayer player,IBoard board)
 {
     Console.Write("{0} is next ", player.Name);
     var command = Console.ReadLine();
     Move move = player.Move(command,board);
     return move;
 }
Example #6
0
        public void move(ref IBoard board)
        {
            Console.WriteLine("### TURN FOR " + name.ToUpper() + " ###\n");

            for(;;)
            {
                Position position;

                try
                {
                    Console.Write("Move Row: ");
                    position.row = int.Parse(Console.ReadLine());
                    Console.Write("Move Column:");
                    position.column = int.Parse(Console.ReadLine());

                    if (board.move(this, position))
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("\nInvalid Move, Try Again :)\n");
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("\nInvalid Move, Try Again :)\n");
                }

            }
        }
 public KingSurvivalEngine(IRenderer renderer, IInputProvider inputProvider,IBoard board, IWinningConditions winningConditions)
 {
     this.renderer = renderer;
     this.provider = inputProvider;
     this.winningConditions = winningConditions;
     this.board = board;
 }
        public RecentThreadsViewModel(
            RecentThreadsService repositoryService,
            IBoard board,
            IShell shell,
            FavoriteThreadsService favoriteThreads)
            : base(repositoryService, board, shell) {

            FavoriteThreads = favoriteThreads;
            var dialog = new MessageDialog(
                Localization.GetForView("RecentThreads", "ClearConfirmationContent"),
                Localization.GetForView("RecentThreads", "ClearConfirmationTitle"));

            dialog.AddButton(
                Localization.GetForView("RecentThreads", "ConfirmClear"),
                async () => {
                    IsLoading = true;
                    Threads.Clear();
                    RepositoryService.Items.Clear();
                    await RepositoryService.Save();
                    IsLoading = false;
                });

            dialog.AddButton(
                Localization.GetForView("RecentThreads", "DontClear"), () => { });

            ClearConfirmationDialog = dialog;
        }
Example #9
0
        public override Move Move(string command,IBoard board)
        {
            int[] deltaRed = { -1, +1, +1, -1 }; //UR, DR, DL, UL

            int[] deltaColona = { +1, +1, -1, -1 };
            int indexOfChange = -1;

            if (command.Length != 3)
            {
                //TODO:Change the exception to custom exception
                throw new ArgumentOutOfRangeException("The command should contain three symbols");
            }

            switch (command)
            {
                case "adr":
                case "bdr":
                case "cdr":
                case "ddr":
                    { indexOfChange = 1; }
                    break;
                case "adl":
                case "bdl":
                case "cdl":
                case "ddl":
                    { indexOfChange = 2; }
                    break;
                default:
                    //TODO:change the exception to custom exception
                    throw new ArgumentOutOfRangeException("The command is not correct");
            }
            int pawnIndex = -1;
            switch (command[0])
            {
                case 'a':
                case 'A':
                    { pawnIndex = 0; }
                    break;
                case 'b':
                case 'B':
                    { pawnIndex = 1; }
                    break;
                case 'c':
                case 'C':
                    { pawnIndex = 2; }
                    break;
                case 'd':
                case 'D':
                    { pawnIndex = 3; }
                    break;
            }
            var fig = this.Figures;
            var oldPosition = board.GetFigurePosition(this.Figures[pawnIndex]);
            int pawnNewRow = oldPosition.Row + deltaRed[indexOfChange];
            int pawnNewColum = oldPosition.Col + deltaColona[indexOfChange];
            var newPosition = new Position(pawnNewRow, pawnNewColum);
            //Position.CheckIfValid(newPosition, GlobalErrorMessages.PositionNotValidMessage);
               // this.Figures[pawnIndex].Position = newPosition;
            return new Move(oldPosition, newPosition);
        }
Example #10
0
 /// <summary>
 /// bueno para produccion
 /// </summary>
 /// <param name="board"></param>
 public DominoGame(IBoard board)
 {
     Players = new List<IPlayer>();
     GameBoard = board;
     Stock = new Stock();
     PlayerTurn = 0;
 }
        protected void AddBoardToOutput(IBoard board, TagHelperOutput output, bool editable = false) {
            if (board == null) { throw new ArgumentNullException(nameof(board)); }
            if (output == null) { throw new ArgumentNullException(nameof(output)); }

            int counter = 0;
            output.Content.AppendEncoded($"{NewLine}{Indent}<table>{NewLine}");
            for (int row = 0; row < board.Size; row++) {

                output.Content.AppendEncoded($"{Indent}{Indent}<tr>{NewLine}");
                output.Content.AppendEncoded($"{Indent}{Indent}{Indent}");
                for (int col = 0; col < board.Size; col++) {
                    output.Content.AppendEncoded($"<td>");
                    if (!editable) {
                        output.Content.AppendEncoded($"{board[row, col]}");
                    }
                    else {
                        output.Content.AppendEncoded($"<input type=\"text\" value=\"{board[row,col]}\" name=\"board[{counter}]\" style=\"width:100%;\" maxlength=\"1\" />");
                    }
                    output.Content.AppendEncoded($"</td>");

                    counter++;
                }
                output.Content.AppendEncoded($"{NewLine}{Indent}{Indent}</tr>{NewLine}");
            }
            output.Content.AppendEncoded($"{Indent}</table>{NewLine}");
        }
Example #12
0
        public void RenderBoard(IBoard board)
        {
            this.PrintHorizontalNumbers();
            for (int row = 0; row < board.NumberOfRows; row++)
            {
                Console.Write(row + "| ");
                for (int column = 0; column < board.NumberOfColumns; column++)
                {
                    Position position = new Position(row, column);
                    var figure = board.GetFigureAtPosition(position);

                    if (figure != null)
                    {
                        Console.Write(figure.DisplayName + " ");
                    }
                    else
                    {
                        this.PrintCell(position);
                    }
                }

                Console.Write("|");
                Console.WriteLine();
            }

            this.PrintHorizontalLines();
        }
        public void DrawBoard(IBoard board)
        {
            StringBuilder result = new StringBuilder();

            // Append the numbers row first
            for (int i = 0; i < board.NumbersRow.Length; i++)
            {
                result.AppendFormat("{0, -2}", board.NumbersRow[i]);
            }

            result.AppendLine();

            // Append the rest of the rows
            for (int row = 0; row < board.Gamefield.GetLength(0); row++)
            {
                for (int col = 0; col < board.Gamefield.GetLength(1); col++)
                {
                    result.AppendFormat("{0, -2}", board.Gamefield[row, col]);
                }

                result.AppendLine();
            }

            Console.WriteLine(result.ToString());
        }
Example #14
0
        public void RenderBoard(IBoard board)
        {
            int counter = 0;
            int startRow = (Console.BufferHeight / 2) - ((board.Size / 2) * BoardCellSymbolsCount);
            int startCol = (Console.BufferWidth / 2) - ((board.Size / 2) * BoardCellSymbolsCount);

            this.PrintBoardBorder(startRow - Renderer.BorderSize, startCol - Renderer.BorderSize, board);

            for (int row = 0; row < board.Size; row++)
            {
                for (int col = 0; col < board.Size; col++)
                {
                    int printRow = startRow + (row * BoardCellSymbolsCount);
                    int printCol = startCol + (col * BoardCellSymbolsCount);
                    ConsoleColor color = counter % 2 == 0 ? Renderer.DarkBoardCells : Renderer.LigthBoardCells;
                    var figure = board.SeeFigureOnPosition(row, col);
                    this.PrintCell(printRow, printCol, color, figure);
                    counter++;
                }

                counter++;
            }

            Console.BackgroundColor = ConsoleColor.Black;
            Console.WriteLine();
        }
Example #15
0
        private void PrintBoardBorder(int startRow, int startCol, IBoard board)
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;

            int horizontalBoardSymbolTopRow = (Console.BufferWidth / 2) - ((board.Size / 2) * BoardCellSymbolsCount) - 2;
            int totalBoardCols = board.Size * Renderer.BoardCellSymbolsCount;
            var totalCols = totalBoardCols + (2 * Renderer.BorderSize);
            int startBoardCol = ((Console.BufferHeight / 2) - totalCols / 2) + (BoardCellSymbolsCount / 2) + Renderer.BorderSize;
            this.PrintBoardSide(startRow, startRow + Renderer.BorderSize, startCol, startCol + totalCols);
            this.PrintHorizontalSymbols(startBoardCol, totalBoardCols, horizontalBoardSymbolTopRow, board, Renderer.HorizontalBoardFirstSymbol);

            int horizontalBoardSymbolBottomRow = (Console.BufferWidth / 2) + ((board.Size / 2) * BoardCellSymbolsCount) + 1;
            var bottomStartRow = (Console.BufferHeight / 2) + (board.Size / 2 * Renderer.BoardCellSymbolsCount);
            this.PrintBoardSide(bottomStartRow, bottomStartRow + Renderer.BorderSize, startCol, startCol + totalCols);
            this.PrintHorizontalSymbols(startBoardCol, totalBoardCols, horizontalBoardSymbolBottomRow, board, Renderer.HorizontalBoardFirstSymbol);

            int totalBoardRows = board.Size * BoardCellSymbolsCount;
            int varticalBoardSymbolLeftCol = (Console.BufferHeight / 2) - ((board.Size / 2) * BoardCellSymbolsCount) - 2;
            var totalRows = (board.Size * Renderer.BoardCellSymbolsCount) + Renderer.BorderSize;
            int startBoardRow = ((Console.BufferHeight / 2) - totalCols / 2) + (BoardCellSymbolsCount / 2) + Renderer.BorderSize;
            this.PrintBoardSide(startRow, startRow + totalRows, startCol, startCol + Renderer.BorderSize);
            this.PrintVerticalSymbols(startBoardRow, totalBoardRows, varticalBoardSymbolLeftCol, board, Renderer.VerticalBoardFirstSymbol);

            var rigthBorderStartCol = Console.BufferWidth / 2 + (board.Size * Renderer.BoardCellSymbolsCount / 2);
            int varticalBoardSymbolRigthCol = (Console.BufferHeight / 2) + ((board.Size / 2) * BoardCellSymbolsCount) + 1;
            this.PrintBoardSide(startRow, startRow + totalRows, rigthBorderStartCol, rigthBorderStartCol + Renderer.BorderSize);
            this.PrintVerticalSymbols(startBoardRow, totalBoardRows, varticalBoardSymbolRigthCol, board, Renderer.VerticalBoardFirstSymbol);
        }
Example #16
0
 public static void CheckIfFigureOnTheWay(IPosition position, IBoard board, string message)
 {
     if (board.GetFigureAtPosition(position) != null)
     {
         throw new ArgumentException(message);
     }
 }
Example #17
0
        public void ValidateMove(IFigure figure, IBoard board, Move move)
        {
            var rowDistance = Math.Abs(move.From.Row - move.To.Row);
            var colDistance = Math.Abs(move.From.Col - move.To.Col);

            if (rowDistance != colDistance)
            {
                throw new InvalidOperationException(string.Format(GlobalConstants.ExceptionMessege, figure.Type));
            }

            int rowDirection = move.From.Row > move.To.Row ? -1 : 1;
            int colDirection = move.From.Col > move.To.Col ? -1 : 1;

            var row = move.From.Row;
            var col = move.From.Col;

            var endRow = move.To.Row + (rowDirection * (-1));
            var endCol = move.To.Col + (colDirection * (-1));

            while (row != endRow && col != endCol)
            {
                row += rowDirection;
                col += colDirection;

                if (board.SeeFigureOnPosition(row, col) != null)
                {
                    throw new InvalidOperationException(string.Format(GlobalConstants.ExceptionMessege, figure.Type));
                }
            }

            base.ValidateMove(figure, board, move);
        }
 public Player(IRandomGenerator generator, IBoard gameBoard, string name = "")
 {
     Generator = generator;
     GameBoard = gameBoard;
     Name = name;
     Position = 0;
 }
Example #19
0
 public bool CopyFrom(IBoard board)
 {
     if (Width != board.Width || Height != board.Height)
         return false;
     SetCells(board.Cells);
     return true;
 }
Example #20
0
 public PostsViewModel(IShell shell, IBoard board, string boardId, IList<PostViewModel> threadPosts, IEnumerable<PostViewModel> posts) {
     Posts = new ObservableCollection<PostViewModel>(posts.Select(CreatePostViewModel));
     BoardId = boardId;
     Board = board;
     ThreadPosts = threadPosts;
     Shell = shell;
 }
Example #21
0
 // コンストラクタ
 public ThreadProxy(int threadNumber, string title, int latestMessageNumber, IBoard board)
 {
     m_Id = threadNumber;
     m_Title = title;
     m_LatestMessageNumber = latestMessageNumber;
     m_Board = board;
 }
        public void AddFigureToBoard(IPlayer firstPlayser, IPlayer secondPlayer, IBoard board, string fen)
        {
            var splitedFen = fen.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            var index = 0;

            for (int row = splitedFen.Length - 1; row >= 0; row--)
            {
                var currentRow = this.MakeRow(splitedFen[row]);

                for (int col = 0; col < currentRow.Length; col++)
                {
                    if (currentRow[col] == Pown)
                    {
                        var pawn = new Pawn(secondPlayer.Color);
                        secondPlayer.AddFigure(pawn);
                        var position = new Position(index + 1, (char)(col + 'a'));
                        board.AddFigure(pawn, position);
                    }
                    else if (currentRow[col] == King)
                    {
                        var figureInstance = new King(firstPlayser.Color);
                        firstPlayser.AddFigure(figureInstance);
                        var position = new Position(index + 1, (char)(col + 'a'));
                        board.AddFigure(figureInstance, position);
                    }
                }

                index++;
            }
        }
 public StandardTwoPlayerEngine(IRenderer renderer, IInputProvider inputProvider)
 {
     this.renderer = renderer;
     this.input = inputProvider;
     movementStrategy = new NormalMovementStrategy();
     this.board = new Board();
 }
 public void Move(char player, IBoard board)
 {
     var freeSpaces = board.GetFreeSpaces();
     Random rnd = new Random();
     int r = rnd.Next(freeSpaces.Length);
     board.SetSpace(player, (int)Char.GetNumericValue(freeSpaces[r]));
 }
Example #25
0
        private bool CheckIfCheck(IBoard gameBoard, Position kingPosition, IDictionary<Position, IFigure> defenderFigures)
        {
            var defenderFiguresPositions = defenderFigures.Keys;
            var counter = 0;

            foreach (var position in defenderFiguresPositions)
            {
                var figure = defenderFigures[position];
                var availableMovements = figure.Move(this.strategy);

                try
                {
                    var tryMove = new Move(position, kingPosition);
                    this.CheckValidMove(figure, availableMovements, tryMove);
                }
                catch (Exception ex)
                {
                    counter++;
                }
            }
            if (counter == defenderFigures.Count)
            {
                return false;
            }

            return true;
        }
        public void VlidateMove(IFigure figure, IBoard board, Move move)
        {
            Position from = move.From;
            Position to = move.To;

            if (from.Row != to.Row && from.Col != to.Col)
            {
                throw new InvalidOperationException("Rook cannot move this way!");
            }

            if (to.Col > from.Col)
            {
                this.RightChecker(board, from, to);
                return;
            }
            else if (to.Col < from.Col)
            {
                this.LeftChecker(board, from, to);
                return;
            }
            else if (to.Row > from.Row)
            {
                this.TopChecker(board, from, to);
                return;
            }
            else if (to.Row < from.Row)
            {
                this.DownChecker(board, from, to);
                return;
            }
            else
            {
                throw new InvalidOperationException("Rook cannot move this way!");
            }
        }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShapeI"/> class.
        /// </summary>
        /// <param name="board">The board being used.</param>
        public ShapeI(IBoard board)
            : base(board)
        {
            // Initialize blocks
            blocks = new Block[] {
                new Block (board, Color.Cyan),
                new Block (board, Color.Cyan),
                new Block (board, Color.Cyan),
                new Block (board, Color.Cyan)
            };

            // Set block positions
            setBlockPositions();

            // Set rotations
            rotationOffset = new Point[][]
            {
                new Point[] { new Point(-2, -2), new Point(2, 2) },
                new Point[] { new Point(-1, -1), new Point(1, 1) },
                new Point[] { new Point(0, 0), new Point(0, 0) },
                new Point[] { new Point(1, 1), new Point(-1, -1) }
            };

            // 0 = no rotation
            // 1 = 90 degree rotation counterclockwise
            currentRotation = 0;

            length = blocks.Length;
        }
Example #28
0
        public override Move Move(string command,IBoard board)
        {
            int[] deltaRed = { -1, +1, +1, -1 }; //UR, DR, DL, UL

            int[] deltaColona = { +1, +1, -1, -1 };
            int indexOfChange = -1;

            if (command.Length != 3)
            {
                //TODO:change the exception to custom exception
                throw new ArgumentOutOfRangeException("The command should contain three symbols");
            }

            var oldPosition = board.GetFigurePosition(this.Figures[0]);

            switch (command)
            {
                case "kur": { indexOfChange = 0; } break;
                case "kdr": { indexOfChange = 1; } break;
                case "kdl": { indexOfChange = 2; } break;
                case "kul": { indexOfChange = 3; } break;
                default:
                    //TODO:change the exception to custom exception
                    throw new ArgumentOutOfRangeException("The command is not correct");

            }
            int newRow = oldPosition.Row + deltaRed[indexOfChange];
            int newColumn = oldPosition.Col + deltaColona[indexOfChange];
            var newPosition = new Position(newRow, newColumn);
            //Position.CheckIfValid(newPosition, GlobalErrorMessages.PositionNotValidMessage);
              //  this.Figures[0].Position = newPosition;
            return new Move(oldPosition, newPosition);
        }
        /// <summary>
        /// Clears all empty cells and moves all balloons on the column to rows greater than their current one if there are vacant indexes.
        /// </summary>
        /// <param name="board">The board object of the game.</param>
        private void ClearEmptyCells(IBoard board)
        {
            int row;
            int col;

            Queue<IBalloon> baloonsToPop = new Queue<IBalloon>();
            for (col = board.Cols - 1; col >= 0; col--)
            {
                for (row = board.Rows - 1; row >= 0; row--)
                {
                    if (board[row, col] != Balloon.Default)
                    {
                        baloonsToPop.Enqueue(board[row, col]);
                        board[row, col] = Balloon.Default;
                    }
                }

                row = board.Rows - 1;
                while (baloonsToPop.Count > 0)
                {
                    board[row, col] = baloonsToPop.Dequeue();
                    row--;
                }

                baloonsToPop.Clear();
            }
        }
        protected internal override IEnumerable<IMove> GetStrategyAvailableMoves(IBoard board, ITurn turn, IGameRuleStrategyContext context)
        {
            if (this.NeedToMovePiece(board, turn.Player))
                yield break;

            var playerName = turn.Player;
            var dice = this.GetAvailableDice(turn.Dice).OrderByDescending(x => x.Value).ToList();
            var firstPiece = false;
            for (var i = (board.Lanes.Count * 3) / 4; i < board.Lanes.Count; i++)
            {
                var lane = board.Lanes[i];
                if (lane.Count == 0 || lane[0].Player != playerName)
                    continue;

                foreach (var die in dice)
                {
                    if (i + die.Value == board.Lanes.Count ||
                        (i + die.Value > board.Lanes.Count && !firstPiece))
                    {
                        yield return new DefaultMove(board.Lanes[i], i, die);
                        firstPiece = true;
                    }
                }

                firstPiece = true;
            }
        }
Example #31
0
 public IEnumerable <string> NormalMoves(IBoard board)
 {
     throw new NotImplementedException();
 }
Example #32
0
        public void AddActivityHistoryToMember(IMember member, IWorkItem trackedWorkItem, ITeam trackedTeam, IBoard trackedBoard)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"Member: {member.Name} created: {trackedWorkItem.GetType().Name} with Title: {trackedWorkItem.Title} in Board: {trackedBoard.Name} part of {trackedTeam.Name} Team!");
            string resultToAddAssMessage        = sb.ToString().Trim();
            var    activityHistoryToAddToMember = new ActivityHistory(resultToAddAssMessage);

            member.ActivityHistory.Add(activityHistoryToAddToMember);
        }
 public void DisplayInitialBoard(IBoard board) => _displayInitialBoard.Invoke(board);
Example #34
0
 /// <summary>
 /// Constructs the Block object, which determines how a block will
 /// move on the board.
 /// </summary>
 /// <param name="board">The game board</param>
 /// <param name="colour">The color</param>
 /// <param name="position">The position</param>
 public Block(IBoard board, Color colour, Point position)
 {
     this.board    = board;
     this.colour   = colour;
     this.position = position;
 }
Example #35
0
        public string Execute()
        {
            Console.WriteLine("Please enter title of the story:");
            string title = Console.ReadLine();

            HelperMethods.ValidateWorkItemTitle(title);
            Console.Clear();
            Console.WriteLine("Please enter description of the story:");
            string description = Console.ReadLine();

            HelperMethods.ValidateWorkItemDescription(description);
            Console.Clear();
            Console.WriteLine($"Please choose priority of the story:{Environment.NewLine}" +
                              $"Type 1 for High.{Environment.NewLine}" +
                              $"Type 2 for Medium.{Environment.NewLine}" +
                              $"Type 3 for Low.{Environment.NewLine}");
            string   priorityUserInput = Console.ReadLine();
            Priority priority;

            switch (priorityUserInput)
            {
            case "1": priority = Priority.High; break;

            case "2": priority = Priority.Medium; break;

            case "3": priority = Priority.Low; break;

            default: return("invalid command");
            }
            Console.Clear();
            Console.WriteLine($"Please choose size of the story:{Environment.NewLine}" +
                              $"Type 1 for Large.{Environment.NewLine}" +
                              $"Type 2 for Medium.{Environment.NewLine}" +
                              $"Type 3 for Small.{Environment.NewLine}");
            string sizeUserInput = Console.ReadLine();
            Size   size;

            switch (sizeUserInput)
            {
            case "1": size = Size.Large; break;

            case "2": size = Size.Medium; break;

            case "3": size = Size.Small; break;

            default: return("invalid command");
            }
            Console.Clear();
            Console.WriteLine($"Please choose status of the story:{Environment.NewLine}" +
                              $"Type 1 for NotDone.{Environment.NewLine}" +
                              $"Type 2 for InProgress.{Environment.NewLine}" +
                              $"Type 3 for Done.{Environment.NewLine}");
            string      statusUserInput = Console.ReadLine();
            StoryStatus status;

            switch (statusUserInput)
            {
            case "1": status = StoryStatus.NotDone; break;

            case "2": status = StoryStatus.InProgress; break;

            case "3": status = StoryStatus.Done; break;

            default: return("invalid command");
            }
            Console.Clear();
            Console.WriteLine("Please enter the name of the team responsible for this story:");
            Console.WriteLine("List of teams:" + Environment.NewLine + HelperMethods.ListTeams(this.engine.Teams));
            string teamName     = Console.ReadLine();
            bool   ifTeamExists = HelperMethods.IfExists(teamName, engine.Teams);

            if (ifTeamExists == false)
            {
                return("Team with such name does not exist.");
            }
            ITeam teamToBeAssigned = HelperMethods.ReturnExisting(teamName, engine.Teams);

            Console.Clear();
            Console.WriteLine("Please enter board where to add this feedback:");
            Console.WriteLine("List of boards:" + Environment.NewLine + HelperMethods.ListBoards(teamToBeAssigned.Boards));
            string boardName     = Console.ReadLine();
            bool   ifBoardExists = HelperMethods.IfExists(boardName, teamToBeAssigned.Boards);

            if (ifBoardExists == false)
            {
                return($"Board with name {boardName} does not exist in team {teamToBeAssigned.Name}.");
            }
            IBoard boardToBeAssigned = HelperMethods.ReturnExisting(boardName, teamToBeAssigned.Boards);

            Console.Clear();
            Console.WriteLine("Please enter id of assigned member:");
            Console.WriteLine("List of members:" + Environment.NewLine + HelperMethods.ListMembers(teamToBeAssigned.Members));
            bool assigneeIdTry = int.TryParse(Console.ReadLine(), out int resultParse);
            int  assigneeId;

            if (assigneeIdTry == false)
            {
                return("invalid command");
            }
            else
            {
                assigneeId = resultParse;
            }
            bool ifMemberExists = HelperMethods.IfExists(assigneeId, teamToBeAssigned.Members);

            if (ifMemberExists == false)
            {
                return($"Member with id {assigneeId} does not exist in team {teamToBeAssigned.Name}.");
            }
            IMember memberToBeAssigned = HelperMethods.ReturnExisting(assigneeId, teamToBeAssigned.Members);

            var story = this.factory.CreateStory(title, description, priority, size, status, memberToBeAssigned);

            this.engine.Stories.Add(story);
            boardToBeAssigned.WorkItems.Add(story);
            memberToBeAssigned.WorkItems.Add(story);
            string result = HelperMethods.TimeStamp() + story.ToString() + $" was created in board {boardName} and assigned to {memberToBeAssigned.Name} with ID {memberToBeAssigned.MemberID}";

            story.History.Add(result);
            teamToBeAssigned.History.Add(result);
            boardToBeAssigned.History.Add(result);
            memberToBeAssigned.History.Add(result);

            return(result);
        }
Example #36
0
 public IEnumerable <string> Mills(IBoard board)
 {
     throw new NotImplementedException();
 }
Example #37
0
 public bool MillFormed(IBoard board)
 {
     throw new NotImplementedException();
 }
 /// Instantiates ShapeO.
 public ShapeO(IBoard board) : base(board, setBlocks(board), null)
 {
 }
Example #39
0
 /// <summary>
 /// The DrawSimpleDot
 /// </summary>
 /// <param name="board">The board<see cref="IBoard"/></param>
 public void DrawSimpleDot(IBoard board)
 {
     this.WriteAt(".", board.BoardSizeX / 2, board.BoardSizeY / 2);
     Console.SetCursorPosition(0, board.BoardSizeY + 2);
 }
 public PickUpAvailabilityChain(Location location, IBoard board, int playerId)
 {
     _location = location;
     _board    = board;
     _playerId = playerId;
 }
 public IBoardMoveService Create(IBoard board)
 {
     return(new BoardMoveService(board));
 }
 public PlayerFactory(string[] names, IRandomGenerator generator, IBoard board)
 {
     _playerNames = names;
     _generator   = generator;
     _board       = board;
 }
Example #43
0
 public ConsoleAppRegistry()
 {
     ShowDrawingToUser = new Drawing();
     ProcessUserInput  = new ProcessUserInput();
     GetEmptyBoard     = new Board();
 }
Example #44
0
 /// <summary>
 /// The ClearConsole
 /// </summary>
 /// <param name="board">The board<see cref="IBoard"/></param>
 public void ClearConsole(IBoard board)
 {
     Console.Clear();
 }
Example #45
0
        public sealed override void HandleAccept(Controller controller)
        {
            IModel     model        = controller.Model;
            ISelection selection    = model.CurrentSelection;
            IBoard     visibleBoard = model.CurrentGameBox.CurrentGame.VisibleBoard;

            if (selection != null && !selection.Empty)
            {
                IStack stack = selection.Stack;
                if (stack.AttachedToCounterSection)
                {
                    if (stack.Board == visibleBoard)
                    {
                        model.CommandManager.ExecuteCommandSequence(
                            new MoveAttachedStackCommand(model, stack, newPosition));
                    }
                    else
                    {
                        model.CommandManager.ExecuteCommandSequence(
                            new MoveAttachedStackFromOtherBoardCommand(model, stack, visibleBoard, newPosition));
                    }
                }
                else
                {
                    if (stack.Pieces.Length == selection.Pieces.Length)
                    {
                        if (stack.Board == visibleBoard)
                        {
                            model.CommandManager.ExecuteCommandSequence(
                                new CommandContext(visibleBoard, stack.BoundingBox),
                                new CommandContext(visibleBoard),
                                new MoveStackCommand(model, stack, newPosition));
                        }
                        else
                        {
                            model.CommandManager.ExecuteCommandSequence(
                                new CommandContext(stack.Board, stack.BoundingBox),
                                new CommandContext(visibleBoard),
                                new MoveStackFromOtherBoardCommand(model, stack, visibleBoard, newPosition));
                        }
                    }
                    else
                    {
                        if (stack.Board == visibleBoard)
                        {
                            model.CommandManager.ExecuteCommandSequence(
                                new CommandContext(visibleBoard, stack.BoundingBox),
                                new CommandContext(visibleBoard),
                                new MoveSubSelectionCommand(model, selection, newPosition));
                        }
                        else
                        {
                            model.CommandManager.ExecuteCommandSequence(
                                new CommandContext(stack.Board, stack.BoundingBox),
                                new CommandContext(visibleBoard),
                                new MoveSubSelectionFromOtherBoardCommand(model, selection, visibleBoard, newPosition));
                        }
                    }
                }
            }
        }
 public void Initialize() => _board = new Board(_solveTechniques);
Example #47
0
 public ScoreCalculator(IBoard board)
 {
     _board = board;
 }
 /// <param name="rentPriceMultiplicator">rent price multiplicator list according to whether or not all utilities belong to the same player. The rent price will be (the multiplicator * the dice value)</param>
 public Utility(string id, string name, int buyPrice, int[] rentPriceMultiplicator, IBoard board = null) : base(id, name, buyPrice, rentPriceMultiplicator, board)
 {
 }
Example #49
0
 public bool canShoot(IPlayer player, IBoard booard)
 {
     throw new NotImplementedException();
 }
Example #50
0
 public DragDropAttachedStackFromOtherBoardCommand(IModel model, IStack stack, IBoard boardAfter, PointF positionAfter)
     : base(model)
 {
     this.stack         = stack;
     this.boardAfter    = boardAfter;
     this.positionAfter = positionAfter;
 }
Example #51
0
        public void ValidateMove(IFigure figure, IBoard board, Move move)
        {
            var color            = figure.Color;
            var other            = figure.Color == ChessColor.White ? ChessColor.Black : ChessColor.White;
            var from             = move.From;
            var to               = move.To;
            var figureAtPosition = board.GetFigureAtPosition(to);

            if (color == ChessColor.White && to.Row < from.Row)
            {
                throw new InvalidOperationException(PawnBackwardsErrorMessage);
            }

            if (color == ChessColor.Black && to.Row > from.Row)
            {
                throw new InvalidOperationException(PawnBackwardsErrorMessage);
            }

            if (color == ChessColor.White)
            {
                if (from.Row + 1 == to.Row && this.CheckDiagonalMove(from, to))
                {
                    if (this.CheckOtherFigureIfValid(board, to, other))
                    {
                        return;
                    }
                }
                if (from.Row == 2 && !this.CheckDiagonalMove(from, to))
                {
                    if (from.Row + 2 == to.Row && figureAtPosition == null)
                    {
                        return;
                    }
                }
                if (from.Row + 1 == to.Row && !this.CheckDiagonalMove(from, to))
                {
                    if (figureAtPosition == null)
                    {
                        return;
                    }
                }
            }
            else if (color == ChessColor.Black)
            {
                if (from.Row - 1 == to.Row && this.CheckDiagonalMove(from, to))
                {
                    if (this.CheckOtherFigureIfValid(board, to, other))
                    {
                        return;
                    }
                }
                if (from.Row == 7 && !this.CheckDiagonalMove(from, to))
                {
                    if (from.Row - 2 == to.Row && figureAtPosition == null)
                    {
                        return;
                    }
                }
                if (from.Row - 1 == to.Row && !this.CheckDiagonalMove(from, to))
                {
                    if (figureAtPosition == null)
                    {
                        return;
                    }
                }
            }

            throw new InvalidOperationException(PawnInvalidMove);
        }
Example #52
0
 public bool isValidMove(string currPos, string posMoveTo, IBoard board)
 {
     throw new NotImplementedException();
 }
Example #53
0
 public CommandContext(BoardMemory memento, IBoard board, IPlayer player)
 {
     this.Memory = memento;
     this.Board  = board;
     this.Player = player;
 }
Example #54
0
 public LegalMoves(IBoard board, ICowBox cowBox)
 {
     this.board  = board;
     this.cowBox = cowBox;
 }
 public MainWindowViewModel(IReadOnlyList <IPlayerViewModel> playerViewModels, IBoardViewModel boardViewModel, IBoard board)
 {
     _playerViewModels = playerViewModels;
     _boardViewModel   = boardViewModel;
     _board            = board;
 }
Example #56
0
        public void Get(IBoard board, Point point)
        {
            var actual = board.Get(point);

            actual.Should().Be(9);
        }
Example #57
0
 /// <summary>
 /// Apply the new Cell State
 /// </summary>
 /// <param name="board"></param>
 /// <param name="row"></param>
 /// <param name="col"></param>
 /// <returns></returns>
 protected virtual int GetNewState(IBoard board, int row, int col) =>
 _gameRules.ApplyLiveRules(board[row, col], board.GetLiveNeighbours(row, col));
 public Feedback(string title, string description, int rating, IBoard board)
     : base(title, description, board)
 {
     this.Rating = rating;
     this.Status = FeedbackStatusType.Unscheduled;
 }
Example #59
0
 /// <summary>
 /// Evolve game to next generation
 /// </summary>
 public void Evolve() => _gameBoard = Evolve(_gameBoard);
Example #60
0
    private void CheckTerminalBoard(IGame curGame, IBoard board)
    {
        bool         terminal    = false;
        List <ICard> toTestDiag1 = new List <ICard>();
        List <ICard> toTestDiag2 = new List <ICard>();

        for (int i = 0; i < 5 && !terminal; i++)
        {
            List <ICard> toTestHoriz = new List <ICard>();
            List <ICard> toTestVert  = new List <ICard>();
            ICard        card1       = board.GetCardAtSpace(i, i);
            ICard        card2       = board.GetCardAtSpace(i, 4 - i);
            if (card1 != null)
            {
                toTestDiag1.Add(card1);
            }
            if (card2 != null)
            {
                toTestDiag2.Add(card2);
            }
            for (int j = 0; j < 5 && (toTestHoriz.Count == j || toTestVert.Count == j); j++)
            {
                ICard card3 = board.GetCardAtSpace(j, i);
                ICard card4 = board.GetCardAtSpace(i, j);
                if (card3 != null && board.isKnown(1, j, i))
                {
                    toTestHoriz.Add(card3);
                }
                if (card4 != null && board.isKnown(1, i, j))
                {
                    toTestVert.Add(card4);
                }
            }

            if (toTestVert.Count != 5 && toTestHoriz.Count != 5)
            {
                continue;
            }

            foreach (HANDTYPE t in Enum.GetValues(typeof(HANDTYPE)))
            {
                if (curGame.CheckGameOverClaim(toTestHoriz, t))
                {
                    for (int j = 0; j < 5; j++)
                    {
                        var space1 = (from space in FindObjectsOfType <BoardSpaceStruct>() where (space.x == j && space.y == i) select space).FirstOrDefault();
                        StartCoroutine(displayOutline(space1, 2f));
                        if (!space1.isFaceup())
                        {
                            space1.flipUp();
                        }
                    }
                    model.GameLost();
                    return;
                }
                else if (curGame.CheckGameOverClaim(toTestVert, t))
                {
                    for (int j = 0; j < 5; j++)
                    {
                        var space1 = (from space in FindObjectsOfType <BoardSpaceStruct>() where (space.x == i && space.y == j) select space).FirstOrDefault();
                        StartCoroutine(displayOutline(space1, 2f));
                        if (!space1.isFaceup())
                        {
                            space1.flipUp();
                        }
                    }
                    model.GameLost();
                    return;
                }
            }
        }
        foreach (HANDTYPE t in Enum.GetValues(typeof(HANDTYPE)))
        {
            if (curGame.CheckGameOverClaim(toTestDiag1, t))
            {
                for (int j = 0; j < 5; j++)
                {
                    var space1 = (from space in FindObjectsOfType <BoardSpaceStruct>() where (space.x == j && space.y == j) select space).FirstOrDefault();
                    StartCoroutine(displayOutline(space1, 2f));
                }
                model.GameLost();
                return;
            }
            else if (curGame.CheckGameOverClaim(toTestDiag2, t))
            {
                for (int j = 0; j < 5; j++)
                {
                    var space1 = (from space in FindObjectsOfType <BoardSpaceStruct>() where (space.x == j && space.y == 4 - j) select space).FirstOrDefault();
                    StartCoroutine(displayOutline(space1, 2f));
                }
                model.GameLost();
                return;
            }
        }
    }