Exemplo n.º 1
0
        public void IsSingleMoveRightValid()
        {
            INextValueGenerator <sbyte> generatorMock = MockRepository.GenerateStub <INextValueGenerator <sbyte> >();

            generatorMock.Stub(m => m.NextPosition(Arg <sbyte> .Is.Anything)).Return(0); //put initial value to cell "4" [0,0]
            generatorMock.Stub(m => m.NextValue()).Return(2);                            //cell Value shall be 2
            IGameBoard board = InitBoard(4, generatorMock);

            board.MoveRight(); //Now cell [0,1] must contains 2
            Assert.AreEqual(board.To2DArray()[0, board.Size - 1].Value, 2);
        }
Exemplo n.º 2
0
Arquivo: Board.cs Projeto: knjz/2048
        public Board(SByte size = 4, INextValueGenerator<sbyte> generator = null)
        {
            m_size = size;
            m_board = new List<Tile>(m_size * m_size);
            sbyte y = 0;
            for (SByte x = 0; x < m_size * m_size; x++)
            {
                if ((x % m_size == 0) && (x > 0))
                    y++;

                m_board.Add(new Tile { X = y, Y = (sbyte)(x - (sbyte)(y * m_size)) });
            }
            NextValueGenerator = generator ?? new StandardNextValueGenerator();
            NextFill();
        }
Exemplo n.º 3
0
        public Board(SByte size = 4, INextValueGenerator <sbyte> generator = null)
        {
            m_size  = size;
            m_board = new List <Tile>(m_size * m_size);
            sbyte y = 0;

            for (SByte x = 0; x < m_size * m_size; x++)
            {
                if ((x % m_size == 0) && (x > 0))
                {
                    y++;
                }

                m_board.Add(new Tile {
                    X = y, Y = (sbyte)(x - (sbyte)(y * m_size))
                });
            }
            NextValueGenerator = generator ?? new StandardNextValueGenerator();
            NextFill();
        }
Exemplo n.º 4
0
 public IGameBoard InitBoard(sbyte size, INextValueGenerator<sbyte> generator)
 {
     return new Board(size, generator);
 }
Exemplo n.º 5
0
 public IGameBoard InitBoard(sbyte size, INextValueGenerator <sbyte> generator)
 {
     return(new Board(size, generator));
 }