private bool AutoPlay() { var lastPlay = m_Game.GetLastPlay(); var lastPlayerName = m_Game.GetLastPlayerName(); var currentPlayerName = m_Game.GetCurrentTurnPlayerName(); if (string.IsNullOrEmpty(currentPlayerName) || currentPlayerName == "You") { return(false); } var currentPlayer = m_Game.FindPlayer(currentPlayerName); if (currentPlayer == null) { return(false); } if (string.IsNullOrEmpty(lastPlayerName)) // first play of current round { var play = BigTwoLogic.TryToGiveOutBest(currentPlayer.CurrentHand.GetCards(), 0, "3D"); if (play == null || play.Count <= 0) { return(false); } return(m_Game.AcceptPlay(currentPlayerName, play)); } else { if (lastPlayerName == currentPlayerName) { var play = BigTwoLogic.TryToGiveOutBest(currentPlayer.CurrentHand.GetCards(), 0); return(m_Game.AcceptPlay(currentPlayerName, play)); } else { var play = BigTwoLogic.TryToGiveOutBest(currentPlayer.CurrentHand.GetCards(), lastPlay.Count); if (play == null || play.Count <= 0) { return(m_Game.AcceptPlay(currentPlayerName, new List <int>())); } else { var playCards = currentPlayer.CurrentHand.GetCards(play); if (BigTwoLogic.CheckBetterCards(playCards, lastPlay)) { return(m_Game.AcceptPlay(currentPlayerName, play)); } else { return(m_Game.AcceptPlay(currentPlayerName, new List <int>())); } } } } }
private void btnGive_Click(object sender, EventArgs e) { List <PictureBox> cardBoxes = new List <PictureBox>() { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6, pictureBox7, pictureBox8, pictureBox9, pictureBox10, pictureBox11, pictureBox12, pictureBox13 }; if (m_Game.GetGameState() != "PlayingCards") { return; } var lastPlay = m_Game.GetLastPlay(); var lastPlayerName = m_Game.GetLastPlayerName(); var currentPlayerName = m_Game.GetCurrentTurnPlayerName(); if (currentPlayerName != "You") { return; } var player = m_Game.FindPlayer("You"); if (string.IsNullOrEmpty(lastPlayerName) || lastPlay == null || lastPlay.Count <= 0) { var items = BigTwoLogic.TryToGiveOutBest(player.CurrentHand.GetCards(), 0, "3D"); if (items == null || items.Count <= 0) { LogMsg("No tips found"); return; } else { for (var i = 0; i < cardBoxes.Count; i++) { if (items.IndexOf(i) >= 0) { cardBoxes[i].Top = POP_POS_Y; } else { cardBoxes[i].Top = BASE_POS_Y; } } } } else { var items = BigTwoLogic.TryToGiveOutBest(player.CurrentHand.GetCards(), lastPlayerName == "You" ? 0 : lastPlay.Count); if (items == null || items.Count <= 0) { LogMsg("You have to pass"); return; } else { if (lastPlayerName == "You") { for (var i = 0; i < cardBoxes.Count; i++) { if (items.IndexOf(i) >= 0) { cardBoxes[i].Top = POP_POS_Y; } else { cardBoxes[i].Top = BASE_POS_Y; } } } else { var playCards = player.CurrentHand.GetCards(items); if (BigTwoLogic.CheckBetterCards(playCards, lastPlay)) { for (var i = 0; i < cardBoxes.Count; i++) { if (items.IndexOf(i) >= 0) { cardBoxes[i].Top = POP_POS_Y; } else { cardBoxes[i].Top = BASE_POS_Y; } } } else { LogMsg("You have to pass"); return; } } } } }