// 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);
    }
Esempio n. 2
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);
    }
Esempio n. 3
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);
        }
    }
Esempio n. 4
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);
    }
Esempio n. 5
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);
    }
    // === 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);
    }
Esempio n. 7
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);
    }
Esempio n. 8
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);
    }
Esempio n. 9
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);
    }
Esempio n. 10
0
    // === PUBLIC METHODS ===

    // Executes the handler for the given action command
    public CommandOutcome ExecuteAction(string actionID)
    {
        if (actions.ContainsKey(actionID))
        {
            return(actions[actionID].DoAction());
        }
        else
        {
            parserState.CommandComplete();
            Debug.LogErrorFormat("ActionController.DoAction was passed an unknown action ID: \"{0}\"", actionID);
            return(CommandOutcome.NO_COMMAND);
        }
    }
Esempio n. 11
0
    // === PUBLIC METHODS ===

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

        scoreController.DisplayScore(ScoreMode.INTERIM);
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Esempio n. 12
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);
    }
Esempio n. 13
0
    public override CommandOutcome DoAction()
    {
        // If player tried to use a second word, force default message
        if (parserState.GetOtherWordText() != null)
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        // Ask for confirmation before quitting
        parserState.CommandComplete();
        questionController.RequestQuestionResponse("quit");
        return(CommandOutcome.QUESTION);
    }
Esempio n. 14
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);
    }
Esempio n. 15
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);
    }
Esempio n. 16
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);
    }
Esempio n. 17
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);
    }
Esempio n. 18
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);
    }
Esempio n. 19
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);
    }
Esempio n. 20
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);
    }
Esempio n. 21
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);
    }
Esempio n. 22
0
    // === PUBLIC METHODS ===

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

        // 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 (itemToFill == null)
        {
            return CommandOutcome.NO_COMMAND;
        }

        string location = playerController.CurrentLocation;
        string fillMsg;
        int bottleState = itemController.GetItemState("20Bottle");
        LiquidType liquidAtLocation = locationController.LiquidAtLocation(location);

        switch (itemToFill)
        {
            case "58Vase":
                if (!playerController.HasItem("58Vase"))
                {
                    fillMsg = "29DontHaveIt";
                }
                else if (liquidAtLocation == LiquidType.NONE && !(playerController.HasItem("21Water") || playerController.HasItem("22Oil")))
                {
                    fillMsg = "144NoLiquid";
                }
                else
                {
                    // Vase breaks when filled with liquid
                    itemController.SetItemState("58Vase", 2);
                    itemController.MakeItemImmovable("58Vase");
                    itemController.DropItemAt("58Vase", location);
                    fillMsg = "145TemperatureVase";
                }
                break;
            case "42Urn":
                if (itemController.GetItemState("42Urn") != 0)
                {
                    fillMsg = "213UrnFullOil";
                }
                else
                {
                    // If the bottle is available and it contains a liquid...
                    if (playerController.ItemIsPresent("20Bottle") && bottleState != 1)
                    {
                        string liquidType = bottleState == 0 ? "21Water" : "22Oil";

                        // Empty the bottle
                        itemController.DestroyItem(liquidType);
                        itemController.SetItemState("20Bottle", 1);

                        if (liquidType == "21Water")
                        {
                            // Water gets squirted back
                            fillMsg = "211UrnSquirt";
                        }
                        else 
                        {
                            // Oil stys in the urn
                            itemController.SetItemState("42Urn", 1);
                            fillMsg = "212BottleOilToUrn";
                        }
                    }
                    else
                    {
                        // No liquid here to fill urn with
                        fillMsg = "144NoLiquid";
                    }
                }
                break;
            case "20Bottle":
                // bottle not empty
                if (bottleState != 1)
                {
                    fillMsg = "105BottleFull";
                }
                else if (liquidAtLocation != LiquidType.NONE)
                {
                    bool isWater = liquidAtLocation == LiquidType.WATER;
                    itemController.SetItemState("20Bottle", isWater ? 0 : 2);
                    playerController.CarryItem(isWater ? "21Water" : "22Oil");
                    fillMsg = isWater ? "107BottleWater" : "108BottleOil";
                }
                else if (itemController.ItemIsAt("42Urn", location) && itemController.GetItemState("42Urn") != 0)
                {
                    fillMsg = "214NoOilFromUrn";
                }
                else
                {
                    fillMsg = "106NoFill";
                }
                break;
            default:
                // Force default message
                parserState.CurrentCommandState = CommandState.DISCARDED;
                return CommandOutcome.NO_COMMAND;
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(fillMsg));
        parserState.CommandComplete();
        return CommandOutcome.MESSAGE;
    }
