Skip to content

Instantly share code, notes, and snippets.

@haxpor
Created July 27, 2016 14:26
Show Gist options
  • Save haxpor/ae782d2fe4942aaedaeed4c26c851444 to your computer and use it in GitHub Desktop.
Save haxpor/ae782d2fe4942aaedaeed4c26c851444 to your computer and use it in GitHub Desktop.
Demonstrate how to know reward to get if users execute such an action from engine rule
// call engine rule to get a list of rule info
// to get to know reward to get from executing such action on Engine api
EngineApi.RuleInfoList(Playbasis.Instance, "comment", "jontestuser",
delegate(List<RuleInfoVariant2> result, HttpError error) {
if (error == null) {
if (result != null) {
// loop through all rule
foreach (RuleInfoVariant2 ruleInfo in result)
{
// loop through all jigsaw of each rule
foreach (Jigsaw jigsaw in ruleInfo.JigsawSet) {
// if such jigsaw's category is "REWARD", then we know we got a reward here
if (jigsaw.Category == "REWARD") {
JigsawRewardConfig rconfig = (JigsawRewardConfig)jigsaw.Config;
// reward is a badge?
if (rconfig.RewardName == "badge") {
JigsawRewardConfigBadgeData badgeData = (JigsawRewardConfigBadgeData)rconfig.Data;
Debug.Log("Got badge reward: " + Dumper.Dump(badgeData));
}
// otherwise it's point-based reward
else {
Debug.Log("Got point-based reward: " + Dumper.Dump(rconfig));
}
}
}
}
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment