コード例 #1
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("To get information about the current active threats, you need to start a new game. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            if (game.ThreatManager.ExternalThreats.Count < 1 && game.ThreatManager.InternalThreats.Count < 1)
            {
                return(ResponseCreator.Ask("There are no active threats at the moment. Use the threat information command when you need information about an active threat. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            string message  = "";
            var    request  = (IntentRequest)information.SkillRequest.Request;
            string threatId = request.Intent.Slots["Threat"].GetSlotId();
            var    threat   = game.ThreatManager.GetActiveThreat(threatId);

            if (threat == null)
            {
                string threatName = request.Intent.Slots["Threat"].Value;
                return(ResponseCreator.Ask($"{threatName} is not a valid active threat. Try the threat information command again and provide one of the following: {game.ThreatManager.GetThreatsAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // valid active threat let's grab the info message
            message += threat.GetInfoMessage();
            message += "What are your orders, captain? ";

            game.Message = message;

            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
 public Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
 {
     return(Task.FromResult(ResponseBuilder.Ask(new SsmlOutputSpeech(Helper.ssmlString("For a list of all connected users ask, who is online? If you want information about the server, say serverinfo.")), new Reprompt()
     {
         OutputSpeech = new PlainTextOutputSpeech("For a list of all connected users ask, who is online? If you want information about the server, say Serverinfo.")
     })));
 }
コード例 #3
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before healing your crew. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("You cannot heal the crew in this ship. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Medical && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available medical crew to heal our units in the infirmary. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.InfirmaryCrewCount < 1)
            {
                return(ResponseCreator.Ask("There are no crew members in the infirmary. Use this command when someone ends up in the infirmary. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // we are good to go, heal the units in t he infirmary
            ship.HealCrew();

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #4
0
ファイル: Roll.cs プロジェクト: stoiveyp/Spellcasting
        public static SkillResponse GenerateRoll(AlexaRequestInformation <APLSkillRequest> information)
        {
            var result = GetResult(information.SkillRequest);

            information.State.SetSession(SessionKeys.LastRoll, result);
            return(GetResponse(result, information.SkillRequest.SupportsAPL1_1()));
        }
コード例 #5
0
        public override bool CanHandle(AlexaRequestInformation <SkillRequest> information)
        {
            var game    = (Game)information.Context;
            var request = (IntentRequest)information.SkillRequest.Request;

            return(game.GameState == Enums.GameState.Rules && request.Intent.Name == BuiltInIntent.Previous);
        }
コード例 #6
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation information)
        {
            var speech = new Speech(
                new Paragraph(new PlainText("Okay, here's a list of the meetups being monitored"))
                );

            foreach (var techEvent in EventNames)
            {
                var eventSentence = new Sentence();
                if (string.IsNullOrWhiteSpace(techEvent.Value))
                {
                    eventSentence.Elements.Add(new PlainText(techEvent.Key));
                }
                else
                {
                    eventSentence.Elements.Add(new Sub(techEvent.Key, techEvent.Value));
                }

                speech.Elements.Add(
                    new Paragraph(eventSentence)
                    );
            }

            speech.Elements.Add(
                new Paragraph(new PlainText("to find out about a meetup say, give me details on, followed by the meetup name."))
                );

            speech.Elements.Add(
                new Paragraph(new PlainText("to find out about a meetup say, when's the meetup for, and then the meetup name"))
                );

            information.State.SetSession(SessionKeys.CurrentActivity, SkillActivities.WhatEvent);
            return(ResponseBuilder.Ask(speech, null));
        }
コード例 #7
0
 public bool CanHandle(AlexaRequestInformation information)
 {
     return(information.SkillRequest.Request is IntentRequest intent &&
            intent.Intent.Name == Consts.IntentAllEvent &&
            intent.Intent.Slots.ContainsKey(Consts.SlotDateRange) &&
            !string.IsNullOrWhiteSpace(intent.Intent.Slots[Consts.SlotDateRange].Value));
 }
コード例 #8
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            var intent = ((IntentRequest)information.SkillRequest.Request).Intent;

            if (
                string.IsNullOrWhiteSpace(intent.Slots[Consts.SlotRelativeDate]?.Value) ||
                string.IsNullOrWhiteSpace(intent.Slots[Consts.SlotTimeOfDay]?.Value))
            {
                return(ResponseBuilder.DialogDelegate(intent));
            }

            var events = await new TechMeetState {
                GroupName = information.State.GetSession <string>(SessionKeys.CurrentGroup)
            }.GetEventsFromS3();
            var meetupEvent = events.FirstOrDefault(e => e.Id == information.State.GetSession <string>(SessionKeys.CurrentEvent));

            if (meetupEvent == null)
            {
                return(ResponseBuilder.Tell(
                           "I'm sorry, but I can't seem to find the last event you looked for. If you look at another event I can set a reminder then"));
            }

            //Calculate Reminder
            var date = CalculateReminderDate(LocalDate.FromDateTime(DateTime.Parse(meetupEvent.LocalDate)),
                                             intent.Slots[Consts.SlotRelativeDate].Id());

            var speech = $"I'll remind you about {meetupEvent.Group.Name} on {date.ToDateTimeUnspecified():dddd dd MMMM} at {intent.Slots[Consts.SlotTimeOfDay]?.Value}. Is that correct?";

            intent.Slots["confirmation"].Value = "1";
            return(ResponseBuilder.DialogConfirmSlot(new PlainTextOutputSpeech {
                Text = speech
            }, "confirmation", intent));
        }
コード例 #9
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            var request     = information.SkillRequest as APLSkillRequest;
            var id          = ((IntentRequest)request.Request).Intent.Slots[Consts.SlotEvent].Id();
            var currentDate = LocalDate.FromDateTime(DateTime.Now);

            var meetup = new TechMeetState {
                GroupName = id
            };
            var rawEvents = await meetup.GetEventsFromS3();

            var groupData = await meetup.GetGroupFromS3();

            var events = rawEvents.ToLocalEventTime();

            information.State.ClearSession();
            information.State.SetSession(SessionKeys.CurrentActivity, SkillActivities.Event);
            information.State.SetSession(SessionKeys.CurrentGroup, id);
            if (!events.Any())
            {
                return(SpeechHelper.NoEvent());
            }

            var eventToRecognise =
                (events.Any(l => l.Date > currentDate)
                    ? events.Where(e => e.Date > currentDate)
                    : events).First();

            information.State.SetSession(SessionKeys.CurrentEvent, eventToRecognise.Event.Id);
            return(await SpeechHelper.SingleEventResponse(request, eventToRecognise, currentDate, groupData, "I've got information on a meetup event. "));
        }
コード例 #10
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (_intentName == BuiltInIntent.Yes)
            {
                // we should continue previous game
                game.Message         = game.RepeatMessage;
                game.RepromptMessage = "Awaiting your orders, captain. ";
                game.GameState       = game.LastGameState;
                game.SaveData();
            }
            else if (_intentName == BuiltInIntent.No)
            {
                // answer was No, go back to main menu
                game.IsGameInProgress = false;
                game.Welcome();
            }
            else
            {
                // invalid answer, ask the continue game prompt again
                return(ResponseCreator.Ask("I'm sorry, I didn't get that. Do you want to continue playing your last unfinished game? ", "To continue your last game, say yes. Otherwise, say no. ", information.SkillRequest.Session));
            }

            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #11
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "I'm sorry Captain, that is not a valid command. ";

            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #12
0
        public override async Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "I'm sorry Captain, that is not a valid command. Say help if you need assistance. ";

            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
        public async Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
        {
            var clients = await Helper.GetClients();

            if (clients.Count == 0)
            {
                return(ResponseBuilder.Tell(new SsmlOutputSpeech(Helper.ssmlString("There's nobody online."))));
            }
            else if (clients.Count == 1)
            {
                return(ResponseBuilder.Tell(new SsmlOutputSpeech(Helper.ssmlString("There's one person on the server. " + Helper.NormalizeClients(clients).First().NickName + "."))));
            }
            else
            {
                string users = "";
                clients = Helper.NormalizeClients(clients);
                int i = 0;
                foreach (var user in clients)
                {
                    if (i < clients.Count - 1)
                    {
                        users += user.NickName + ",";
                    }
                    else
                    {
                        users += " and " + user.NickName + ",";
                    }

                    i++;
                }


                return(ResponseBuilder.Tell(new SsmlOutputSpeech(Helper.ssmlString("There are several people online. " + users))));
            }
        }
コード例 #14
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            Session session = information.SkillRequest.Session;
            String  speech  = "Bye";//localizer.Get(currentLocale, "GOODBYE_MSG");

            return(ResponseBuilder.Tell(speech));
        }
コード例 #15
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before removing locked threats from your scanners. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("You cannot remove the locked threats from  your scanners in this ship. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Medical && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available medical crew to remove a locked threat from our scanners. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.ScannerCount < 1)
            {
                return(ResponseCreator.Ask("There are no locked threats on our scannerse. Use this command when you roll a threat that gets locked on the scanners. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            // we are good to go, remove a threat from the scanner
            ship.RemoveThreatFromScanner();

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #16
0
 public bool CanHandle(AlexaRequestInformation information)
 {
     return(information.SkillRequest.Request is IntentRequest intentRequest &&
            intentRequest.Intent.Name == Consts.IntentReminder &&
            !string.IsNullOrWhiteSpace(information.State.GetSession <string>(SessionKeys.CurrentEvent)) &&
            intentRequest.Intent.Slots["confirmation"].ConfirmationStatus == ConfirmationStatus.Denied);
 }
 public Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
 {
     return(Task.FromResult(ResponseBuilder.Ask(new SsmlOutputSpeech(Helper.ssmlString("Sorry, I didn't get that. Please say it again.")), new Reprompt()
     {
         OutputSpeech = new PlainTextOutputSpeech("I didn't get that. Please say it again.")
     })));
 }
コード例 #18
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var    game    = (Game)information.Context;
            string message = "";

            switch (game.GameState)
            {
            case Enums.GameState.MainMenu:
                message = "You are in the main menu. Say new game to begin, or say rules to learn how to play. ";
                break;

            case Enums.GameState.PlayerTurn:
                message = "Here's a reference for all commands: 1. End turn. 2. Transform. 3. Assign tactical crew to weapons. 4. Fire weapons. 5. Fire stasis beam. 6. Recharge Shields. 7. Heal Crew. 8. Remove Threat. 9. Repair Hull. 10. Send crew on a mission. 11. Return crew from a mission. 12. I need more  time. 13. Status. 14. Threat status. 15. Threat information. ";
                break;

            case Enums.GameState.FiringWeapons:
                message = "You have assigned tactical crew to your weapons. Say fire weapons to open fire. ";
                break;

            case Enums.GameState.ContinueGamePrompt:
                message = "Say yes to continue playing your last unfinished game. Say no to go to the main menu.";
                break;

            case Enums.GameState.Rules:
                message = "Say next to continue to the next rule, back to go back to the previous rule, or repeat to repeat the current rule. You can say new game at any point to start a new game. ";
                break;
            }


            return(ResponseCreator.Ask(message, game.RepromptMessage, information.SkillRequest.Session));
        }
コード例 #19
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation information)
        {
            information.State.ClearSession();
            var intent = ((IntentRequest)information.SkillRequest.Request).Intent;

            var dates       = AmazonDateParser.Parse(intent.Slots[Consts.SlotDateRange].Value);
            var currentDate = LocalDate.FromDateTime(DateTime.Now);
            var id          = intent.Slots[Consts.SlotEvent].Id();

            var meetup = new TechMeetState {
                GroupName = id
            };

            var rawEvents = await meetup.GetEventsFromS3();

            var groupData = await meetup.GetGroupFromS3();

            information.State.SetSession(SessionKeys.CurrentActivity, SkillActivities.Event);
            information.State.SetSession(SessionKeys.CurrentGroup, id);

            var eventToRecognise = rawEvents.ToLocalEventTime()
                                   .Where(d => d.Date >= dates.From && d.Date <= dates.To).Where(d => d.Date >= currentDate).ToArray();

            if (!eventToRecognise.Any())
            {
                return(SpeechHelper.NoEvent(true));
            }

            if (eventToRecognise.Length == 1)
            {
                return(await SpeechHelper.SingleEventResponse((APLSkillRequest)information.SkillRequest, eventToRecognise.First(), currentDate, groupData, "I've got information on a meetup event. "));
            }

            return(SpeechHelper.RespondToEvent(eventToRecognise, currentDate, groupData.Name));
        }
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            Session  session = information.SkillRequest.Session;
            String   speech  = LocalizationManager.Translate("WELCOME_MESSAGE");
            Reprompt rp      = new Reprompt(speech);

            return(ResponseBuilder.Ask(speech, rp, session));
        }
コード例 #21
0
        public override bool CanHandle(AlexaRequestInformation <SkillRequest> information)
        {
            var request = (IntentRequest)information.SkillRequest.Request;

            _intentName = request.Intent.Name;
            return(_intentName == "ShipStatusIntent" || _intentName == "CrewStatusIntent" ||
                   _intentName == "ScannerStatusIntent" || _intentName == "ShipHealthStatusIntent");
        }
コード例 #22
0
 public bool CanHandle(AlexaRequestInformation information)
 {
     return(information.SkillRequest.Request is IntentRequest intent &&
            !string.IsNullOrWhiteSpace(information.State.GetSession <string>(SessionKeys.CurrentActivity)) &&
            (intent.Intent.Name == BuiltInIntent.No ||
             intent.Intent.Name == BuiltInIntent.Cancel ||
             intent.Intent.Name == BuiltInIntent.Stop));
 }
コード例 #23
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information, Exception exception)
        {
            Session  session = information.SkillRequest.Session;
            String   speech  = "Error";//localizer.Get(currentLocale, "ERROR");
            Reprompt rp      = new Reprompt(speech);

            return(ResponseBuilder.Ask(speech, rp, session));
        }
コード例 #24
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
        {
            // session ended save current session data to dynamo db
            var game = (Game)information.Context;
            await game.SaveDataToDb();

            return(ResponseBuilder.Empty());
        }
コード例 #25
0
        public override bool CanHandle(AlexaRequestInformation <SkillRequest> information)
        {
            var  intentRequest    = (IntentRequest)information.SkillRequest.Request;
            bool isContinuePrompt = ((Game)information.Context).GameState == GameState.ContinueGamePrompt;

            _intentName = intentRequest.Intent.Name;


            return(isContinuePrompt);
        }
コード例 #26
0
        public async Task <SkillResponse> Handle(AlexaRequestInformation <SkillRequest> information)
        {
            // session ended save current session data to dynamo db
            var game = (Game)information.Context;
            await game.SaveDataToDb();

            string message = "Thank you for playing Deep Space Dice. I will be expecting your return, Captain. If you enjoyed playing Deep Space Dice, you should try Desolate. To launch Desolate, say Alexa, enable Desolate Board Game. ";

            return(ResponseBuilder.Tell(message));
        }
コード例 #27
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation information)
        {
            if (information.State.GetSession <SkillActivities>(SessionKeys.CurrentActivity) == SkillActivities.Event)
            {
            }

            return(ResponseBuilder.Ask(@"I can tell you about several meetups in and around the Nottingham area.
If you're unsure of what meetups are available say, what meetups can I pick from,
                                       If you have a meetup you want to know about, ask when the next meetup is and include the name of the event. Once you've listened to the detail of an event you can ask to have a reminder set.
", null, new Session()));
        }
コード例 #28
0
ファイル: Roll.cs プロジェクト: stoiveyp/Spellcasting
        public override bool CanHandle(AlexaRequestInformation <APLSkillRequest> information)
        {
            if (!information.SkillRequest.IsIntentName(IntentNames.Roll))
            {
                return(false);
            }

            SetDefaults(information.SkillRequest.Request as IntentRequest);

            return(true);
        }
コード例 #29
0
        public async Task <SkillResponse> Intercept(AlexaRequestInformation information, RequestInterceptorCall next)
        {
            var result = await next(information);

            if (result.SessionAttributes == null)
            {
                result.SessionAttributes = information.State.Session.Attributes;
            }

            return(result);
        }
コード例 #30
0
        public override SkillResponse HandleSyncRequest(AlexaRequestInformation <SkillRequest> information)
        {
            var game = (Game)information.Context;

            if (!game.IsGameInProgress)
            {
                return(ResponseCreator.Ask("You need to start a new game before firing the stasis beam. Say new game to begin. ", "To start, say new game. ", information.SkillRequest.Session));
            }

            var ship = game.Ship as HalcyonShip;

            if (ship == null)
            {
                return(ResponseCreator.Ask("Our ship does not have a stasis beam. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            if (!ship.Crew.Any(c => c.Type == Enums.CrewType.Science && c.State == CrewState.Available))
            {
                return(ResponseCreator.Ask($"We have no available science crew to fire the stasis beam. We have {ship.GetAvailableCrewAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (game.ThreatManager.ExternalThreats.Count < 1 && game.ThreatManager.InternalThreats.Count < 1)
            {
                return(ResponseCreator.Ask("There are no threats to disable with the stasis beam. ", game.RepromptMessage, information.SkillRequest.Session));
            }

            if (ship.ShipSystems["ScienceUnavailable"])
            {
                return(ResponseCreator.Ask("Our science crew are having an existentialism crisis and are unavailable. Send a science crew on a mission to deal with cosmic existentialism to be able to use them again. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // check if enemy target is present
            var    request  = (IntentRequest)information.SkillRequest.Request;
            string threatId = request.Intent.Slots["Threat"].GetSlotId();
            var    threat   = game.ThreatManager.GetActiveThreat(threatId);

            if (threat == null)
            {
                string threatName = request.Intent.Slots["Threat"].Value;
                return(ResponseCreator.Ask($"{threatName} is not a valid target. Try firing the stasis beam again and provide one of the following: {game.ThreatManager.GetThreatsAsString()}. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // we have a valid target, let's check if it is already disabled
            if (threat.IsDisabled)
            {
                return(ResponseCreator.Ask($"{threat.Name} is already disabled. We can use the stasis beam on targets that are still active. ", game.RepromptMessage, information.SkillRequest.Session));
            }
            // we have a valid target, fire the stasis beam
            ship.FireStasisBeam(threat);

            game.Message        += "Awaiting further orders, captain. ";
            game.RepeatMessage   = game.Message;
            game.RepromptMessage = "Waiting for further orders, captain. ";
            game.SaveData();
            return(ResponseCreator.Ask(game.Message, game.RepromptMessage, information.SkillRequest.Session));
        }