コード例 #1
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);
    }
コード例 #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);
    }
コード例 #3
0
    // === PUBLIC METHODS ===

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

        // If a subject was provided, force the default message to be shown
        if (itemToCalm != null)
        {
            parserState.CurrentCommandState = CommandState.DISCARDED;
        }

        return(CommandOutcome.NO_COMMAND);
    }
コード例 #4
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);
    }
コード例 #5
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);
    }
コード例 #6
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);
    }
コード例 #7
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);
    }
コード例 #8
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);
    }
コード例 #9
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);
    }
コード例 #10
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);
    }
コード例 #11
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);
    }
コード例 #12
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);
    }
コード例 #13
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);
    }
コード例 #14
0
    // === PUBLIC METHODS ===

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

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

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

        outcome = CommandOutcome.MESSAGE;

        // Check for a condition that prevents us from processing the carry command further
        if (AlreadyHasItem() || CustomCarryResponse() || ItemNotMovable() || !ValidLiquidItem() || InventoryFull() || CantCatchBird())
        {
            return(outcome);
        }

        // Remove any negative item state (possibly set when cave closed)
        int itemState = itemController.GetItemState(itemToCarry);

        if (itemState < 0)
        {
            itemState = -1 - itemState;
            itemController.SetItemState(itemToCarry, itemState);
        }

        // Carry the item
        playerController.CarryItem(itemToCarry);

        // For certain objects, there's some tidying up to do
        switch (itemToCarry)
        {
        case "4Cage":
        case "8Bird":
            // If the player has carried the bird or cage and the bird is currently in the cage...
            if (itemState == 1)
            {
                // ... then carry the other item as well
                string otherItemToCarry = itemToCarry == "4Cage" ? "8Bird" : "4Cage";
                playerController.CarryItem(otherItemToCarry);
            }
            break;

        case "20Bottle":
            // If the player has carried the bottle, and the bottle has liquid in it...
            if (itemState == 0 || itemState == 2)
            {
                // ... then carry the relevant liquid as well
                string otherItemToCarry = itemState == 0 ? "21Water" : "22Oil";
                playerController.CarryItem(otherItemToCarry);
            }
            break;

        case "59Emerald":
        case "65Ruby":
        case "67Amber":
        case "68Sapphire":
            // If the player has carried a gemstone and the gemstone was in the cavity...
            if (itemState != 0)
            {
                //... then indicate the gemstone is no longer in the cavity and the cavity is now empty
                itemController.SetItemState(itemToCarry, 0);
                itemController.SetItemState("43Cavity", 1);
            }
            break;
        }

        // Mark the command as complete
        parserState.CommandComplete();

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

        return(outcome);
    }
コード例 #15
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);
    }
コード例 #16
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;
    }
コード例 #17
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);
    }
コード例 #18
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);
    }
コード例 #19
0
    // === PUBLIC METHODS ===

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

        noSubjectMsg  = new NoSubjectMsg("44NoAttack", null);
        carryOverVerb = false;

        // Check whether a subject was identified, or could be identified and return if not
        itemToAttack = controller.GetSubject("attack");

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

        attackText = null;
        CommandOutcome outcome = CommandOutcome.MESSAGE;

        switch (itemToAttack)
        {
        case BIRD:
            outcome = AttackBird();
            break;

        case VENDING:
            outcome = AttackVendingMachine();
            break;

        case CLAM:
        case OYSTER:
            attackText = playerMessageController.GetMessage("150StrongShell");
            break;

        case SNAKE:
            attackText = playerMessageController.GetMessage("46AttackSnake");
            break;

        case DWARF:
            outcome = AttackDwarf();
            break;

        case DRAGON:
            outcome = AttackDragon();
            break;

        case TROLL:
            attackText = playerMessageController.GetMessage("157TrollDefence");
            break;

        case OGRE:
            outcome = AttackOgre();
            break;

        case BEAR:
            outcome = AttackBear();
            break;

        default:
            // The identified object cannot be attacked, so display default message
            parserState.CurrentCommandState = CommandState.DISCARDED;
            return(CommandOutcome.NO_COMMAND);
        }

        if (attackText != null)
        {
            textDisplayController.AddTextToLog(attackText);
        }

        parserState.CommandComplete();
        return(outcome);
    }
コード例 #20
0
    // Check a range of primary and secondary targets if no explicit subject given
    public override string FindSubstituteSubject()
    {
        string subject      = null;
        int    subjectCount = 0;

        // These are all potential primary targets if no subject is given
        Substitute[] primarySubstitutes = new Substitute[]
        {
            new Substitute(SNAKE, false),
            new Substitute(DRAGON, true),
            new Substitute(TROLL, false),
            new Substitute(OGRE, false),
            new Substitute(BEAR, true)
        };

        // These are all potential secondary targets if no subject given and no primary target found
        Substitute[] secondarySubstitutes = new Substitute[]
        {
            new Substitute(BIRD, true),
            new Substitute(VENDING, true),
            new Substitute(CLAM, false),
            new Substitute(OYSTER, false)
        };

        // If there's at least one dwarf at this location, set the subject to dwarf
        if (dwarfController.CountDwarvesAt(location) > 0)
        {
            subject = DWARF;
            subjectCount++;
        }

        // Now check other enemies that might be here, that could be attacked
        foreach (Substitute enemy in primarySubstitutes)
        {
            if (itemController.ItemIsAt(enemy.item, location) && (!enemy.conditional || itemController.GetItemState(enemy.item) == 0))
            {
                subject = enemy.item;
                subjectCount++;
            }
        }

        // if no primary substitute was found...
        if (subjectCount == 0)
        {
            // Try the secondary substitutes
            foreach (Substitute target in secondarySubstitutes)
            {
                if (itemController.ItemIsAt(target.item, location) && (!target.conditional || parserState.ActiveCommand != "2017Throw"))
                {
                    subject = target.item;
                    subjectCount++;
                }
            }
        }

        // If we found more than one potential subject, then the subject is ambiguous so indicate no subject
        if (subjectCount > 1)
        {
            subject       = null;
            noSubjectMsg  = new NoSubjectMsg("257VerbWhat", parserState.Words);
            carryOverVerb = true;
        }

        return(subject);
    }
コード例 #21
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);
    }