/// <summary> /// Koncowka lewy, wykonuje sie po wykonaniu ruchu przez gracza /// </summary> private void EndTrick() { GameShape.CardMouseLeftButtonDown -= new MouseButtonEventHandler(GameShape_CardMouseLeftButtonDown); Canvas.SetZIndex(Player4Trick, 4); bool renons; for (int i = 1; i < WistPlayerNumber; i++) { Deck playerXMoves = new Deck(PlayersHandDecks[i - 1].Deck); playerXMoves = GameRules.PossibleMoves(PlayersHandDecks[i - 1].Deck, WistCard, HeartsOpen, out renons); PlayCardChosenAlgorithm(playerXMoves, PlayersTricks[i - 1], PlayersUsedCards[i - 1], PlayersAlgorithms[i - 1]); PlayersHandDecks[i - 1].Deck.Sort(); //sprawdz czy dolozyl do koloru, jezeli nie to ustaw krotkosc if (renons) { PlayersUsedCards[i - 1].CardRenons[WistCard.Suit] = true; } Canvas.SetZIndex(PlayersTricks[i - 1], 4 + i); } //sprawdz kto wygral lewe i ustaw nowego wistujacego WistPlayerNumber = GameRules.TrickWinner(Player1Trick.Deck.TopCard, Player2Trick.Deck.TopCard, Player3Trick.Deck.TopCard, Player4Trick.Deck.TopCard, WistPlayerNumber); WistCard = null; GameShape.MouseLeftButtonDown += new MouseButtonEventHandler(GameShape_MouseLeftButtonDown); GameShape.KeyUp += new KeyEventHandler(GameShape_KeyUp); //BeginTrick(); }
//graj sam //NIESKONCZONA - chyba juz skonczona private void PlayAutoTrick(int @howManyTricks = 13) { GameShape.CardMouseLeftButtonDown -= new MouseButtonEventHandler(GameShape_CardMouseLeftButtonDown); bool renons; int i; if (PlayersHandDecks[WistPlayerNumber - 1].Deck.Cards.Count == 0) { //zakoncz gre EndGame(); return; } for (i = 0; i < 4; i++) { int index = (WistPlayerNumber - 1 + i) % 4; Deck playerXMoves = new Deck(PlayersHandDecks[index].Next.Deck); //pierwszy gracz jest oczywiscie wistujacym if (i == 0) { playerXMoves = GameRules.PossibleMoves(PlayersHandDecks[index].Deck, null, HeartsOpen, out renons); WistCard = new Card(PlayCardChosenAlgorithm(playerXMoves, PlayersTricks[index], PlayersUsedCards[index], PlayersAlgorithms[index])); } //kolejni gracze musze dostosowac ruchy do wistujacego else { playerXMoves = GameRules.PossibleMoves(PlayersHandDecks[index].Deck, WistCard, HeartsOpen, out renons); PlayCardChosenAlgorithm(playerXMoves, PlayersTricks[index], PlayersUsedCards[index], PlayersAlgorithms[index]); //sprawdz czy dolozyl do koloru, jezeli nie to ustaw krotkosc if (renons) { PlayersUsedCards[index].CardRenons[WistCard.Suit] = true; } } Canvas.SetZIndex(PlayersTricks[index], i); PlayersHandDecks[index].Deck.Sort(); } WistPlayerNumber = GameRules.TrickWinner(Player1Trick.Deck.TopCard, Player2Trick.Deck.TopCard, Player3Trick.Deck.TopCard, Player4Trick.Deck.TopCard, WistPlayerNumber); WistCard = null; GameShape.MouseLeftButtonDown += new MouseButtonEventHandler(GameShape_MouseLeftButtonDown); }