//Processes all naki requests and sets the next player turn accordingly public void ProcessNakiRequests(string nextStateIfNashi) { //Debug.Log("Processing naki responses:\r\n" + nakiResponses[0] + "\r\n" //+ nakiResponses[1] + "\r\n" + nakiResponses[2] + "\r\n"); Naki naki = new Naki() { type = NakiType.Nashi }; for (int i = 0; i < 3; i++) { if (nakiResponses[i].type > naki.type) //if higher priority { if (nakiResponses[i].type == NakiType.Chii) { //Check if kamicha (player to right) if ((nakiResponses[i].requestor.PlayerNumber - Kawa.MostRecentKawa.PlayerNumber + 4) % 4 == 1) { naki = nakiResponses[i]; } } else { naki = nakiResponses[i]; } } } if (naki.type == NakiType.Nashi) { nextTurnArgs = TurnArgs.Default; SetState(nextStateIfNashi); } else { //Flow interrupt. Start the relevant player's turn instead nextTurnArgs = new TurnArgs(Naki.GetTurnArgs(naki.type), naki); SetState("Player " + naki.requestor.PlayerNumber + " Turn"); } nakiResponses.Clear(); }
//Takes a turn. public abstract void StartTurn(TurnArgs args);
//HandAnalyzer Hal; private void Process_Test() { //Test script if (Input.GetKeyDown("g")) { Debug.Log("Executing test script..."); CreateTileSet(RuleSets.DefaultRules); board.Wall.Build(allTiles); System.Random rand = new System.Random(); int r = rand.Next(1, 5); if (r == 5) { r = 4; } //r = 4; board.Wall.Break(r); Hand[] hands = new Hand[4]; hands[0] = GameObject.Find("Hand 1").GetComponent <Hand>(); hands[1] = GameObject.Find("Hand 2").GetComponent <Hand>(); hands[2] = GameObject.Find("Hand 3").GetComponent <Hand>(); hands[3] = GameObject.Find("Hand 4").GetComponent <Hand>(); GameObject.Find("Player 1").AddComponent <UserPlayer>(); GameObject.Find("Player 2").AddComponent <UserPlayer>(); GameObject.Find("Player 3").AddComponent <UserPlayer>(); GameObject.Find("Player 4").AddComponent <UserPlayer>(); Players[0] = GameObject.Find("Player 1").GetComponent <UserPlayer>(); Players[1] = GameObject.Find("Player 2").GetComponent <UserPlayer>(); Players[2] = GameObject.Find("Player 3").GetComponent <UserPlayer>(); Players[3] = GameObject.Find("Player 4").GetComponent <UserPlayer>(); Players[0].Setup(1, hands[0], board.Ponds[0], this, board); Players[1].Setup(2, hands[1], board.Ponds[1], this, board); Players[2].Setup(3, hands[2], board.Ponds[2], this, board); Players[3].Setup(4, hands[3], board.Ponds[3], this, board); Players[0].enabled = true; Players[1].enabled = true; Players[2].enabled = true; Players[3].enabled = true; //Hal = new HandAnalyzer(hands[0], 0); //EventManager.Subscribe("Debug: New HandAnalyzer Analysis Available", //() => { Debug.Log(Hal.Debug_Print()); }); //() => { DebugDisplayText.text = Hal.Debug_Print(); }); for (int i = 0; i < 13; i++) { hands[0].Deal(board.Wall.Draw()); hands[1].Deal(board.Wall.Draw()); hands[2].Deal(board.Wall.Draw()); hands[3].Deal(board.Wall.Draw()); } EventManager.FlagEvent("Hands Dealt"); nextTurnArgs = TurnArgs.Default; SetState("Player 1 Turn"); //No more actions //Debug.Log("Test completed. Entering null state..."); //SetState("Null"); } }
//Takes a turn. public override void StartTurn(TurnArgs args) { SetState("Starting Turn"); turnArgs = args; }