Ejemplo n.º 1
0
        private async Task <DialogTurnResult> AskStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            Activity activity;

            //display board
            if (stepContext.Options == null || (bool)stepContext.Options == true)
            {
                if (GameState.Board.getCurrentPlayerName().Equals("Your"))
                {
                    activity = MessageFactory.Text("", $"{GameState.Board.getCurrentPlayerName()} turn", InputHints.ExpectingInput);
                }
                else
                {
                    activity = MessageFactory.Text("", $"{GameState.Board.getCurrentPlayerName()}'s turn", InputHints.ExpectingInput);
                }
                //prompt user to get the place they want to put their piece
                //activity.Attachments = new List<Attachment> { (CreateAdaptiveCardAttachment(board)) };
                //activity.Speak = $"Where would {board.getCurrentPlayerName()} like to place their {board.getCurrentPlayerToken()}";
                //return await stepContext.PromptAsync(nameof(NumberPrompt<int>), new PromptOptions { Prompt = activity }, cancellationToken);
            }
            else
            {
                activity = MessageFactory.Text("", $"That spots already taken, choose again", InputHints.ExpectingInput);
                //return await stepContext.PromptAsync(nameof(NumberPrompt<int>), new PromptOptions { Prompt = activity }, cancellationToken);
            }
            activity.Attachments = new List <Attachment> {
                (BoardAdaptiveCard.CreateAdaptiveCardAttachment(GameState.Board))
            };
            //activity.Speak = $"Where would {board.getCurrentPlayerName()} like to place their {board.getCurrentPlayerToken()}";
            return(await stepContext.PromptAsync(nameof(NumberPrompt <int>), new PromptOptions { Prompt = activity }, cancellationToken));
        }
Ejemplo n.º 2
0
        private async Task <DialogTurnResult> FinalStateStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var currentGameState = GameState.Board.getStatus();

            if (currentGameState == Board.GameState.TIE)
            {
                var activity = (Activity)MessageFactory.Attachment(BoardAdaptiveCard.CreateAdaptiveCardAttachment(GameState.Board));
                activity.Speak  = $"Game Tied. All of you lose";
                GameState.Board = new Board();
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = activity }, cancellationToken));
            }
            else
            {
                //handle winner
                var    activity = (Activity)MessageFactory.Attachment(BoardAdaptiveCard.CreateAdaptiveCardAttachment(GameState.Board));
                string winner   = GameState.Board.getWinnerName() + " wins";
                if (winner.Equals("Your wins"))
                {
                    winner = "You win";
                }
                activity.Speak  = $"Game Over. " + winner;
                GameState.Board = new Board();
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = activity }, cancellationToken));
            }
        }