The current section describes possible operations with players' wallets for withdrawing funds and adding winning during a game process.
For placing a bet use:
// type of bet: spin | freespin | bonus game | buy a game e.t.c
string betType = FireballConstants.BetType.SPIN;
// bet amaount in cents for real money, or simple value for virtual currencies
long betAmount = 50;
// send requset for bet place
await _fireball.PlaceBet(betType, betAmount, message);
if bet placing succesfully confirmend on operators wallet integrtion, game server function will receive "bet-placed" message. Otherwise game server functionwill receive "bet-place-rejected" message: …
public async Task<MessageResult> HandleMessage(ParseResult parseResult)
{
if (parseResult.IsSuccess)
{
switch (parseResult.MessageName)
{
...
case FireballConstants.MessagesNames.BET_PLACED:
return await OnBetPlaced(parseResult.ToMessage<IntegrationBetPlaced>());
case FireballConstants.MessagesNames.BET_PLACE_REJECTED:
return await OnBetPlacedRejected(parseResult.ToMessage<ErrorMessage>());
...
}
}
...
}
...
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
_logger.Log($"bet-placed: OperatorBetId = {message.OperatorBetId}");
if (message.BetType == FireballConstants.BetType.SPIN)
{
// do next game logic for spin
}
else if (message.BetType == FireballConstants.BetType.FREESPIN)
{
// do next game logic for free spin
}
return MessageResult.ErrorResult($"Undefined bet type = {message.BetType}");
}
public async Task<MessageResult> OnBetPlacedRejected(ErrorMessage error)
{
_logger.LogError($"bet-place-rejected: {error.Reason}");
// send error to game client
return await _fireball.SendErrorToClient(error, ErrorCode.Integration);
}
…
For paying a winning you need to supply "OperatorBetId" you get on succesfully bet placed:
public async Task<MessageResult> OnBetPlaced(IntegrationBetPlaced message)
{
if (message.BetType == FireballConstants.BetType.SPIN)
{
string betId = message.OperatorBetId;
long betAmount = message.Amount;
// check is player win and calculate winning amount
bool isWin = await _fireball.Random.GetRandomBool();
long winAmount = isWin ? 5 * betAmount : 0;
// pay winning
return await _fireball.PayWin(FireballConstants.WinningType.SPIN, betId, winAmount, message);
}
return MessageResult.ErrorResult($"Undefined bet type = {message.BetType}");
}
As result of paying win game server function will receive "winning-paid" message on operation complete successfully or "winning-pay-rejected" on error:
...
case FireballConstants.MessagesNames.WINNING_PAID:
return await OnWinPaid(parseResult.ToMessage<IntegrationWinningPaid>());
case FireballConstants.MessagesNames.WINNING_PAY_REJECTED:
return await OnWinPayRejected(parseResult.ToMessage<ErrorMessage>());
...
More details coming soon!