/// <summary> /// A string representation of this Move. /// </summary> /// <returns></returns> public override string ToString() { if (IllegalMove.Equals("")) { return(PlayerName + " place_armies " + Region.Id + " " + Armies); } else { return(PlayerName + " illegal_move " + IllegalMove); } }
/// <summary> /// A string representation of this Move. /// </summary> /// <returns></returns> public override string ToString() { if (IllegalMove.Equals("")) { return(PlayerName + " attack/transfer " + FromRegion.Id + " " + ToRegion.Id + " " + Armies); } else { return(PlayerName + " illegal_move " + IllegalMove); } }
public void NotifyIllegalMove(IllegalMove move) { this.cardData_to_cardView[move.card.ToString()].UndoDrag(); }
public void NotifyIllegalMove(IllegalMove move) { //Do nothing }
public void NotifyCardDropped(Card selectedCard, TablePosition dropPosition) { bool isValidMove = false; Zone selectedCardZone = selectedCard.GetZone(gameState); int selectedCardColumnIndex = selectedCard.GetColumn(gameState); TablePosition from = new TablePosition(selectedCardZone, selectedCardColumnIndex); if (from.zone == dropPosition.zone && from.index == dropPosition.index) { isValidMove = false; } else if (dropPosition.zone == Zone.Tableu) { int targetColumn = dropPosition.index; CardColumn targetCardColumn = this.Tableu[targetColumn]; Card cardToDropOn = targetCardColumn.faceUpCards.LastOrDefault(); isValidMove = IsLegal_TableuMove(selectedCard, cardToDropOn); } else if (dropPosition.zone == Zone.Foundation) { isValidMove = IsLegal_FoundationMove(selectedCard, FoundationPiles[dropPosition.index]); } else { //Card was dropped on the upper part of the table, between foundation piles and deckPile, or on the same column as it started isValidMove = false; } if (isValidMove) { List <Card> cardsBeingMoved = new List <Card>(); cardsBeingMoved.Add(selectedCard); //If the moved card comes from the tableu, there might other cards above that need to be moved as well. //This doens't happen for moves where the selected card comes from foundation piles, stock pile or waste pile. if (selectedCardZone == Zone.Tableu) { cardsBeingMoved.AddRange(this.Tableu[selectedCardColumnIndex].faceUpCards.SkipWhile(c => c != selectedCard).Skip(1)); } GameState snapshot = gameState.Clone() as GameState; Move move = new Move(cardsBeingMoved, from, dropPosition, snapshot); //Notify subscribers foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances) { subscribedHandler.NotifyLegalMove(move); } //Store move in history Debug.Log("Legal move"); //Update Game data ExecuteMove(move); movesHistory.Push(move); } else { IllegalMove move = new IllegalMove(selectedCard); //Notify subscribers foreach (ISolitaireEventsHandlers subscribedHandler in subscribedInstances) { subscribedHandler.NotifyIllegalMove(move); } Debug.Log("Illegal move"); } }