Esempio n. 23
0
    // ==== PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        location = playerController.CurrentLocation;
        locking  = parserState.ActiveCommand == "2006Lock";

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

        // 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 (itemToLockOrUnlock == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        string lockUnlockMsg = null;

        // Process the item being locked or unlocked and generate a suitable message
        switch (itemToLockOrUnlock)
        {
        case "14Clam":
        case "15Oyster":
            lockUnlockMsg = ClamOyster();
            break;

        case "9RustyDoor":
            lockUnlockMsg = itemController.GetItemState("9RustyDoor") == 1 ? "54OK" : "111RustyDoor";
            break;

        case "4Cage":
            lockUnlockMsg = "32NoLock";
            break;

        case "1Keys":
            lockUnlockMsg = "55NoUnlockKeys";
            break;

        case "3Grate":
        case "64Chain":
            lockUnlockMsg = "31NoKeys";
            if (playerController.ItemIsPresent("1Keys"))
            {
                if (itemToLockOrUnlock == "3Grate")
                {
                    lockUnlockMsg = Grate();
                }
                else
                {
                    lockUnlockMsg = Chain();
                }
            }
            break;

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

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(lockUnlockMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Esempio n. 24
0
    // === PUBLIC METHODS ===

    public override CommandOutcome DoAction()
    {
        location = playerController.CurrentLocation;        // Get player's current location

        // Attempt to get an item to throw
        noSubjectMsg = new NoSubjectMsg("257VerbWhat", parserState.Words);
        itemToThrow  = controller.GetSubject("throw");

        // 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 (itemToThrow == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        // If subject is real rod, but player only carrying phony rod, then set phony rod as subject
        if (itemToThrow == "5BlackRod" && !playerController.HasItem("5BlackRod") && playerController.HasItem("6BlackRod"))
        {
            itemToThrow = "6BlackRod";
        }

        // If player is not holding the object, show default message
        if (!playerController.HasItem(itemToThrow))
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        string throwMsg = null;           // Will hold the message to be shown to the player as a result of the command

        outcome = CommandOutcome.MESSAGE; // In most cases, outcome will be message (will be updated if not)

        // If at troll bridge and throwing a treasure, it is assumed to be a toll to cross
        if (itemController.IsTreasure(itemToThrow) && itemController.ItemIsAt("33Troll", location))
        {
            throwMsg = ThrowTreasureToTroll();
        }
        // If throwing food in the presence of the bear...
        else if (itemToThrow == "19Food" && itemController.ItemIsAt("35Bear", location))
        {
            // ... construct a feed command with the bear as subject and execute that instead
            CommandWord feedCommand = new CommandWord("FEED", null);
            CommandWord itemCommand = new CommandWord("BEAR", null);
            parserState.ResetParserState(new CommandWord[2] {
                feedCommand, itemCommand
            });
            return(CommandOutcome.NO_COMMAND);
        }
        // Throwing the axe
        else if (itemToThrow == "28Axe")
        {
            throwMsg = ThrowAxe();
        }
        // In all other circumstances...
        else
        {
            // ...execute a drop command instead
            return(controller.ExecuteAction("drop"));
        }

        if (throwMsg != null)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage(throwMsg));
        }

        parserState.CommandComplete();
        return(outcome);
    }
