public void Join() { TacoManager.OpenMessage(TacoConfig.TacoPublicJoining); var t = TacoManager.Target; Action <string> success = (string data) => { var r = JsonUtility.FromJson <JoinTournamentResult> (data); if (r.success) { TacoManager.SetTarget(t); Decimal prize = decimal.Parse(r.tournament.prize.ToString("F2")); Decimal entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2")); string replacedString = string.Empty; if (r.tournament.typeCurrency == 0) { replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", r.userFunds); replacedString = replacedString.Replace("&entryFee", entryFee.ToString()); replacedString = replacedString.Replace("&prize", prize.ToString()); } else { replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", " T " + r.userFunds); replacedString = replacedString.Replace("&entryFee", " T " + entryFee.ToString()); replacedString = replacedString.Replace("&prize", " T " + prize.ToString()); } TacoManager.CloseMessage(); TacoManager.OpenModalJoinSuccessPanel(r.tournament, TacoConfig.JoinSuccessNotice); double val = 0; if (r.tournament.typeCurrency == 0) { //real money if (double.TryParse(r.userFunds, out val)) { TacoManager.UpdateFundsWithToken(val, r.currencyValue, r.ticket, r.userBonus); } } else { //userFunds is 'gtoken' now if (double.TryParse(r.currencyValue, out val)) { TacoManager.UpdateFundsWithToken(val, r.userFunds, r.ticket); } } ShowTournamentPanel(CurrentSubPanel); } else { TacoManager.CloseMessage(); if (r.addFund) { if (t.typeCurrency == 0) { TacoManager.OpenModalFundErrorJoinPanel(TacoConfig.TacoJoinPublicNoFundHead, t); } else { TacoManager.OpenModalTacoErrorJoinPanel(TacoConfig.TacoJoinPublicNoTacoHead, t); } } else { TacoManager.OpenModalAlreadyJoinedPanel(TacoConfig.TacoJoinAlreadyHead, r.message); } } }; Action <string, string> fail = (string data, string error) => { var msg = data + (string.IsNullOrEmpty(error) ? string.Empty : " : " + error); Debug.Log("Error adding funds : " + msg); if (!string.IsNullOrEmpty(data)) { var r = JsonUtility.FromJson <CreateTournamentResult> (data); TacoManager.CloseMessage(); if (!string.IsNullOrEmpty(r.message)) { if (r.forbidden) { TournamentSubmitForbidden(r.message); } else { TacoManager.OpenModalTournamentJoinErrorPanel(TacoConfig.TacoJoinPublicErrorHead, r.message, ModalFunctions.FundsScreen); } } } }; if (t != null) { StartCoroutine(ApiManager.Instance.JoinTournament(t.typeCurrency, t.id, TacoSetup.Instance.SiteId, TacoManager.GameId, TacoManager.User.token, success, fail)); } }
public void ReEnter() { TacoManager.OpenMessage(TacoConfig.TacoPublicJoining); var t = TacoManager.Target; Action <string> success = (string data) => { Debug.Log("reenter data: " + data); var r = JsonUtility.FromJson <JoinTournamentResult> (data); if (r.success) { TacoManager.SetTarget(t); var prize = decimal.Parse(r.tournament.prize.ToString("F2")); var entryFee = decimal.Parse(r.tournament.entryFee.ToString("F2")); string replacedString = string.Empty; if (r.tournament.typeCurrency == 0) { replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", r.userFunds); replacedString = replacedString.Replace("&entryFee", entryFee.ToString()); replacedString = replacedString.Replace("&prize", prize.ToString()); } else { replacedString = TacoConfig.TacoJoinPublicSuccessBody.Replace("&userFunds", " T " + r.userFunds); replacedString = replacedString.Replace("&entryFee", " T " + entryFee.ToString()); replacedString = replacedString.Replace("&prize", " T " + prize.ToString()); } TacoManager.CloseMessage(); TacoManager.OpenModalJoinSuccessPanel(r.tournament, TacoConfig.ReenterSuccessNotice); TacoManager.UpdateFundsWithToken(r.cash, r.token.ToString(), r.ticket.ToString()); ShowTournamentPanel(CurrentSubPanel); } else { TacoManager.CloseMessage(); if (r.error == TacoConfig.NotEnoughFundError) { TacoManager.OpenModalFundErrorJoinPanel(TacoConfig.TacoJoinPublicNoFundHead, t); } else if (r.error == TacoConfig.NotEnoughTokenError) { TacoManager.OpenModalTacoErrorJoinPanel(TacoConfig.TacoJoinPublicNoTacoHead, t); } else if (r.error == TacoConfig.DuplidateError) { TacoManager.OpenModalAlreadyJoinedPanel(TacoConfig.TacoJoinAlreadyHead, r.message); } else { TacoManager.OpenModalGeneralResultPanel(false, TacoConfig.Error, r.message); } } }; Action <string, string> fail = (string data, string error) => { if (!string.IsNullOrEmpty(data)) { var r = JsonUtility.FromJson <CreateTournamentResult> (data); TacoManager.CloseMessage(); if (!string.IsNullOrEmpty(r.message)) { if (r.forbidden) { TournamentSubmitForbidden(r.message); } else { TacoManager.OpenModalTournamentJoinErrorPanel(TacoConfig.TacoJoinPublicErrorHead, r.message, ModalFunctions.FundsScreen); } } } }; if (t != null) { StartCoroutine(ApiManager.Instance.ReEnterTournament(t.id, success, fail)); } }