Skip to main content
Version: 5.11.6

GetProbability

public BackendReturnObject GetProbability(string CardFileUuid);

Parameter

ValueTypeDescription
CardFileUuidstringuuid/id of the probability card file

[version1] : bro.GetReturnValuetoJSON()["rows"][i]\ ["selectedProbabilityCardFile"]["M"]["uuid"]["S"]
[version2] : bro.GetReturnValuetoJSON()["rows"][i]["selectedProbabilityFileId"]["N"]

Description

Performs a draw using a probability card.

  • 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.GetProbability("CardFileUuid");

Asynchronous

Backend.Probability.GetProbability("CardFileUuid", (callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.Probability.GetProbability, "CardFileUuid", (callback) => 
{
// Post-process
});

Return cases

Success cases

When a draw is performed
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

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

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

GetReturnValuetoJSON

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

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 GetProbabilityTest()
{
string selectedProbabilityFileId = "93";

var bro = Backend.Probability.GetProbability(selectedProbabilityFileId);

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

LitJson.JsonData json = bro.GetFlattenJSON();

ProbabilityItem item = new ProbabilityItem();

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

Debug.Log(item.ToString());
}