private void HandleOnActionHistoryReceived(string sender, string actionHistory) { //DebugLog.LogWarning (actionHistory); JSON_Object obj = new JSON_Object(actionHistory); int roundStatus = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND_STATUS); int round = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND); JSONArray turnsArray = obj.getJSONArray(Constants.FIELD_ACTION_HISTORY_TURNS); for (int i = 0; i < turnsArray.Count(); i++) { ActionResponse ar = JsonUtility.FromJson <ActionResponse> (turnsArray.getString(i)); if (playerID.Equals(ar.Player_Name)) { betAmount += ar.Bet_Amount; buyInAmount = ar.Player_BuyIn_Chips; if (ar.Action == (int)PLAYER_ACTION.FOLD || ar.Action == (int)PLAYER_ACTION.TIMEOUT) { GetComponent <CanvasGroup> ().alpha = .4f; } } } DisplayBetAmount(); DisplayTotalChips(); }
private void managePlayerMoveAction(string sender, string msg) { JSON_Object jsonResponce = new JSON_Object(msg); if (jsonResponce.getInt(GameConstant.TAG_ACTION) != GameConstant.ACTION_NO_TURN) { if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.managePlayerMoveAction( jsonResponce.getString(GameConstant.TAG_PLAYER_NAME), jsonResponce.getInt(GameConstant.TAG_BET_AMOUNT), jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT), jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE), jsonResponce.getInt(GameConstant.TAG_ACTION)); } else { waGameManager.managePlayerMoveAction( jsonResponce.getString(GameConstant.TAG_PLAYER_NAME), jsonResponce.getInt(GameConstant.TAG_BET_AMOUNT), jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT), jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE), jsonResponce.getInt(GameConstant.TAG_ACTION)); } } }
private void manageWAPotAmount(JSONArray waPotResponceArray) { int cntr = 0; while (cntr < waPotResponceArray.Count()) { JSON_Object waWinnerObject = (JSON_Object)waPotResponceArray.get(cntr); waGameManager.manageWACardPotAmt( waWinnerObject.getString(GameConstant.TAG_WINNER_NAME), waWinnerObject.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), waWinnerObject.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT)); cntr++; } }
// Use this for initialization void Start() { JSON_Object jo1 = new JSON_Object(); jo1.put("count", 1); jo1.increment("count"); Debug.Log("Should print 2: " + jo1.getInt("count")); JSON_Object jo2 = new JSON_Object("{\"quote\": \"He said, \\\"I like JSON\\\"\"}"); Debug.Log("Should print an escaped quote: " + jo2.toString()); JSONArray ja1 = new JSONArray(); ja1.put(jo1); ja1.put(jo2); Debug.Log("Should print count 2, and an escaped quote: " + ja1.toString()); JSON_Object jo3 = ja1.getJSONObject(1); Debug.Log("Should print the same escaped quote: " + jo3.toString()); string twitterTest = "{\"errors\": [{\"message\": \"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.\", \"code\": 68}]}"; JSON_Object jo4 = new JSON_Object(twitterTest); JSONArray ja2 = jo4.getJSONArray("errors"); string message = ja2.getJSONObject(0).getString("message"); int code = ja2.getJSONObject(0).getInt("code"); Debug.Log(message + " code: " + code); }
private void manageBliendPlayers(string sender, JSON_Object jsonResponce) { int smallBliendAmt = jsonResponce.getInt(GameConstant.TAG_SMALL_BLIEND_AMOUNT); if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { if (texassGameManager.getBlindAmount() != 0) { // smallBliendAmt = texassGameManager.getBlindAmount (); } texassGameManager.defineBlindPlayer(smallBliendAmt, jsonResponce.getString(GameConstant.TAG_PLAYER_DEALER), jsonResponce.getString(GameConstant.TAG_PLAYER_SMALL_BLIND), jsonResponce.getString(GameConstant.TAG_PLAYER_BIG_BLIND)); if (texassGameManager.getPlayerManager().getDealerPlayer().getPlayerName().Equals(appwarp.username)) { sendGameType(smallBliendAmt); } } else { if (waGameManager.getBlindAmount() != 0) { // smallBliendAmt = waGameManager.getBlindAmount (); } waGameManager.defineBlindPlayer(smallBliendAmt, jsonResponce.getString(GameConstant.TAG_PLAYER_DEALER), jsonResponce.getString(GameConstant.TAG_PLAYER_SMALL_BLIND), jsonResponce.getString(GameConstant.TAG_PLAYER_BIG_BLIND)); if (waGameManager.getPlayerManager().getDealerPlayer().getPlayerName().Equals(appwarp.username)) { sendGameType(smallBliendAmt); } } }
/// <summary> /// Initializes a new instance of the <see cref="API_GameInfo"/> class. /// </summary> /// <param name="gameInfo">Game info.</param> public API_GameInfo(string gameInfo) { JSON_Object obj = new JSON_Object(gameInfo); total = obj.getInt("total"); per_page = obj.getString("per_page"); current_page = obj.getInt("current_page"); last_page = obj.getInt("last_page"); if (obj.has("next_page_url")) { next_page_url = obj.getString("next_page_url"); } if (obj.has("prev_page_url")) { prev_page_url = obj.getString("prev_page_url"); } if (obj.has("from")) { from = obj.getString("from"); } if (obj.has("to")) { to = obj.getString("to"); } JSONArray arr = new JSONArray(obj.getString("data")); gameList = new List <GameData> (); for (int i = 0; i < arr.Count(); i++) { GameData data = new GameData(arr.getString(i)); if (!data.game_type.Equals(APIConstants.CASH_GAME_GAME_TYPE) && data.status.Equals(APIConstants.TOURNAMENT_STATUS_FINISHED)) { DateTime currentTime = DateTime.Parse(data.currenrTime); DateTime finishedTime = DateTime.Parse(data.finished_time); if ((currentTime - finishedTime).Minutes < 10) { gameList.Add(data); } } else { gameList.Add(data); } } }
private void manageRoundCompleted(string sender, string msg) { JSON_Object jsonResponce = new JSON_Object(msg); if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.moveToNextRound( jsonResponce.getInt(GameConstant.TAG_ROUND), jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT)); } else { waGameManager.moveToNextRound( jsonResponce.getInt(GameConstant.TAG_ROUND), jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT)); } }
private void managePlayerCards(string sender, JSON_Object jsonResponce) { // DEBUG.Log ("Plr Card : "+sender+" \n>> "+ jsonResponce.toString()); if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.addNewPlayerOnTable( 1, jsonResponce.getString(GameConstant.TAG_PLAYER_NAME), jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE), jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_1), jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_2), jsonResponce.getInt(GameConstant.TAG_GAME_STATUS), jsonResponce.getInt(GameConstant.TAG_PLAYER_STATUS), jsonResponce.getInt(GameConstant.TAG_CURRENT_ROUND)); } else { waGameManager.addNewPlayerOnTable( 1, jsonResponce.getString(GameConstant.TAG_PLAYER_NAME), jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE), jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_1), jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_2), jsonResponce.getString(GameConstant.TAG_CARD_WA), jsonResponce.getInt(GameConstant.TAG_GAME_STATUS), jsonResponce.getInt(GameConstant.TAG_PLAYER_STATUS)); } }
private void manageGameCompleted(string sender, string msg) { // DEBUG.Log ("Game Completed : "+msg); JSON_Object jsonResponce = new JSON_Object(msg); List <string> listBestCard = new List <string> (); JSONArray jSONArray = jsonResponce.getJSONArray(GameConstant.TAG_WINNER_BEST_CARDS); for (int i = 0; i < jSONArray.Count(); i++) { listBestCard.Add(jSONArray.get(i).ToString()); } if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.manageGameFinishAction( jsonResponce.getString(GameConstant.TAG_WINNER_NAME), jsonResponce.getInt(GameConstant.TAG_WINNER_RANK), jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT), jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), listBestCard); } else { waGameManager.manageGameFinishAction( jsonResponce.getString(GameConstant.TAG_WINNER_NAME), jsonResponce.getInt(GameConstant.TAG_WINNER_RANK), jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT), listBestCard); // jsonResponce.getInt (GameConstant.TAG_WINNERS_WINNING_AMOUNT), } }
/// <summary> /// Initializes a new instance of the <see cref="API_Transactions"/> class. /// </summary> /// <param name="transactions">Transactions.</param> public API_Transactions(string transactions) { JSON_Object obj = new JSON_Object(transactions); total = obj.getInt("total"); total = obj.getInt("per_page"); total = obj.getInt("current_page"); total = obj.getInt("last_page"); next_page_url = obj.getString("next_page_url"); prev_page_url = obj.getString("prev_page_url"); from = obj.getString("from"); to = obj.getString("to"); JSONArray arr = obj.getJSONArray("data"); transactionList = new List <Transactions> (); for (int i = 0; i < arr.Count(); i++) { // transactionList.Add (new Transactions (arr.getString (i))); transactionList.Add(JsonUtility.FromJson <Transactions> (arr.getString(i))); } }
public void manageReBuyChips(string sender, string msg) { if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { JSON_Object jSONObject = new JSON_Object(msg); if (sender.Equals(appwarp.TEXASS_SERVER_NAME)) { texassGameManager.getPlayerManager().addBalanceToPlayer( jSONObject.getString(GameConstant.TAG_PLAYER_NAME), jSONObject.getInt(GameConstant.TAG_PLAYER_BALANCE)); } } }
private void HandleOnSnGPlayerEliminated(Packet packet) { try { JSONArray arr = new JSONArray(packet.ToString()); JSON_Object obj = arr.getJSONObject(1).getJSONObject("data"); string gameID = obj.getString("game_id"); int totalPlayers = obj.getInt("user_count"); UpdatePlayersCount(gameID, totalPlayers); } catch (Exception e) { Debug.LogError("> Exception : " + e); } }
private void HandleOnLeaveCashGame (Packet packet) { try { JSONArray arr = new JSONArray (packet.ToString ()); JSON_Object dataObj = arr.getJSONObject (1); string data = dataObj.getString ("data"); DebugLog.Log (data); JSON_Object obj = new JSON_Object (data); string gameID = obj.getString ("game_id"); int totalPlayers = obj.getInt ("user_count"); UpdatePlayersCount (gameID, --totalPlayers); } catch (Exception e) { Debug.Log ("Exception : " + e); } }