public void HumanExecute() //This function is used to draw or discard when the button clicked { if (!CardsInHand.CheckVictory(playerCardsInHand) && mMachine.CurrentState.GetName == "Player Turn State" && move == true) { DetectSelection(); playerCardsInHand.ResetScore();//to show the potential score in the current hand right now (resets and displays at the start of every turn) playerCardsInHand.AnalyseHand(playerCardsInHand); if (!mMachine.CurrentState.hasDrawn) //if has not drawn, then it will execute draw action { DeckAnimator.SetTrigger("Draw"); mMachine.Execute(deckToDraw); lastDrawDeck = deckToDraw; mAI.MatchAndIterate(); //The AI will do its calculation even it's in player's turn, keeping track of the current state is necessary or the AI will be very dumb if (CardsInHand.CheckVictory(playerCardsInHand)) { UpdateEverything(); endCanvas.SetActive(true); endText.text = "Player Win!"; isComplete = true; playerWin = true; PlayerScore.text = playerScore; //Setting player score for (int i = 0; i < displayCards_AI.Length; i++) { displayCards_AI[i].GetComponentInChildren <CardImage>().enabled = true; } } } else //if has drawn, then it will execute discard action { if (mMachine.Execute(cardToDiscard)) { lastDiscardCard = cardToDiscard; turnCounter += 1; mAI.MatchAndIterate(); move = false; } } UpdateEverything(); } }