Exemplo n.º 1
0
 public void DiagonalMovePathCheck()
 {
     var m = new DiagonalMoveTemplate();
     var s = new GameState(3, 3);
     s[new Position(2, 2)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(1, 1), new Position(3, 3), s));
 }
Exemplo n.º 2
0
 public Piece(Piece copy)
 {
     IsEmpty = copy.IsEmpty;
     Player = copy.Player;
     Pos = copy.Pos;
     PossibleMoves = new List<ITemplateMove>(copy.PossibleMoves);
     path = new Stack<Position>(copy.Path);
 }
Exemplo n.º 3
0
        public void MoveTest()
        {
            var p = new Piece();
            var pos = new Position(1, 1);
            p.Move(pos);

            Assert.AreEqual(1, p.PathLength);
            Assert.AreEqual(pos, p.Pos);
        }
Exemplo n.º 4
0
        public void NewEmptyPiece()
        {
            var s = new GameState(5, 5);
            var pos = new Position(3, 3);
            s[pos] = new Piece();

            s.NewEmptyPiece(pos);

            Assert.IsTrue(s[pos].IsEmpty);
        }
Exemplo n.º 5
0
        public void UnmoveTest()
        {
            var to = new Position(1, 1);
            var p = new Piece();
            p.Move(to);
            p.Unmove();

            Assert.AreEqual(0, p.PathLength);
            Assert.AreEqual(null, p.Pos);
        }
Exemplo n.º 6
0
        public void CaptureMove()
        {
            var s = new GameState(5, 5);
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            s[from] = new Piece();
            var movingPiece = s[from];
            s[to] = new Piece();
            var m = new ConcreteMove(from, to);

            m.Apply(s);

            Assert.AreEqual(s[to], movingPiece);
        }
Exemplo n.º 7
0
        public void GetConcreteFromTemplate()
        {
            var s = new GameState(5, 5);
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            s[from] = new Piece();
            var movingPiece = s[from];
            var m = new MockTemplate().Concretize(from, to);

            m.Apply(s);

            Assert.IsTrue(s[from].IsEmpty);
            Assert.AreNotEqual(s[from], movingPiece);
            Assert.AreEqual(s[to], movingPiece);
        }
Exemplo n.º 8
0
        public void MakeMoveIsStateChanged()
        {
            var g = new MockGame();
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            var p = new Piece();
            var m = new ConcreteMove(from, to);
            g.State[from] = p;
            p.Move(from);
            g.AddMove(m);

            g.MakeMove();

            Assert.AreEqual(p, g.State[to]);
        }
Exemplo n.º 9
0
        public void MakeMove()
        {
            var g = new MockGame();
            var from = new Position(1, 1);
            var to = new Position(2, 2);
            var p  = new Piece();
            var m = new ConcreteMove(from, to);
            g.State[from] = p;
            p.Move(from);
            g.AddMove(m);

            bool result = g.MakeMove();

            Assert.AreEqual(1, g.MovesCount);
            Assert.AreEqual(1, g.CurrentMove);
            Assert.IsTrue(result);
        }
 public void GetPresentationException()
 {
     var p = new EnglishFENPresentation();
     var o = new Piece();
     p.GetPresentation(o);
 }
Exemplo n.º 11
0
 public virtual void NewEmptyPiece(Position pos)
 {
     var p = new Piece {IsEmpty = true};
     this[pos] = p;
     p.Move(pos);
 }
Exemplo n.º 12
0
 public void TemplateMovePathCheck()
 {
     var m = new MockTemplate(null, null, true);
     var s = new GameState(5, 5);
     s[new Position(3, 4)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(3, 3), new Position(3, 5), s));
 }
Exemplo n.º 13
0
 public void TemplateMoveNotCapture()
 {
     var m = new MockTemplate(null, false);
     var s = new GameState(5, 5);
     s[new Position(5, 5)] = new Piece();
     Assert.IsFalse(m.CanApply(new Position(3, 3), new Position(5, 5), s));
     Assert.IsTrue(m.CanApply(new Position(3, 3), new Position(4, 4), s));
 }
Exemplo n.º 14
0
 public void GetPresentationException()
 {
     var p = new FigurinePresentation();
     var o = new Piece();
     p.GetPresentation(o);
 }