protected virtual void PlayPlaying() { if (Game.CurrentBidding.Declarer == Position && GrandpaCards == null) { GetGrandpaHand(); } if ( ((int)Game.CurrentBidding.Declarer + 2) % 4 != (int)Position && Game.CurrentGame.CurrentPlayer == Position) { for (int i = 0; i < MyCards.Count; i++) { if (Game.CheckNextCard( Position, MyCards[i].Color, MyCards[i].Figure )) { var data = new PutCardActionRequestSerializer() { CardOwnerPosition = (int)Position, Color = (int)MyCards[i].Color, Figure = (int)MyCards[i].Figure }; PerformServerAction("put-card", data.GetApiObject(), PutCardCallback, MyCards[i]); break; } } } else if ( Game.CurrentBidding.Declarer == Position && ((int)Game.CurrentGame.CurrentPlayer + 2) % 4 == (int)Position ) { for (int i = 0; GrandpaCards != null && i < GrandpaCards.Count; i++) { if (Game.CheckNextCard( (PlayerTag)(((int)Position + 2) % 4), GrandpaCards[i].Color, GrandpaCards[i].Figure )) { var data = new PutCardActionRequestSerializer() { CardOwnerPosition = ((int)Position + 2) % 4, Color = (int)GrandpaCards[i].Color, Figure = (int)GrandpaCards[i].Figure }; PerformServerAction("put-card", data.GetApiObject(), PutCardCallback, GrandpaCards[i]); break; } } } }
protected virtual void PlayPlaying() { if (Game.CurrentGame.TrickList.Count > 0) { var lastTrick = Game.CurrentGame.TrickList[Game.CurrentGame.TrickList.Count - 1].CardList; List <int> cardToSend = new List <int>(); foreach (var card in lastTrick) { cardToSend.Add(((int)card.Figure) * 10 + (int)card.Color + 1); } AILogic.CardsHistory.AddTrick(cardToSend); } if (Game.CurrentBidding.Declarer == Position && AILogic.Grandpa_hand == null) { GetGrandpaHand(); } if ( ((int)Game.CurrentBidding.Declarer + 2) % 4 != (int)Position && Game.CurrentGame.CurrentPlayer == Position) { Console.WriteLine(Position); var trick = Game.CurrentGame.currentTrick.CardList; List <int> newTrick = new List <int>(); foreach (var t in trick) { newTrick.Add((int)t.Color + 1 + (int)t.Figure * 10); } int card = AILogic.PutCard(newTrick, (int)Game.CurrentGame.ContractColor + 1, AILogic.AI_hand); var data = new PutCardActionRequestSerializer() { CardOwnerPosition = (int)Position, Color = card % 10 - 1, Figure = card / 10 }; Card NormalCard = new Card((CardFigure)data.Figure, (CardColor)data.Color, Position); PerformServerAction("put-card", data.GetApiObject(), PutCardCallback, NormalCard); } else if ( Game.CurrentBidding.Declarer == Position && ((int)Game.CurrentGame.CurrentPlayer + 2) % 4 == (int)Position) { var trick = Game.CurrentGame.currentTrick.CardList; List <int> newTrick = new List <int>(); foreach (var t in trick) { newTrick.Add((int)t.Color + 1 + (int)t.Figure * 10); } int card = AILogic.PutCard(newTrick, (int)Game.CurrentGame.ContractColor + 1, AILogic.Grandpa_hand); var data = new PutCardActionRequestSerializer() { CardOwnerPosition = ((int)Position + 2) % 4, Color = card % 10 - 1, Figure = card / 10 }; Card NormalCard = new Card((CardFigure)data.Figure, (CardColor)data.Color, (PlayerTag)(((int)Position + 2) % 4)); PerformServerAction("put-card", data.GetApiObject(), PutCardCallback, NormalCard); } }