//Occurs when the user clicks the pon button public void OnPonClick() { Naki naki = GetNaki(NakiType.Pon); callback(naki); FinalizeService(); }
//Occurs when the user clicks the tsumo button public void OnTsumoClick() { Naki naki = GetNaki(NakiType.Tsumo); callback(naki); FinalizeService(); }
public TurnArgs() { type = TurnArgsType.Default; naki = new Naki() { type = NakiType.Nashi }; }
//Occurs when the user clicks the chii button public void OnChiiClick() { //TODO: check if ambiguous Naki naki = GetNaki(NakiType.Chii); callback(naki); FinalizeService(); }
//Offers a discard to be called as naki public override void Offer(Tile tile) { TileID id = tile.Query(); List <PotentialMeld> melds = handAnalyzer.GetWaitingMelds(id); /* * string message = "Hand Analyzer " + PlayerNumber + " returned these melds matching the offer of " + * id.ToString() + ":\r\n"; * for (int i = 0; i < melds.Count; i++) * message += melds[i].ToString() + "\r\n"; * Debug.Log(message); */ //Formulate a list of potential naki to send to the Naki UI Manager List <Naki> naki = new List <Naki>(); bool add; for (int i = 0; i < melds.Count; i++) { add = true; if (Naki.GetNakiType(melds[i].Waits[0].type) == NakiType.Chii) { //If I am not kamicha (player to right), I cannot request chii if ((PlayerNumber - tile.StolenFrom + 4) % 4 != 1) { add = false; } } if (add) { naki.Add(new Naki() { meld = melds[i], requestor = this, type = Naki.GetNakiType(melds[i].Waits[0].type) }); } } //If I cannot request any naki for this tile, respond that I don't want the discard if (naki.Count == 0) { controller.RespondToOffer(new Naki() { type = NakiType.Nashi, requestor = this, meld = null }); } //Otherwise pass the list of possible naki to the Naki UI Manager for user input else { sendingToUI = naki; SetState("Awaiting User Naki Choice"); } }
//Occurs when the user clicks the continue button public void OnContinueClick() { Naki naki = new Naki() { type = NakiType.Nashi, //requestor = player, meld = null }; callback(naki); FinalizeService(); }
//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(); }
public TurnArgs(TurnArgsType t, Naki n) { type = t; naki = n; }
//*********************************************************************** //**************************** Naki Management ************************** //*********************************************************************** //Callback for players responding to naki offers public void RespondToOffer(Naki naki) { nakiResponses.Add(naki); }