Before you can contribute or get outcome from any jackpots, you need to:
After successful authorization, you can connect Player to receive jackpots updates on game client:
// setup constants for game
public static class MyGameConstants
{
public static string JACKPOT_TEMPLATE_ID = "00000000-0000-0000-0000-000000000000";
public static float CONTRIBUTION_PERCENT = 0.5f;
}
public async Task<MessageResult> OnAuthSuccess(SessionMessage message)
{
// create list of jackpots template ids
var jackpots = new List<string>()
{
MyGameConstants.JACKPOT_TEMPLATE_ID,
};
// connect jackpots list to game client for receiving jackpots updates
return await _fireball.SendSessionToClient(message, jackpots);
}
Every time Player place a bet, the game can contribute some part of the bet amount or full amount into the jackpot for later next try to win the jackpot:
public async Task<MessageResult> BetPlace(long betAmount, BaseMessage message)
{
// calculate jackpot contribution amount
var contributionAmount = (long)(betAmount * MyGameConstants.CONTRIBUTION_PERCENT);
// create jackpot contributions list
var contributionsList = new List<JackpotContribution>()
{
new JackpotContribution(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount),
};
// place bet with notifing what part of bet will go for jackpot contributions
return await _fireball.PlaceBet(FireballConstants.BetType.SPIN, betAmount, message, contributionsList);
}
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
// calculate jackpot contribution amount
var contributionAmount = (long)(message.Amount * MyGameConstants.CONTRIBUTION_PERCENT);
// make contribution into jackpot from succesfully placed bet
var result = await _fireball.Jackpots.Contribute(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount, message);
// do next game logic
...
}
if game want to get immediate outcome, use next method:
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
// calculate jackpot contribution amount
var contributionAmount = (long)(message.Amount * MyGameConstants.CONTRIBUTION_PERCENT);
// make contribution into jackpot from succesfully placed bet
var result = await _fireball.Jackpots.ContributeAndGetOutcome(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount, message);
if (result.Won)
{
// congratulation! jackpot has been won!
}
// do next game logic
...
}
After successful contributions, Player can try to win jackpot by use some part of contributions or full contributed amount:
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
// calculate jackpot contribution amount
var contributionAmount = (long)(message.Amount * MyGameConstants.CONTRIBUTION_PERCENT);
// make contribution into jackpot from succesfully placed bet
await _fireball.Jackpots.Contribute(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount, message);
// do next game logic
...
var result = await _fireball.Jackpots.GetOutcome(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount, message);
if (result.Won)
{
// congratulation! jackpot has been won!
}
}
After Player successfully won jackpot, this jackpot must be paid into Players balance:
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
// calculate jackpot contribution amount
var contributionAmount = (long)(message.Amount * MyGameConstants.CONTRIBUTION_PERCENT);
// make contribution into jackpot from succesfully placed bet
var result = await _fireball.Jackpots.ContributeAndGetOutcome(MyGameConstants.JACKPOT_TEMPLATE_ID, contributionAmount, message);
if (result.Won)
{
// create a list of won jackpots
var jackpotsWon = new List<JackpotEntry>()
{
new JackpotEntry(result)
};
// paying won jackpot amount
await _fireball.PayJackpot(jackpotsWon, message.OperatorBetId, message);
}
// do next game logic
...
}