Esempio n. 25
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);
        itemToWave   = controller.GetSubject("wave");

        // 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 (itemToWave == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        List <string> waveMsg   = new List <string>();
        bool          hasItem   = playerController.HasItem(itemToWave);
        bool          isRod     = itemToWave == "5BlackRod";
        bool          birdHere  = playerController.ItemIsPresent("8Bird");
        bool          atFissure = location == "17EastFissure" || location == "27WestFissure";
        bool          closing   = gameController.CurrentCaveStatus == CaveStatus.CLOSING;

        if (!hasItem && (!isRod || !playerController.HasItem("6BlackRod")))
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage("29DontHaveIt"));
            parserState.CommandComplete();
            return(CommandOutcome.MESSAGE);
        }

        // Wave will have no effect in these circumstances
        if (!isRod || !hasItem || (!birdHere && (closing || !atFissure)))
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        CommandOutcome outcome = CommandOutcome.MESSAGE;

        // If the bird is here...
        if (birdHere)
        {
            switch (itemController.GetItemState("8Bird") % 2)
            {
            // ... and bird is uncaged...
            case 0:
                // ... if at steps and jade necklace not yet found...
                if (location == "14TopOfPit" && !itemController.ItemInPlay("66Necklace"))
                {
                    // ... bird retrieves jade necklace...
                    itemController.DropItemAt("66Necklace", location);
                    // Tally a treasure
                    itemController.TallyTreasure("66Necklace");
                    waveMsg.Add(playerMessageController.GetMessage("208BirdRetrieveNecklace"));
                }
                else
                {
                    // ... otherwise bird just got agitated
                    waveMsg.Add(playerMessageController.GetMessage("206BirdAgitated"));
                }
                break;

            case 1:
                // ... bird got agitated in cage
                waveMsg.Add(playerMessageController.GetMessage("207BirdAgitatedCage"));
                break;
            }

            // If cave is closed, this action will wake the dwarves
            if (gameController.CurrentCaveStatus == CaveStatus.CLOSED)
            {
                outcome = CommandOutcome.DISTURBED;
            }
        }

        // If we're at the fissure and it's not closing
        if (atFissure && !closing)
        {
            //Toggle crystal bridge state and show appropriate message
            int fissureState = itemController.GetItemState("12Fissure");
            itemController.SetItemState("12Fissure", fissureState + 1);
            waveMsg.Add(itemController.DescribeItem("12Fissure"));
            itemController.SetItemState("12Fissure", 1 - fissureState);
        }

        // Show any messages generated and end this command
        for (int i = 0; i < waveMsg.Count; i++)
        {
            if (waveMsg[i] != null)
            {
                textDisplayController.AddTextToLog(waveMsg[i]);
            }
        }

        parserState.CommandComplete();
        return(outcome);
    }
Esempio n. 26
0
    // === PUBLIC METHODS ===

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

        // Determine the liquid in the botttle, if any
        liquidInBottle = null;

        switch (itemController.GetItemState(BOTTLE))
        {
        case 0:
            liquidInBottle = WATER;
            break;

        case 2:
            liquidInBottle = OIL;
            break;
        }

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

        // 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 (itemToPour == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        // If the item to pour is the bottle, substitute the liquid, if any
        if (itemToPour == BOTTLE && liquidInBottle != null)
        {
            itemToPour = liquidInBottle;
        }

        // If player doesn't have the object, show the default message
        if (!playerController.HasItem(itemToPour))
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

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

        // If the item being poured is not oil or water, object
        if (itemToPour != WATER && itemToPour != OIL)
        {
            pourMsg = "78NoPour";
        }
        else
        {
            // If the urn is here and empty - create a new command to fill the urn and execute that instead
            if (itemController.ItemIsAt("42Urn", location))
            {
                CommandWord fillCommand = new CommandWord("FILL", null);
                CommandWord urnCommand  = new CommandWord("URN", null);
                parserState.ResetParserState(new CommandWord[2] {
                    fillCommand, urnCommand
                });
                return(CommandOutcome.NO_COMMAND);
            }
            else
            {
                // Set the bottle to empty and destroy the liquid
                itemController.SetItemState(BOTTLE, 1);
                itemController.DestroyItem(itemToPour);

                // Check for special actions at the rusty door
                if (itemController.ItemIsAt(DOOR, location))
                {
                    if (itemToPour == OIL)
                    {
                        // If oil used, hinges are lubricated
                        itemController.SetItemState(DOOR, 1);
                        pourMsg = "114OiledHinges";
                    }
                    else
                    {
                        // Water is used, so hinges are rusted up
                        itemController.SetItemState(DOOR, 0);
                        pourMsg = "113RustyHinges";
                    }
                }
                // Check for special actions at plant
                else if (itemController.ItemIsAt(PLANT, location))
                {
                    if (itemToPour == WATER)
                    {
                        int plantState = itemController.GetItemState(PLANT);

                        // Describe what happens to plant
                        itemController.SetItemState(PLANT, plantState + 3);
                        textDisplayController.AddTextToLog(itemController.DescribeItem(PLANT));

                        // Set a new stable state for the plant and the phony plant
                        plantState = (plantState + 1) % 3;
                        itemController.SetItemState(PLANT, plantState);
                        itemController.SetItemState("25PhonyPlant", plantState);

                        // Force location to be redescribed
                        outcome = CommandOutcome.FULL;
                    }
                    else
                    {
                        // Player has watered plant with oil
                        pourMsg = "112PlantOil";
                    }
                }
                else
                {
                    // The player has emptied the bottle onto the ground
                    pourMsg = "77PourGround";
                }
            }
        }

        if (pourMsg != null)
        {
            textDisplayController.AddTextToLog(playerMessageController.GetMessage(pourMsg));
        }
        parserState.CommandComplete();
        return(outcome);
    }
