Exemple #1
0
        public GameServiceDataRepository(
            IPlayerRepository playerRepository,
            IGameResultRepository gameResultRepository,
            IPlayerStatusRepository playerStatusRepository,
            IGameTypeRepository gameTypeRepository,
            IPlayerStateRepository playerStateRepository)
        {
            if (ReferenceEquals(playerRepository, null))
            {
                throw new ArgumentNullException("playerRepository");
            }
            if (ReferenceEquals(gameResultRepository, null))
            {
                throw new ArgumentNullException("gameResultRepository");
            }
            if (ReferenceEquals(playerStatusRepository, null))
            {
                throw new ArgumentNullException("playerStatusRepository");
            }
            if (ReferenceEquals(gameTypeRepository, null))
            {
                throw new ArgumentNullException("gameTypeRepository");
            }
            if (ReferenceEquals(playerStateRepository, null))
            {
                throw new ArgumentNullException("playerStateRepository");
            }

            _PlayerRepository       = playerRepository;
            _GameResultRepository   = gameResultRepository;
            _PlayerStatusRepository = playerStatusRepository;
            _GameTypeRepository     = gameTypeRepository;
            _PlayerStateRepository  = playerStateRepository;
        }
 public GameResultService(IGameResultRepository gameResultRepository, IGamerRepository gamerRepository,
                          IGameTableRepository gameTableRepository, IBoardGameRepository boardGameRepository)
 {
     _gameResultRepository = gameResultRepository;
     _gamerRepository      = gamerRepository;
     _gameTableRepository  = gameTableRepository;
     _boardGameRepository  = boardGameRepository;
 }
Exemple #3
0
 public GameService(IGameRepository gameRepository, ITurnRepository turnRepository, IPlayerRepository playerRepository, IGameResultRepository gameResultRepository)
 {
     _playerRepository     = playerRepository;
     _gameRepository       = gameRepository;
     _turnRepository       = turnRepository;
     _maxPoint             = 21;
     _minPoint             = 17;
     _gameResultRepository = gameResultRepository;
 }
Exemple #4
0
 public GameTableService(IGamerService gamerService, IGameTableRepository gameTableRepository,
                         IBoardGameService boardGameService,
                         IGameParticipationService gameParticipationService, IGameResultRepository gameResultRepository)
 {
     _gamerService             = gamerService;
     _gameTableRepository      = gameTableRepository;
     _boardGameService         = boardGameService;
     _gameParticipationService = gameParticipationService;
     _gameResultRepository     = gameResultRepository;
 }
Exemple #5
0
        public DeckViewModel(
            IBackgroundWorkInterface backgroundWorkInterface,
            ICardInfoProvider cardInfoProvider,
            IDeckImportInterface deckImportInterface,
            ISerializer <Models.Client.Decklist> decklistSerializer,
            IDeckRepository deckRepository,
            IEventDispatcher gameEventDispatcher,
            IGameResultRepository gameResultRepository,
            IPlayerDeckTrackerInterface playerDeckTrackerInterface,
            IReplaceDeckInterface replaceDeckInterface,
            IUserConfirmationInterface userConfirmationInterface,
            IEventDispatcher viewEventDispatcher,
            Guid deckID,
            Models.Client.Decklist decklist,
            Func <DeckViewModel, ushort> getPosition,
            string title,
            IEnumerable <Models.Client.GameResult> gameResults = null)
        {
            _backgroundWorkInterface    = backgroundWorkInterface.Require(nameof(backgroundWorkInterface));
            _cardInfoProvider           = cardInfoProvider.Require(nameof(cardInfoProvider));
            _deckImportInterface        = deckImportInterface.Require(nameof(deckImportInterface));
            _decklistSerializer         = decklistSerializer.Require(nameof(decklistSerializer));
            _deckRepository             = deckRepository.Require(nameof(deckRepository));
            _gameEventDispatcher        = gameEventDispatcher.Require(nameof(gameEventDispatcher));
            _gameResultRepository       = gameResultRepository.Require(nameof(gameResultRepository));
            _playerDeckTrackerInterface = playerDeckTrackerInterface.Require(nameof(playerDeckTrackerInterface));
            _replaceDeckInterface       = replaceDeckInterface.Require(nameof(replaceDeckInterface));
            _userConfirmationInterface  = userConfirmationInterface.Require(nameof(userConfirmationInterface));
            _viewEventDispatcher        = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            DeckID       = deckID;
            Decklist     = decklist;
            _gameResults = (gameResults ?? Enumerable.Empty <Models.Client.GameResult>()).ToList();
            _getPosition = getPosition.Require(nameof(getPosition));
            Title        = title ?? string.Empty;

            _viewEventHandlers.Add(
                new DelegateEventHandler <ViewEvents.DeckTracking>(
                    __event =>
            {
                IsTracking = __event.DeckViewModel == this;

                _deleteCanExecuteChanged?.Invoke();
                _replaceCanExecuteChanged?.Invoke();
            }));

            _viewEventHandlers.ForEach(__handler => _viewEventDispatcher.RegisterHandler(__handler));
        }
 public GameResultController(IGameResultRepository resultRepository)
 {
     _resultRepository = resultRepository;
 }
Exemple #7
0
 public PlayerSpecs Specs(IGameResultRepository gameResult, Guid gameId, int roundsWon)
 {
     return(new PlayerSpecs(this, roundsWon, TotalScoreIn(gameResult, gameId)));
 }
Exemple #8
0
        public double TotalScoreIn(IGameResultRepository gameResult, Guid gameId)
        {
            GameScoreProvider gsp = new GameScoreProvider(gameResult);

            return(gsp.PlayerScoresInGame(Id, gameId));
        }
 public GameResultServico(IGameResultRepository repositorio)
     : base(repositorio)
 {
     _repositorio = repositorio;
 }
