Square currentPlayerSquare = [HERE] Player1 [HERE].Board.First(s => s.Number == currentPlayer.Position); Square otherPlayerSquare = [HERE] Player1 [HERE].Board.First(s => s.Number == otherPlayer.Position);
public void PerformSwap(PlayerViewModel currentPlayer, Canvas canvas) { // Hitta en annan spelare att byta plats med var otherPlayer = Players.FirstOrDefault(p => p != currentPlayer && p.Position > 0 && p.Position <= 100); int otherPLayerposition = otherPlayer.Position; // det har lades till int currentplayerposition = currentPlayer.Position; // det har lades till if (otherPlayer != null) { // Byt plats på de två spelarna Square currentPlayerSquare = Player1.Board.First(s => s.Number == currentPlayer.Position); Square otherPlayerSquare = Player1.Board.First(s => s.Number == otherPlayer.Position); currentPlayer.Position = otherPLayerposition; // och detta otherPlayer.Position = currentplayerposition; // och detta! MovePieceToCanvasPosition(currentPlayer.GamePiece, otherPlayerSquare, canvas); MovePieceToCanvasPosition(otherPlayer.GamePiece, currentPlayerSquare, canvas); } }