// Attempts to move player avatar to a new location and returns the outcome of the movement - potential location will be updated with the location the player avatar is trying to move to
    public CommandOutcome MovePlayer(MovementWord command)
    {
        // Start with potential location being the same as the current location
        PotentialLocation = CurrentLocation;

        // Keep track of where player avatar is moving from
        UpdateOldLocations();

        // See if the command is valid for movement from this location
        MoveOutcome outcome = locationController.TryMovement(command);

        string moveMsg;

        if (outcome.locationID != null && outcome.locationID != "")
        {
            // The command attempts to move player avatar to a new location
            PotentialLocation = outcome.locationID;
            return(CommandOutcome.FULL);
        }
        else if (outcome.messageID != null && outcome.messageID != "")
        {
            // The command triggers a message for the player instead of a movement
            moveMsg = outcome.messageID;
        }
        else
        {
            // The command doesn't do anything at this location, so show a default message for that command
            moveMsg = command.DefaultMessageID;
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(moveMsg));
        return(CommandOutcome.MESSAGE);
    }
Пример #2
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        location = playerController.CurrentLocation;

        // Check whether a subject was identified, or could be identified
        noSubjectMsg     = new NoSubjectMsg("257VerbWhat", parserState.Words);
        itemToExtinguish = controller.GetSubject("off");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToExtinguish == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string[] offMsg = new string[2] {
            null, null
        };

        switch (itemToExtinguish)
        {
        case LAMP:
            // Turn the lamp off
            itemController.SetItemState(LAMP, 0);
            offMsg[0] = "40LampOff";

            //If the location is dark, warn the player about the danger of wandering about in the dark
            if (locationController.IsDark(location))
            {
                offMsg[1] = "16PitchDark";
            }
            break;

        case URN:
            // Turn urn off
            int urnState = itemController.GetItemState(URN);
            itemController.SetItemState(URN, urnState == 2 ? 1 : urnState);
            offMsg[0] = "210UrnDark";
            break;

        case "31Dragon":
        case "37Volcano":
            offMsg[0] = "146BeyondPower";
            break;

        default:
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(offMsg[0]));

        if (offMsg[1] != null)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage(offMsg[1]));
        }

        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #3
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);
    }
Пример #4
0
    // Checks if player has passed a number of turns threshold, and shows message and deducts points if so
    public void CheckTurnThresholds(int turns)
    {
        if (ThresholdIndex < turnThresholds.Length && turns == turnThresholds[ThresholdIndex].threshold)
        {
            TurnsPointsLost += turnThresholds[ThresholdIndex].pointsLost;

            textDisplayController.AddTextToLog(playerMessageController.GetMessage(turnThresholds[ThresholdIndex].messageID));
            ThresholdIndex++;
        }
    }
    // Process an action command
    private CommandOutcome ProcessAction(Command command)
    {
        parserState.CurrentCommandState = CommandState.VERB_IDENTIFIED;

        ActionWord     action        = (ActionWord)command;
        CommandOutcome actionOutcome = actionController.ExecuteAction(action.ActionID);

        CommandState commandState = parserState.CurrentCommandState;

        if (commandState == CommandState.DISCARDED)
        {
            if (action.DefaultMessageID != null || action.DefaultMessageID != "")
            {
                // If the action couldn't be executed and there's a default message, show the default message for that action
                textDisplayController.AddTextToLog(playerMessageController.GetMessage(action.DefaultMessageID));
            }

            // Mark this command as complete
            parserState.CommandComplete();
        }
        else if (commandState == CommandState.VERB_IDENTIFIED || commandState == CommandState.NOT_PROCESSED || (commandState == CommandState.NO_COMMAND && parserState.ContainsState(CommandState.NOT_PROCESSED)))
        {
            // If the processing of the command is suspended, pending the processing of another command, or has been reset to not processed, then continue processing
            return(ProcessCommand());
        }

        return(actionOutcome);
    }
