/// <inheritdoc />
        public async Task OnCommandAsync(PacketConnection context, string argument)
        {
            _game.ThrowIfNotHost(Command);
            _game.ThrowIfWrongState(Command, GameState.Handshake);

            SetNameFromArgument(argument);

            await context.SendResponseAsync(ResponseCode.Handshake, _game.LocalPlayer.Name);

            _game.GameState = GameState.Idle;
        }
Example #2
0
        /// <inheritdoc />
        public Task OnCommandAsync(PacketConnection context, string argument)
        {
            _game.ThrowIfNotHost(Command);
            _game.ThrowIfWrongState(Command, GameState.Idle);

            _game.GameState    = GameState.InGame;
            _game.IsLocalsTurn = _random.NextBool();

            if (_game.IsLocalsTurn)
            {
                return(context.SendResponseAsync(ResponseCode.StartHost, "Host starts"));
            }
            else
            {
                return(context.SendResponseAsync(ResponseCode.StartClient, "Client starts"));
            }
        }
Example #3
0
        /// <inheritdoc />
        public Task OnCommandAsync(PacketConnection context, string argument)
        {
            _game.ThrowIfNotHost(Command);

            return(_game.Disconnect());
        }