Exemple #10
0
 public GameResultService(IGameResultRepository repository)
 {
     this.repository = repository;
 }
Exemple #11
0
 public GameResultService(IGameResultRepository gamerepository) : base(gamerepository)
 {
 }
Exemple #12
0
 public GameResultMemoryStorageService(IGameResultRepository repository) : base(repository)
 {
 }
 public AddGameResultService(IGameResultRepository gameResultRepository)
 {
     _gameResultRepository = gameResultRepository;
 }
 public GameResultService(IGameResultRepository gameResultRepository) : base(gameResultRepository)
 {
     this.gameResultRepository = gameResultRepository;
 }
Exemple #15
0
 public GameScoreProvider(IGameResultRepository gameResult)
 {
     _gameResult = gameResult;
 }
Exemple #16
0
 public GameResultReplicationService(IGameResultRepository repository) : base(repository)
 {
 }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="gameResultRepository">Repository of games result entity</param>
 public GameResultService(IGameResultRepository gameResultRepository) => this.GameResultRepository = gameResultRepository;
        public DeckManagerViewModel(
            IBackgroundWorkInterface backgroundWorkInterface,
            ICardInfoProvider cardInfoProvider,
            IDeckImportInterface deckImportInterface,
            ISerializer <Models.Client.Decklist> decklistSerializer,
            IDeckRepository deckRepository,
            IEventStreamFactory eventStreamFactory,
            IEventDispatcher gameEventDispatcher,
            IGameResultRepository gameResultRepository,
            ILogger logger,
            IPlayerDeckTrackerInterface playerDeckTrackerInterface,
            IReplaceDeckInterface replaceDeckInterface,
            IUserConfirmationInterface userConfirmationInterface,
            IEventDispatcher viewEventDispatcher)
        {
            _backgroundWorkInterface = backgroundWorkInterface.Require(nameof(backgroundWorkInterface));
            _cardInfoProvider        = cardInfoProvider.Require(nameof(cardInfoProvider));
            _deckImportInterface     = deckImportInterface.Require(nameof(deckImportInterface));
            _decklistSerializer      = decklistSerializer.Require(nameof(decklistSerializer));
            _deckRepository          = deckRepository.Require(nameof(deckRepository));
            _eventStreamFactory      = eventStreamFactory.Require(nameof(eventStreamFactory));
            _gameEventDispatcher     = gameEventDispatcher.Require(nameof(gameEventDispatcher));
            _gameResultRepository    = gameResultRepository.Require(nameof(gameResultRepository));
            _logger = logger.Require(nameof(logger));
            _playerDeckTrackerInterface = playerDeckTrackerInterface.Require(nameof(playerDeckTrackerInterface));
            _replaceDeckInterface       = replaceDeckInterface.Require(nameof(replaceDeckInterface));
            _userConfirmationInterface  = userConfirmationInterface.Require(nameof(userConfirmationInterface));
            _viewEventDispatcher        = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            // Start loading pre-existing decks
            Task.Run(
                async() =>
            {
                IEnumerable <Models.Client.Deck> decks = await _deckRepository.GetAllDecks();

                _deckViewModels =
                    new ObservableCollection <DeckViewModel>(
                        decks
                        .OrderBy(__deck => __deck.Position)
                        .Select(
                            __deck =>
                            CreateDeckViewModel(
                                __deck.DeckID,
                                DeserializeDecklist(__deck.DeckString),
                                __deck.Title,
                                __deck.GameResults)));

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DeckViewModels)));
            });

            Task.Run(
                async() =>
            {
                using (IEventStream eventStream = _eventStreamFactory.Create())
                {
                    eventStream.SeekEnd();

                    while (true)
                    {
                        try { _gameEventDispatcher.DispatchEvent(await eventStream.ReadNext()); }
                        catch (Exception ex) { await _logger.Write($"{ex.Message}{Environment.NewLine}{ex.StackTrace}"); }
                    }
                }
            });

            _viewEventDispatcher.RegisterHandler(
                new DelegateEventHandler <ViewCommands.DeleteDeck>(
                    async __event =>
            {
                DeckViewModel deckViewModel =
                    _deckViewModels
                    .FirstOrDefault(__deckViewModel => __deckViewModel.DeckID == __event.DeckID);
                if (deckViewModel == null)
                {
                    return;
                }

                _deckViewModels.Remove(deckViewModel);

                await SaveDecks();
            }));

            _viewEventDispatcher.RegisterHandler(
                new DelegateEventHandler <ViewCommands.MoveDeck>(
                    async __event =>
            {
                ushort sourcePosition = __event.SourcePosition;
                if (sourcePosition > _deckViewModels.Count)
                {
                    return;
                }

                DeckViewModel sourceDeck = _deckViewModels[sourcePosition];
                _deckViewModels.RemoveAt(sourcePosition);

                ushort targetPosition = __event.TargetPosition;
                _deckViewModels.Insert(targetPosition, sourceDeck);

                await SaveDecks();
            }));

            Models.Client.Decklist DeserializeDecklist(
                string deckstring)
            {
                using (var stream = new MemoryStream(Encoding.Default.GetBytes(deckstring)))
                    return(_decklistSerializer.Deserialize(stream).Result);
            }
        }
 public GameResultController()
 {
     gameResultRepository = new GameResultRepository();
 }
Exemple #20
0
 public LeaderboardService(IGameResultRepository replicationRepository, IMemoryCache cache)
 {
     ReplicationRepository = replicationRepository;
     Cache = cache;
 }