// add move part but omit those that do nothing void AddMovePart(MovePartModel movepart) { if (!IsNoop(movepart)) { _move.MoveParts.Add(movepart); } }
// Create piece from existing with changes internal PieceModel Create(MovePartModel movepart) { var ret = MemberwiseClone() as PieceModel; _move_lookup[movepart.Kind](ret, movepart); return(ret); }
// 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); }
internal void AddSetAttribute(IdentValue ident, BoolValue value) { _changes.Add(MovePartModel.CreateSetAttribute(Player, Position, Piece, ident, value)); }
internal void AddDrop(PlayerValue player, PositionValue position, PieceValue piece) { _changes.Add(MovePartModel.Create(MoveKinds.Drop, player, position, piece)); }
internal void AddCapture(PositionValue position) { _changes.Add(MovePartModel.Create(MoveKinds.Take, Player, position, Piece)); }
internal void AddChangeOwner(PositionValue position, PlayerValue player) { _changes.Add(MovePartModel.Create(MoveKinds.Owner, player, position, Piece)); }
internal void AddChangePiece(PositionValue position, PieceValue piece) { _changes.Add(MovePartModel.Create(MoveKinds.Piece, Player, position, piece)); }
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)); }