Esempio n. 27
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);
    }
Esempio n. 28
0
    // === PUBLIC METHODS ===

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

        // 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 (itemToFeed == null)
        {
            return(CommandOutcome.NO_COMMAND);
        }

        // Assume trying to feed one of the monsters (will be replaced if not appropriate)
        string feedMsg = "102NothingToEat";

        bool foodHere = playerController.ItemIsPresent("19Food");

        switch (itemToFeed)
        {
        case "8Bird":
            feedMsg = "100MontyBird";
            break;

        case "11Snake":
            // If the bird is here and the cave is not closed, the snake eats the bird
            if (!(gameController.CurrentCaveStatus == CaveStatus.CLOSED) && playerController.ItemIsPresent("8Bird"))
            {
                feedMsg = "101SnakeAteBird";
                itemController.SetItemState("8Bird", 0);
                itemController.DestroyItem("8Bird");
            }
            break;

        case "31Dragon":
            // Trying to feed the dragon's corpse
            if (itemController.GetItemState("31Dragon") != 0)
            {
                feedMsg = "110Ridiculous";
            }
            break;

        case "33Troll":
            feedMsg = "182TrollSins";
            break;

        case "17Dwarf":
            // If trying to feed food to dwarf...
            if (foodHere)
            {
                // ... gets really mad (two increases to activation level)
                feedMsg = "103MadDwarf";
                dwarfController.IncreaseActivationLevel();
                dwarfController.IncreaseActivationLevel();
            }
            else
            {
                // Force default message
                parserState.CurrentCommandState = CommandState.DISCARDED;
                return(CommandOutcome.NO_COMMAND);
            }
            break;

        case "35Bear":

            int bearState = itemController.GetItemState("35Bear");

            if (foodHere)
            {
                itemController.DestroyItem("19Food");
                itemController.SetItemState("35Bear", 1);

                // Ensure axe is now accessible
                itemController.MakeItemMovable("28Axe");
                itemController.SetItemState("28Axe", 0);
                feedMsg = "168BearFood";
            }
            else if (bearState == 3)
            {
                // Trying to feed dead bear
                feedMsg = "110Ridiculous";
            }
            break;

        case "41Ogre":
            if (foodHere)
            {
                feedMsg = "202OgreNotHungry";
            }
            break;

        default:
            feedMsg = "14Explain";
            break;
        }

        textDisplayController.AddTextToLog(playerMessageController.GetMessage(feedMsg));
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
Esempio n. 29
0
    // === PUBLIC METHODS ===

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

        // Create a new list for sounds that can be heard here
        List <string> soundTexts = new List <string>();
        LocationSound locSound   = locationController.SoundAtLocation(playerController.CurrentLocation);

        // Add the location sound if there is one
        if (locSound.soundMessage != null && locSound.soundMessage != "")
        {
            soundTexts.Add(locSound.soundMessage);
        }

        // If the location sound doesn't drown out other sounds...
        if (!locSound.drownsOutOtherSounds)
        {
            // Get all the items currently carried or at player's location
            List <string> itemsHere = playerController.PresentItems();

            // Search the items...
            foreach (string item in itemsHere)
            {
                // .. for any that can be heard
                if (itemController.ItemCanBeHeard(item))
                {
                    string soundText = itemController.ListenToItem(item);

                    // If the bird is singing about its freedom in the forest, we need to add magic word and the bird disappears forever
                    if (item == BIRD && soundText.Contains("~"))
                    {
                        soundText = playerMessageController.AssembleTextWithParams(soundText, new string[] { commandsController.MagicWordText });
                        itemController.DestroyItem(BIRD);
                    }

                    soundTexts.Add(soundText);
                }
            }
        }

        // If there were no sounds, add the silence message
        if (soundTexts.Count == 0)
        {
            soundTexts.Add(playerMessageController.GetMessage("228Silent"));
        }

        // Display all the sounds that can be heard here
        string outString = "";

        for (var i = 0; i < soundTexts.Count; i++)
        {
            if (i > 0)
            {
                outString += "\n";
            }

            outString += soundTexts[i];
        }

        textDisplayController.AddTextToLog(outString);
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }
    public override CommandOutcome DoAction()
    {
        // If player tried to use a second word, force default message
        string[] otherword = parserState.GetOtherWordText();

        if (otherword != null && otherword[0].ToUpper() != "SAY")
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        int nextWord = controller.Foobar;

        // Assume that nothing will happen
        string fooText = playerMessageController.GetMessage("42NothingHappens");

        // Player has used the next word in the sequence
        if (parserState.Words[0].ToUpper() == wordOrder[nextWord])
        {
            // Advance to the next word
            controller.IncrementFoobar();

            // If we're done...
            if (controller.Foobar == wordOrder.Length)
            {
                string eggs  = "56Eggs";
                string troll = "33Troll";

                controller.ResetFoobar();

                bool playerAtInitialEggLocation = itemController.IsInitialLocation(eggs, playerController.CurrentLocation, LOCATION_POSITION.FIRST_LOCATION);

                // If the eggs are currently in their initial location or the player is carrying them, but is currently at their initial location, then nothing happens
                if (!itemController.AtInitalLocation(eggs) && !(playerController.HasItem(eggs) && playerAtInitialEggLocation))
                {
                    // Bring back the troll if we're trying to steal back the eggs after using them to pay for a crossing
                    if (!itemController.ItemInPlay(eggs) && !itemController.ItemInPlay(troll) && itemController.GetItemState(troll) == 0)
                    {
                        itemController.SetItemState(troll, 1);
                    }

                    // Transport the eggs back to the giant room
                    int eggMsgState;

                    if (playerAtInitialEggLocation)
                    {
                        eggMsgState = 0;
                    }
                    else if (playerController.ItemIsPresent(eggs))
                    {
                        eggMsgState = 1;
                    }
                    else
                    {
                        eggMsgState = 2;
                    }

                    itemController.ResetItem(eggs);
                    itemController.SetItemState(eggs, eggMsgState);
                    fooText = itemController.DescribeItem(eggs);
                    itemController.SetItemState(eggs, 0);
                }
            }
            else
            {
                // Player has correctly said the next word in the sequence, but we're not at the end yet...
                fooText = playerMessageController.GetMessage("54OK");
            }
        }
        else
        {
            // Player has said a word out of sequence. If mid-sequence, we need to reset and should give the player a hint.
            if (controller.Foobar != 0)
            {
                fooText = playerMessageController.GetMessage("151StartOver");
                controller.ResetFoobar();
            }
        }

        textDisplayController.AddTextToLog(fooText);
        parserState.CommandComplete();
        return(CommandOutcome.MESSAGE);
    }