Пример #6
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // Note whether it's dark
        isDark = gameController.IsDark();

        // Check whether a subject was identified
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToRead = controller.GetSubject("read");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToRead == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        CommandOutcome outcome = CommandOutcome.MESSAGE;

        if (isDark)
        {
            // If it's dark, can't see object to read it
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("256ISeeNo", parserState.GetOtherWordText()));
        }
        else
        {
            string itemText = itemController.ReadItem(itemToRead);

            if (itemText != null)
            {
                if (itemToRead != "15Oyster" || scoreController.ClosedHintShown)
                {
                    textDisplayController.AddTextToLog(itemText);
                }
                else
                {
                    // Oyster is a special case when read after cave closed before hint has been revealed
                    questionController.RequestQuestionResponse("read");
                    outcome = CommandOutcome.QUESTION;
                }
            }
            else
            {
                parserState.CurrentCommandState = CommandState.DISCARDED;
                return(CommandOutcome.NO_COMMAND);
            }
        }

        parserState.CommandComplete();
        return(outcome);
    }
Пример #7
0
    public override CommandOutcome DoAction()
    {
        string location    = playerController.CurrentLocation;
        bool   inReservoir = location == "168BottomOfReservoir";

        // Only works if player is at either side of, or in, the reservoir
        if (itemController.ItemIsAt(RESERVOIR, location) || inReservoir)
        {
            CommandOutcome outcome = CommandOutcome.MESSAGE;
            int            currentReservoirState = itemController.GetItemState(RESERVOIR);
            itemController.SetItemState(RESERVOIR, currentReservoirState + 1);
            string zzzzzText = itemController.DescribeItem(RESERVOIR);
            itemController.SetItemState(RESERVOIR, 1 - currentReservoirState);

            // If player is in reservoir, they've just killed themself
            if (inReservoir)
            {
                zzzzzText += "\n" + playerMessageController.GetMessage("241NotBright");
                playerController.KillPlayer();
                outcome = CommandOutcome.FULL;
            }

            textDisplayController.AddTextToLog(zzzzzText);
            parserState.CommandComplete();
            return(outcome);
        }
        else
        {
            // Everywhere else, nothing happens, so force default message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }
    }
Пример #8
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // If the phony rod hasn't been picked up yet or the cave is not yet closed, force default message
        if (gameController.CurrentCaveStatus != CaveStatus.CLOSED || itemController.GetItemState("6BlackRod") < 0)
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        string blastMsg;
        int    bonusPoints;

        if (playerController.ItemIsPresent("6BlackRod"))
        {
            bonusPoints = 25;
            blastMsg    = "135HoistedPetard";
        }
        else if (playerController.CurrentLocation == "115RepositoryNE")
        {
            bonusPoints = 30;
            blastMsg    = "134ExplodeLava";
        }
        else
        {
            bonusPoints = 45;
            blastMsg    = "133EndWithBang";
        }

        scoreController.AddBonusPoints(bonusPoints);
        textDisplayController.AddTextToLog(playerMessageController.GetMessage(blastMsg));
        parserState.CommandComplete();
        return(CommandOutcome.ENDED);
    }
Пример #9
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // If player tried to supply a subject, force default message
        if (controller.GetSubject("resume") != null)
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        CommandOutcome outcome = CommandOutcome.MESSAGE;

        parserState.CommandComplete();

        // If the player has been anywhere other than the first location, ask for confirmation before resuming
        if (locationController.MovedBeyondStart)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("268ResumeInstruction"));
            questionController.RequestQuestionResponse("resume");
            outcome = CommandOutcome.QUESTION;
        }
        else
        {
            // Otherwise just resume a saved game
            YesResume();
        }

        return(outcome);
    }
Пример #10
0
    // === PRIVATE METHODS ===

    // Process the input from the player
    private void ProcessInput(string userInput)
    {
        // Clear the text field and give it the focus back ready for the next command
        inputField.text = null;

        // Only give the input field automatic focus if the lower part of debug panel is not active
        if (!gameController.debugMode || !lowerDebugPanel.activeSelf)
        {
            inputField.ActivateInputField();
        }

        // Create array with inidvidual words
        char[]   delimiters = { ' ' };
        string[] inputWords = userInput.Split(delimiters, System.StringSplitOptions.RemoveEmptyEntries);

        // Nothing to process if learner simply hit return
        if (inputWords.Length > 0)
        {
            // Add the full text entered to the narrative in its original form
            textDisplayController.AddTextToLog(">" + userInput);

            // Calculate number of words entered and set word1 and word2 (if present)
            NumberOfWords = inputWords.Length;
            Words[0]      = formatCommandWord(inputWords[0]);
            Words[1]      = NumberOfWords > 1 ? formatCommandWord(inputWords[1]) : new CommandWord();

            // Run the current delegate for a new command being entered
            commandsEntered();
        }
    }
