async Task <TieBetResponse> ICommonGameActionsProvider.TieBetAsync(TieBet request)
 {
     return(await DoBetCommandTransactions <TieBet, TieBetResponse>(request,
                                                                    async (playerId, transaction) =>
                                                                    await SettleBet(transaction,
                                                                                    (data, context) => _gameCommands.TieBetAsync(data, context))));
 }
예제 #2
0
        public UgsGameCommandsAdapter(IGameCommands gameCommands)
        {
            _gameCommands = gameCommands;

            _gameEventsMap =
                new Dictionary <BusEventType, Action <UgsGameEvent> >
            {
                {
                    BusEventType.BetPlaced, @event =>
                    {
                        @event.amount = (@event.amount < 0) ? [email protected] : @event.amount;
                        _gameCommands.PlaceBetAsync(GetGameActionData(@event), GetGameActionContext(@event),
                                                    Guid.Parse(@event.userid)).GetAwaiter().GetResult();
                    }
                },
                {
                    BusEventType.BetWon, @event =>
                    {
                        _gameCommands.WinBetAsync(GetGameActionData(@event), GetGameActionContext(@event))
                        .GetAwaiter()
                        .GetResult();
                    }
                },
                {
                    BusEventType.BetLost, @event =>
                    {
                        _gameCommands.LoseBetAsync(GetGameActionData(@event), GetGameActionContext(@event))
                        .GetAwaiter()
                        .GetResult();
                    }
                },
                {
                    BusEventType.BetFree, @event =>
                    {
                        _gameCommands.FreeBetAsync(GetGameActionData(@event), GetGameActionContext(@event),
                                                   Guid.Parse(@event.userid)).GetAwaiter().GetResult();
                    }
                },
                {
                    BusEventType.BetTied, @event =>
                    {
                        _gameCommands.TieBetAsync(GetGameActionData(@event), GetGameActionContext(@event))
                        .GetAwaiter()
                        .GetResult();
                    }
                },
                {
                    BusEventType.BetAdjusted, @event =>
                    {
                        _gameCommands.AdjustTransaction(GetGameActionData(@event), GetGameActionContext(@event));
                    }
                },
                {
                    BusEventType.GameActionCancelled, @event =>
                    {
                        _gameCommands.CancelTransactionAsync(GetGameActionData(@event), GetGameActionContext(@event))
                        .GetAwaiter()
                        .GetResult();
                    }
                }
            };
        }