Skip to main content
Version: 5.11.8

GetProbabilitys

public BackendReturnObject GetProbabilitys(string CardFileID, int count);

Parameters

ValueTypeDescriptionDefaultMax
CardFileIDstringid of the probability card file--
countintNumber of times to receive multiple items at once1100

[version2] : bro.GetReturnValuetoJSON()["rows"][i]["selectedProbabilityFileId"]["N"] |

Description

Performs draws multiple times using a probability card.

  • This function can only be used in version2.
  • You can perform up to 100 draws.
  • Derives and returns a result with a probability corresponding to the percentage of the probability chart. For example, if the percentage is 1, there is a 1% chance that the result will be returned.

Probability is provided up to the seventh decimal place.

Example

Synchronous

Backend.Probability.GetProbabilitys("CardFileID", 10);

Asynchronous

Backend.Probability.GetProbabilitys("CardFileID", 10, (callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.Probability.GetProbabilitys, "CardFileID", 10, (callback) => 
{
// Post-process
});

Return cases

Success cases

When a draw is performed
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When the wrong id is entered
statusCode : 400
errorCode : BadParameterException

When there is data with 8 or more decimal places in the probability
statusCode : 500
errorCode : ServerErrorException

GetReturnValuetoJSON

{
elements:
[
{
// Probability chart num
num: { S: "1" },
// Probability of occurrence
percent: { S: "10" },
// Column entered in the probability file
compensation: { S: "present1" },
// Column entered in the probability file
monster: { S: "super" }
},
{
num: [Object],
percent: [Object],
compensation: [Object],
monster: [Object]
}
..
]
}

Sample code

// This item was made using the BACKND sample chart provided by default.  
// Please change the variables to match the column names in the chart you have uploaded.
public class ProbabilityItem
{
public string itemID;
public string itemName;
public string hpPower;
public int num;
public string percent;
public override string ToString()
{
return $"itemID : {itemID}\n" +
$"itemName : {itemName}\n" +
$"hpPower : {hpPower}\n" +
$"num : {num}\n" +
$"percent : {percent}\n";
}
}
public void GetProbabilitysTest()
{
string selectedProbabilityFileId = "93";

var bro = Backend.Probability.GetProbabilitys(selectedProbabilityFileId, 10); // 10th;

if(!bro.IsSuccess())
{
Debug.LogError(bro.ToString());
return;
}

LitJson.JsonData json = bro.GetFlattenJSON()["elements"];

List<ProbabilityItem> itemList = new List<ProbabilityItem>();

for(int i = 0; i < json.Count; i++)
{
ProbabilityItem item = new ProbabilityItem();

item.itemID = json[i]["itemID"].ToString();
item.itemName = json[i]["itemName"].ToString();
item.hpPower = json[i]["hpPower"].ToString();
item.num = int.Parse(json[i]["num"].ToString());
item.percent = json[i]["percent"].ToString();

itemList.Add(item);
}

foreach(var item in itemList)
{
Debug.Log(item.ToString());
}
}