Ejemplo n.º 1
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // Get the word to be said, if any
        string[] otherWord = parserState.GetOtherWordText();

        CommandOutcome outcome     = CommandOutcome.NO_COMMAND;
        bool           resetFoobar = true;

        // If there were any
        if (otherWord != null)
        {
            bool foundMagicWord = false;

            List <string> otherCommands = commandsController.FindMatch(otherWord[0]);

            foreach (string command in otherCommands)
            {
                if (magicWords.Contains(command))
                {
                    if (command == "2025FeeFieFoe")
                    {
                        resetFoobar = false;
                    }

                    foundMagicWord = true;
                    break;
                }
            }

            // If it's one of the magic words, discard the SAY verb and just continue to process the magic word
            if (foundMagicWord)
            {
                parserState.CurrentCommandState = CommandState.NO_COMMAND;
            }
            else
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage("258SayWord", otherWord));
                parserState.CommandComplete();
                outcome = CommandOutcome.MESSAGE;
            }
        }
        else
        {
            parserState.CarryOverVerb();
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("257VerbWhat", parserState.Words));
            parserState.CurrentCommandState = CommandState.NO_COMMAND; // Indicate we're done with this command
        }

        // If used with anything other than the Fee Fie Foe sequence, then reset foobar
        if (resetFoobar)
        {
            controller.ResetFoobar();
        }

        return(outcome);
    }
Ejemplo n.º 2
0
    // Tries to identify a subject for the command and returns the ID of the item or null, if none could be found
    public string GetSubject(string actionID)
    {
        string subject = null;

        // If no subject has been identified and there are no further commands to be processed
        if (!parserState.ContainsState(CommandState.SUBJECT_IDENTIFIED) && !parserState.ContainsState(CommandState.NOT_PROCESSED) && !parserState.ContainsState(CommandState.PENDING) && !parserState.SetCarriedOverCommand(true))
        {
            // Otherwise check to see if the command can assume a subject based on the current context
            subject = actions[actionID].FindSubstituteSubject();
        }

        // If the subject has not yet been set but a subject has been identified
        if (subject == null && parserState.ContainsState(CommandState.SUBJECT_IDENTIFIED))
        {
            // ... set it
            subject = parserState.Subject;
        }

        // If we've still not found a subject and there's nothing further to process, it is ambiguous, so ask player for clarification
        if (subject == null && !parserState.ContainsState(CommandState.NOT_PROCESSED) && !parserState.ContainsState(CommandState.PENDING) && !actions[actionID].SubjectOptional)
        {
            if (actions[actionID].CarryOverVerb)
            {
                parserState.CarryOverVerb();
            }

            NoSubjectMsg noSubjectMsg = actions[actionID].NoSubjectMessage;

            if (noSubjectMsg.messageParams != null)
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage(noSubjectMsg.messageID, noSubjectMsg.messageParams));
            }
            else
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage(noSubjectMsg.messageID));
            }

            parserState.CurrentCommandState = CommandState.NO_COMMAND; // Indicate we're done with this command
        }

        return(subject);
    }