Пример #11
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // If there was a second word, treat as a find command
        if (parserState.GetOtherWordText() != null)
        {
            return(controller.ExecuteAction("find"));
        }

        string inventoryText;

        int  numItemsCarried = playerController.NumberOfItemsCarried;
        bool bearFollowing   = playerController.HasItem("35Bear");

        if (numItemsCarried > 0 && !(numItemsCarried == 1 && bearFollowing))
        {
            inventoryText = playerMessageController.GetMessage("99InventoryList") + playerController.Inventory;
        }
        else
        {
            inventoryText = playerMessageController.GetMessage("98InventoryEmpty");
        }

        if (bearFollowing)
        {
            inventoryText += "\n\n" + playerMessageController.GetMessage("141TameBear");
        }

        textDisplayController.AddTextToLog(inventoryText);
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #12
0
    // === PUBLIC METHODS ===

    public override string GetLocation()
    {
        string location   = playerController.CurrentLocation;       // Player avatar's current location
        int    trollState = itemController.GetItemState("33Troll"); // Current state of troll

        // If player has already used their purchased passage
        if (trollState == 1)
        {
            // Let player know the troll is blocking them again and restore troll to normal state at bridge (player doesn't move)
            textDisplayController.AddTextToLog(itemController.DescribeItem("33Troll"));
            itemController.DropItemAt("34PhonyTroll", "OutOfPlay");
            itemController.DropItemAt("33Troll", "117ChasmSW", "122ChasmNE");
            itemController.SetItemState("33Troll", 0);
        }
        else
        {
            // Move player to opposite side of chasm
            string newLoc = location == "117ChasmSW" ? "122ChasmNE" : "117ChasmSW";
            //  playerController.GoTo(newLoc, false);

            // Set troll to blocking bridge if he's still around
            if (trollState == 0)
            {
                itemController.SetItemState("33Troll", 1);
            }

            // Check if trying to cross with the bear
            if (playerController.HasItem("35Bear"))
            {
                // Let player know the bridge is destroyed, then destroy bridge and troll, put dead bear at location and kill player
                textDisplayController.AddTextToLog(playerMessageController.GetMessage("162BearWeight"));
                itemController.SetItemState("32Chasm", 1);
                itemController.SetItemState("33Troll", 2);
                itemController.DropItemAt("35Bear", location, newLoc);
                itemController.MakeItemImmovable("35Bear");
                itemController.SetItemState("35Bear", 3);
                playerController.KillPlayer();
                location = "0Death";
            }
            else
            {
                location = newLoc;
            }
        }

        return(location);
    }
Пример #13
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // In all cases simply acknowledge action
        textDisplayController.AddTextToLog(playerMessageController.GetMessage("54OK"));

        // We're done with this command
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #14
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        itemToDrop = null;
        location   = playerController.CurrentLocation;

        // Check whether a subject was identified, or could be identified
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        itemToDrop   = controller.GetSubject("drop");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToDrop == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        // Check if player is trying to drop the rod but they have the phony rod, not the real rod
        DroppingRod();

        outcome = CommandOutcome.MESSAGE;

        // Check for a number of conditions that might stop processing
        if (DoesNotHaveItem() || BirdAttackSnakeEndsGame() || Vending() || DragonKillsBird())
        {
            return(outcome);
        }

        // Check for custom gem interactions
        GemInteractions();

        // Check for bear v troll interaction
        BearTrollInteraction();

        // Check if vase dropped safely
        VaseDropped();

        // Ackowledge completion of the command
        textDisplayController.AddTextToLog(playerMessageController.GetMessage("54OK"));

        // Check if we're trying to drop a liquid
        LiquidDropped();

        // Check if we're dropping the cage with the bird in it
        CageDropped();

        // Drop the item
        itemController.DropItemAt(itemToDrop, location);

        // Check if we've dropped the bird in the forest
        BirdReleased();

        // Mark the command as complete
        parserState.CommandComplete();
        return(outcome);
    }
    // Callback if player answers positively to hint question
    public void HintQuestionYesResponse()
    {
        // Let the player know how much this hint will cost them and ask for confirmation
        int    points    = hints[currentHint].PointsCost;
        string pointsMsg = playerMessageController.GetMessage("261HintCost", new string[] { points.ToString(), points != 1 ? "s" : "" });

        textDisplayController.AddTextToLog(pointsMsg);

        questionController.RequestQuestionResponse("hintConfirm" + currentHint);
    }
