Пример #1
0
 // add move part but omit those that do nothing
 void AddMovePart(MovePartModel movepart)
 {
     if (!IsNoop(movepart))
     {
         _move.MoveParts.Add(movepart);
     }
 }
Пример #2
0
        // Create piece from existing with changes
        internal PieceModel Create(MovePartModel movepart)
        {
            var ret = MemberwiseClone() as PieceModel;

            _move_lookup[movepart.Kind](ret, movepart);
            return(ret);
        }
Пример #3
0
 // move part that does nothing
 bool IsNoop(MovePartModel mp)
 {
     if (mp.Kind == MoveKinds.Move || mp.Kind == MoveKinds.Copy)
     {
         return(mp.Position == mp.Final && mp.Piece == _move.Piece);
     }
     if (Kind == MoveKinds.Owner)
     {
         return(mp.Player == _move.Player);
     }
     if (Kind == MoveKinds.Piece)
     {
         return(mp.Piece == _move.Piece);
     }
     return(false);
 }
Пример #4
0
 internal void AddSetAttribute(IdentValue ident, BoolValue value)
 {
     _changes.Add(MovePartModel.CreateSetAttribute(Player, Position, Piece, ident, value));
 }
Пример #5
0
 internal void AddDrop(PlayerValue player, PositionValue position, PieceValue piece)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Drop, player, position, piece));
 }
Пример #6
0
 internal void AddCapture(PositionValue position)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Take, Player, position, Piece));
 }
Пример #7
0
 internal void AddChangeOwner(PositionValue position, PlayerValue player)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Owner, player, position, Piece));
 }
Пример #8
0
 internal void AddChangePiece(PositionValue position, PieceValue piece)
 {
     _changes.Add(MovePartModel.Create(MoveKinds.Piece, Player, position, piece));
 }
Пример #9
0
 internal MovePartModel CreateMovePart(PieceValue piece)
 {
     return((Kind == MoveKinds.Move || Kind == MoveKinds.Copy)
 ? MovePartModel.Create(Kind, Player, From, piece ?? Piece, To ?? Current)
 : MovePartModel.Create(Kind, Player, To ?? Current, piece ?? Piece, null));
 }