Skip to main content
Version: 5.15.0

Backend.CDN.Probability.Get

public BackendProbabilityContentReturnObject Backend.CDN.Probability.Get(List< ProbabilityTableItem > probabilityTableList);

public void Backend.CDN.Probability.Get(List< ProbabilityTableItem > probabilityTableList, ContentProgressDelegate contentProgressDelegate, Backend.BackendCallback< BackendProbabilityContentReturnObject > backendCallback);

Parameter

ValueTypeDescription
probabilityTableListList< ProbabilityTableItem >Can be called using Backend.CDN.Probability.Table.Get().
contentProgressDelegateContentProgressDelegateDelegate method that indicates the file download progress

Description

Loads the content of probabilities registered to List< ProbabilityTableItem >, which has been loaded using Backend.CDN.Probability.Table.Get().

  • This method cannot be called via SendQueue.

Upon a successful return value of 204, you can check the file's value in JSON format at List< ProbabilityContentItem > GetProbabilityContentList(), which exists in BackendProbabilityContentReturnObject.

ContentProgressDelegate

public delegate void ContentProgressDelegate(int totalCount, int remainCount, string downloadFile);

This delegate method is called whenever the next file download starts after completing the download within the method.
The method can be used to display the current download progress.

It can be used as shown below:

private void GetProgress(int totalCount, int remainCount, string fileName)
{
Debug.Log("Total number of files : " + totalCount);
Debug.Log("Remaining number of files : " + remainCount);
Debug.Log("Name of file to be currently downloaded : " + fileName);
}

Backend.CDN.Probability.Get(callback.GetProbabilityTableItemList(), GetProgress, bro =>
{
Debug.Log(bro);
});

BackendProbabilityContentReturnObject

namespace BackEnd.ProbabilityContent
{
public class ProbabilityContentItem
{
public string probabilityName;
public string probabilityId;
public string selectedProbabilityFileId;
public string errorString;
public string createdDate;
public string contentString { get; internal set; }

public LitJson.JsonData contentJson
{
get
{
if (contentJson == null)
{
contentJson = new LitJson.JsonData(contentString);
}

return contentJson;
}

private set => contentJson = value;
}
}

public class BackendProbabilityContentReturnObject : BackendReturnObject
{
// In the case of GetProbabilityContentDictionarySortByProbabilityName, the key value is converted into ProbabilityId and saved if the probability name is identical.
public Dictionary<string, ProbabilityContentItem> GetProbabilityContentDictionarySortByProbabilityName();

public Dictionary<string, ProbabilityContentItem> GetProbabilityContentDictionarySortByProbabilityId();

public List<ProbabilityContentItem> GetProbabilityContentList();
}
}

Example

Synchronous

void GetProbability() 
{
BackEnd.ProbabilityContent.BackendProbabilityTableReturnObject callback;

// Load probability table
callback = Backend.CDN.Probability.Table.Get();

if(callback.IsSuccess() == false) {
Debug.LogError(callback);
return;
}

BackEnd.ProbabilityContent.BackendProbabilityContentReturnObject callback2 = null;


// Look up loaded probability table content
callback2 = Backend.CDN.Probability.Get(callback.GetProbabilityTableItemList());

if (callback2.IsSuccess() == false)
{
Debug.LogError("GetContents : Fail : " + callback2);
return;
}

// In the case of success, converts into Dictionary format
Dictionary<string, BackEnd.ProbabilityContent.ProbabilityContentItem> dic = callback2.GetProbabilityContentDictionarySortByProbabilityName();

// Check content
foreach (string keyName in dic.Keys)
{
Debug.Log(dic[keyName].ToString());
}

// For contentJson, refer to the success cases below.
if(dic.ContainsKey("Probability"))
{

LitJson.JsonData json = dic["Probability"].contentJson;

foreach(LitJson.JsonData item in json) {
Debug.Log(item["itemID"]);
Debug.Log(item["itemName"]);
Debug.Log(item["hpPower"]);
Debug.Log(item["percent"]);
Debug.Log(item["num"]);
}
}
}

Asynchronous

private void GetProgress(int totalCount, int remainCount, string fileName)
{
Debug.Log("totalCount : " + totalCount + " remainCount : " + remainCount + " fileName : " + fileName);
}

public void GetProbabilityAsync()
{
StartCoroutine(GetProbabilityAsyncIEnumerator());
}

IEnumerator GetProbabilityAsyncIEnumerator()
{
BackEnd.ProbabilityContent.BackendProbabilityTableReturnObject callback = null;

Backend.CDN.Probability.Table.Get(bro =>
{
callback = bro;
});

yield return new WaitUntil(() => callback != null);

if(callback.IsSuccess() == false) {
Debug.LogError(callback);
yield break;
}

BackEnd.ProbabilityContent.BackendProbabilityContentReturnObject callback2 = null;

Backend.CDN.Probability.Get(callback.GetProbabilityTableItemList(), GetProgress, bro =>
{
callback2 = bro;
});

yield return new WaitUntil(() => callback2 != null);

if (callback2.IsSuccess() == false)
{
Debug.LogError("GetContents : Fail : " + callback2);
yield break;
}

Dictionary<string, BackEnd.ProbabilityContent.ProbabilityContentItem> dic = callback2.GetProbabilityContentDictionarySortByProbabilityName();


foreach (string keyName in dic.Keys)
{
Debug.Log(dic[keyName].ToString());
}

// When the probability file name is 'Probability'
// For contentJson, refer to the success cases below.
if(dic.ContainsKey("Probability")) {

LitJson.JsonData json = dic["Probability"].contentJson;

foreach(LitJson.JsonData item in json) {
Debug.Log(item["itemID"]);
Debug.Log(item["itemName"]);
Debug.Log(item["hpPower"]);
Debug.Log(item["percent"]);
Debug.Log(item["num"]);
}
}
}

ReturnCase

Success cases

When the lookup is successful
statusCode : 204
message : Success

In the case of success, check the GetProbabilityContentDictionary() method.

ContentJson

In the example chart shown below, LitJson.JsonData contentJson of the ProbabilityContentItem class is displayed according to the following.

image

[
{
"itemID": "i101",
"itemName": "Item1",
"hpPower": "1",
"percent": "3.5",
"num": "1"
},
{
"itemID": "i102",
"itemName": "Item2",
"hpPower": "2",
"percent": "3.5",
"num": "2"
},
...
]