Пример #16
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);
    }
    // Responds to a LOOK command, potentially showinga  message to the player about not showing more detial, then instructs the game controller to process a new turn showing the long description
    public CommandOutcome Look()
    {
        // If it has not yet been shown three times, show the no more detail warning and increase the count of times shown
        if (DetailMsgCount < 3)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("15NoMoreDetail"));
            DetailMsgCount++;
        }

        LocViews[playerController.CurrentLocation] = 0;
        return(CommandOutcome.DESCRIBE);
    }
Пример #18
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // Note whether rug is here
        rugHere = playerController.ItemIsPresent(RUG);

        // Check whether a subject was identified
        string itemToFly = controller.GetSubject("fly");

        // If there was no subject but there's more to process, carry on processing
        if (itemToFly == null && (parserState.ContainsState(CommandState.NOT_PROCESSED) || parserState.ContainsState(CommandState.PENDING)))
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string         flyMsg;
        CommandOutcome outcome = CommandOutcome.MESSAGE;

        if (itemToFly == null)
        {
            // Trying to fly without a subject
            flyMsg = rugHere ? "224CantUseRug" : "225FlapArms";
        }
        else if (itemToFly == RUG)
        {
            // If rug is hovering...
            if (itemController.GetItemState(RUG) == 2)
            {
                // fly across chasm on rug
                string rugLoc = itemController.Where(RUG, LOCATION_POSITION.FIRST_LOCATION);
                playerController.GoTo(playerController.CurrentLocation == rugLoc ? itemController.Where(RUG, LOCATION_POSITION.SECOND_LOCATION) : rugLoc, false);

                flyMsg  = itemController.TreasureWasSeen("68Sapphire")  ? "227RugBack" : "226BoardRug";
                outcome = CommandOutcome.FULL;
            }
            else
            {
                // Rug won't fly
                flyMsg = "223RugUncooperative";
            }
        }
        else
        {
            // Trying to fly something other than the rug, so force defult message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(flyMsg));
        parserState.CommandComplete();
        return(outcome);
    }
Пример #19
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToDrink = controller.GetSubject("drink");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToDrink == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string drinkMsg;

        switch (itemToDrink)
        {
        case "44Blood":
            // Destroy the blood and change description of dragon to be sans blood
            itemController.DestroyItem("44Blood");
            itemController.SetItemState("31Dragon", 2);
            itemController.ChangeBirdSound();
            drinkMsg = "240HeadBuzz";
            break;

        case "21Water":
            // If the bottle is here and contains water, drink that
            if (playerController.ItemIsPresent("20Bottle") && itemController.GetItemState("20Bottle") == 0)
            {
                // Remove liquid from bottle
                itemController.SetItemState("20Bottle", 1);
                itemController.DestroyItem("21Water");
                drinkMsg = "74EmptyBottle";
            }
            else
            {
                // Otherwise, force the default message
                parserState.CurrentCommandState = CommandState.DISCARDED;
                return(CommandOutcome.NO_COMMAND);
            }
            break;

        default:
            drinkMsg = "110Ridiculous";
            break;
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(drinkMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #20
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // Check whether a subject was identified
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToBreak = controller.GetSubject("break");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToBreak == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        const string VASE = "58Vase";

        string         breakMsg;
        CommandOutcome outcome = CommandOutcome.MESSAGE;

        switch (itemToBreak)
        {
        case "23Mirror":
            if (gameController.CurrentCaveStatus == CaveStatus.CLOSED)
            {
                breakMsg = "197BreakMirror";
                outcome  = CommandOutcome.DISTURBED;
            }
            else
            {
                breakMsg = "148TooFarUp";
            }

            break;

        case VASE:
            breakMsg = "198DropVase";
            itemController.DropItemAt(VASE, playerController.CurrentLocation);
            itemController.SetItemState(VASE, 2);
            itemController.MakeItemImmovable(VASE);
            break;

        default:
            // Force default message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(breakMsg));
        parserState.CommandComplete();
        return(outcome);
    }
Пример #21
0
    public override CommandOutcome DoAction()
    {
        // If player tried to supply a subject, force default message
        if (controller.GetSubject("brief") != null)
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        // Acknowledge player's instruction and switch brief mode on
        textDisplayController.AddTextToLog(playerMessageController.GetMessage("156BeBrief"));
        locationController.SetBriefMode();
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
    // Process the response to a question
    public void GetQuestionResponse()
    {
        string response = playerInput.Words[0].activeWord.ToUpper();

        string questionID = CurrentQuestion;

        // If the player wants instructions, show them and give them a more generous battery life for the lamp
        if (response == "Y" || response == "YES")
        {
            if (questions[questionID].YesMessage != null)
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage(questions[CurrentQuestion].YesMessage));
            }

            ResetParams();
            questions[questionID].yesResponse?.Invoke();
            gameController.ResumeCommandProcessing();
        }
        // Otherwise give them the default battery life for the lamp
        else if (questions[questionID].AnyNonYesResponseForNo || response == "N" || response == "NO")
        {
            if (questions[questionID].NoMessage != null)
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage(questions[CurrentQuestion].NoMessage));
            }

            ResetParams();
            questions[questionID].noResponse?.Invoke();
            gameController.ResumeCommandProcessing();
        }
        // Learner has responded with something other than yes or no answer so prompt them and continue waiting
        else
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("185Answer"));
        }
    }
