using System.Collections.Generic;
using LitJson;
using Wizard;

public class UserCrystalCount : HeaderData
{
	private const string ORB_KEY = "orb";

	public int total_crystal;

	public int free_crystal;

	public int charge_crystal;

	public int red_ether;

	public int rupy;

	public int _spotcardPoint;

	public string create_time;

	public string update_time;

	public string delete_time;

	public string affected_rows;

	public int last_payment_date;

	public string _lastPaymentId;

	public int _lastPaymentItemBuyNumber;

	public List<SpecialCrystalInfo> SpecialCrystalInfo { get; private set; }

	public bool EnableSpecialCrystal => SpecialCrystalInfo.Count > 0;

	public bool NeedNewIcon
	{
		get
		{
			foreach (SpecialCrystalInfo item in SpecialCrystalInfo)
			{
				if (item.AvailablePurchaseCount > 0)
				{
					return true;
				}
			}
			return false;
		}
	}

	public RemainTime GetCloseTimeLimit()
	{
		int num = int.MaxValue;
		RemainTime result = null;
		foreach (SpecialCrystalInfo item in SpecialCrystalInfo)
		{
			if (item.RemainTime.Second < num)
			{
				num = item.RemainTime.Second;
				result = item.RemainTime;
			}
		}
		return result;
	}

	public void SetUserCrystalCount(JsonData data)
	{
		total_crystal = data["total_crystal"].ToInt();
		free_crystal = data["free_crystal"].ToInt();
		charge_crystal = data["crystal"].ToInt();
		red_ether = data["red_ether"].ToInt();
		rupy = data["rupy"].ToInt();
	}

	public void ParseSpecialCrystal(JsonData responseData)
	{
		SpecialCrystalInfo = new List<SpecialCrystalInfo>();
		JsonData jsonData = responseData["data"];
		if (jsonData.Keys.Contains("special_crystal_info"))
		{
			JsonData jsonData2 = jsonData["special_crystal_info"];
			for (int i = 0; i < jsonData2.Count; i++)
			{
				SpecialCrystalInfo item = new SpecialCrystalInfo(jsonData2[i], responseData);
				SpecialCrystalInfo.Add(item);
			}
		}
	}
}
