private void ReverseMove(Move.MoveType move) { if (move == null) { return; } state = move.Reverse(state); Moved(); }
private bool ApplyMove(Move.MoveType move) { bool valid; state = move.Apply(state, out valid); if (valid) { Moved(); } return(valid); }
private bool MoveCardToStack(Card card, int toStack) { var info = cardStore.Get(card); int index = info.cardPositionIndex; int sub = info.cardPositionSubIndex; Move.MoveType move = null; if (info.cardPosition == CardPosition.Waste) { move = new Move.MoveWasteToTableau(toStack); } else if (info.cardPosition == CardPosition.Tableau) { if (state.tableau[index].Count - 1 == sub) { move = new Move.MoveTableauCardToTableau(index, toStack); } else { move = new Move.MoveTableauStackToTableau(index, sub, toStack); } } else if (info.cardPosition == CardPosition.Foundation) { if (state.foundation[index].Count - 1 == sub) { move = new Move.MoveFoundationToTableau(index, toStack); } } if (move == null) { return(false); } else { return(ApplyMove(move)); } }