Пример #23
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToRub = controller.GetSubject("rub");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToRub == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string rubMsg;

        switch (itemToRub)
        {
        case "2Lantern":
            // Force default message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);

        case "42Urn":
            if (itemController.GetItemState("42Urn") == 2)
            {
                string location = playerController.CurrentLocation;
                itemController.DestroyItem("42Urn");
                itemController.DropItemAt("43Cavity", location);
                itemController.DropItemAt("67Amber", location);
                itemController.SetItemState("67Amber", 1);
                itemController.TallyTreasure("67Amber");
                rubMsg = "216UrnGenie";
            }
            else
            {
                goto default;
            }
            break;

        default:
            rubMsg = "76Peculiar";
            break;
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(rubMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #24
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToFind = controller.GetSubject("find");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToFind == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string location = playerController.CurrentLocation;
        string findMsg  = null;

        if (gameController.CurrentCaveStatus == CaveStatus.CLOSED)
        {
            findMsg = "138AroundSomewhere";
        }
        else if (playerController.HasItem(itemToFind))
        {
            findMsg = "24AlreadyHaveIt";
        }
        else
        {
            bool foundDwarf = itemToFind == "17Dwarf" && dwarfController.CountDwarvesAt(location) > 0;
            bool foundWater = itemToFind == "21Water" && ((itemController.GetItemState("20Bottle") == 0 && itemController.ItemIsAt("20Bottle", location)) || (locationController.LiquidAtLocation(location) == LiquidType.WATER));
            bool foundOil   = itemToFind == "22Oil" && ((itemController.GetItemState("20Bottle") == 2 && itemController.ItemIsAt("20Bottle", location)) || (locationController.LiquidAtLocation(location) == LiquidType.OIL));
            bool foundItem  = itemController.ItemIsAt(itemToFind, location);

            if (foundDwarf || foundWater || foundOil || foundItem)
            {
                findMsg = "94HaveWhatNeed";
            }
            else
            {
                // Show default message if nothing found
                parserState.CurrentCommandState = CommandState.DISCARDED;
                return(CommandOutcome.NO_COMMAND);
            }
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(findMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Пример #25
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // If there are no further commands to be processed, then force the default message
        if (!parserState.ContainsState(CommandState.NOT_PROCESSED))
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
        }
        else
        {
            // Otherwise - increment the go count and if it's been used 10 times, give the player a hint about not using it
            if (controller.IncrementGoCount() == 10)
            {
                textDisplayController.AddTextToLog(playerMessageController.GetMessage("276NoGo"));
            }
        }

        return(CommandOutcome.NO_COMMAND);
    }
Пример #26
0
    // === PUBLIC METHODS ===

    public override string GetLocation()
    {
        string locationID = playerController.CurrentLocation;
        int    numItems   = playerController.NumberOfItemsCarried;

        // If the player is not carrying anything (or only carrying the emerald), they can pass through the passage
        if (numItems == 0 || (numItems == 1 && playerController.HasItem("59Emerald")))
        {
            locationID = locationID == "99Alcove" ? "100PloverRoom" : "99Alcove";
        }
        else
        {
            // Otherwise tell them something they are carrying won't fit through the passage
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("117ObjectWontFit"));
        }

        return(locationID);
    }
Пример #27
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToEat = controller.GetSubject("eat");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToEat == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string eatMsg;

        switch (itemToEat)
        {
        case "19Food":
            itemController.DestroyItem("19Food");
            eatMsg = "72Delicious";
            break;

        case "8Bird":
        case "11Snake":
        case "14Clam":
        case "15Oyster":
        case "17Dwarf":
        case "31Dragon":
        case "33Troll":
        case "35Bear":
        case "41Ogre":
            eatMsg = "71LostAppetite";
            break;

        default:
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(eatMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
    private void FirstEncounter()
    {
        string location = playerController.CurrentLocation;

        // Determine if the player will encounter the first dwarf on this turn and return if not
        if (!(locationController.LocType(location) == LocationType.DEEP) || (Random.value < .95 && (!locationController.CanMoveBack(location) || Random.value < .85)))
        {
            return;
        }

        // Indicate player has met the first dwarf
        ActivationLevel = 2;

        // On first encountering the dwarves, randomly kill up to two of them (there's a 50% chance a dwarf will die - note it's possible the same dwarf could be killed twice - not a bug)
        for (int i = 0; i < 2; i++)
        {
            if (Random.value < .5)
            {
                KillDwarf(Random.Range(0, 4));
            }
        }

        // If any of the dwarves is at the player avatar's current location, move them to the alternative location
        for (int i = 0; i < NUM_DWARVES; i++)
        {
            if (Dwarves[i].DwarfLocation == location)
            {
                Dwarves[i].DwarfLocation = dwarfStartLocations[6];
                Dwarves[i].OldDwarfLocation = dwarfStartLocations[6];
            }
        }

        // Tell the player about the encounter
        textDisplayController.AddTextToLog(playerMessageController.GetMessage("3DwarfThrow"));

        // Drop the axe here
        itemController.DropItemAt("28Axe", location);
    }
Пример #29
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        // Check whether a subject was identified
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        string itemToWake = controller.GetSubject("wake");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToWake == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        if (itemToWake != "17Dwarf" || gameController.CurrentCaveStatus != CaveStatus.CLOSED)
        {
            // Force defult message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        // Player has woken the dwarves, ending the game
        textDisplayController.AddTextToLog(playerMessageController.GetMessage("199WakeDwarf"));
        parserState.CommandComplete();
        return(CommandOutcome.DISTURBED);
    }
Пример #30
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        location = playerController.CurrentLocation;

        // Check whether a subject was identified, or could be identified
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        itemToLight  = controller.GetSubject("on");

        // If no item could be identified then we're either done with this command or we need to continue processing to find a subject
        if (itemToLight == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string         onMsg   = null;
        CommandOutcome outcome = CommandOutcome.MESSAGE;

        switch (itemToLight)
        {
        case LAMP:
            if (gameController.LampLife < 0)
            {
                // Lamp is out of power
                onMsg = "184LampNoPower";
            }
            else
            {
                // Turn lamp on
                itemController.SetItemState(LAMP, 1);
                onMsg = "39LampOn";

                // If it had been dark, describe the location now there's light to see by
                if (gameController.WasDark)
                {
                    outcome = CommandOutcome.DESCRIBE;
                }
            }
            break;

        case URN:
            if (itemController.GetItemState(URN) == 0)
            {
                onMsg = "38UrnEmpty";
            }
            else
            {
                // Light the urn
                itemController.SetItemState(URN, 2);
                onMsg = "209UrnLit";
            }
            break;

        default:
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(onMsg));
        parserState.CommandComplete();
        return(outcome);
    }