Example #1
0
        public CommandResult Handle(T command)
        {
            var player = PlayerStore.GetPlayer();

            return(player.IsDead
                ? CommandResult.Error("You are dead, sorry.")
                : HandlePlayerCommand(player));
        }
Example #2
0
        public void UpdatePosition(string gameId, float position)
        {
            if (!_groupStore.GroupExists(gameId))
            {
                return;
            }

            var playerId = _playerStore.GetPlayer(Context.ConnectionId).Id;

            _gameEngineService.MovePlayer(gameId, playerId, position);
        }
        private THandler CreateSut(
            Player player            = null,
            IPlayerStore playerStore = null,
            IRandom random           = null,
            TOptions options         = null)
        {
            player      = player ?? PlayerFixture.CreateDefaultPlayer();
            playerStore = playerStore ?? Substitute.For <IPlayerStore>();
            playerStore.GetPlayer().Returns(player);
            random = random ?? Substitute.For <IRandom>();
            var opts = Substitute.For <IOptions <TOptions> >();

            opts.Value.Returns(options ?? new TOptions());

            return(CreateSutImpl(playerStore, random, opts));
        }
        private static AttackCommandHandler CreateSut(
            Player player                 = null,
            IPlayerStore playerStore      = null,
            IRandom random                = null,
            IFormulaCalculator calculator = null,
            AttackOptions options         = null)
        {
            player      = player ?? PlayerFixture.CreateDefaultPlayer();
            playerStore = playerStore ?? Substitute.For <IPlayerStore>();
            playerStore.GetPlayer().Returns(player);
            random     = random ?? Substitute.For <IRandom>();
            calculator = calculator ?? Substitute.For <IFormulaCalculator>();

            var optionsSnapshot = Substitute.For <IOptionsSnapshot <AttackOptions> >();

            optionsSnapshot.Value.Returns(options ?? new AttackOptions());

            return(new AttackCommandHandler(playerStore, random, calculator, optionsSnapshot));
        }
Example #5
0
        public PlayerReadModel QueryPlayerState()
        {
            var player = _playerStore.GetPlayer();

            return(new PlayerReadModel(player));
        }