Exemple #1
0
        public string Run(string nextLine)
        {
            string output = Environment.NewLine;

            if (!this.State.Initialized)
            {
                initplay(this.State);

                this.State.Initialized = true;
                output += Database.rspeak(65);
                output += Database.rspeak(1);
            }

            string result = (string.IsNullOrWhiteSpace(output) ? string.Empty : output + Environment.NewLine) + Turn.turn(this.State, nextLine);

            return(string.IsNullOrWhiteSpace(result) ?  $"Sorry, I didn't quite get that. You said: {Convert.ToBase64String(Encoding.UTF8.GetBytes(nextLine))} in base64." : result);
        }
        void DefineAllTurns()
        {
            Turn stageOne = new Turn();

            stageOne.EnemiesToSpawn.Add(AllEnemies[0]);
            stageOne.EnemieSpawnPoints.Add(new Point(324, 94));

            stageOne.Player           = Player;
            stageOne.PlayerStartPoint = new Point(74, 144);

            Turn stageTwo = new Turn();

            stageTwo.EnemiesToSpawn.Add(AllEnemies[1]);
            stageTwo.EnemieSpawnPoints.Add(new Point(324, 94));

            stageTwo.Player           = Player;
            stageTwo.PlayerStartPoint = new Point(74, 144);

            Turn stageThree = new Turn();

            stageThree.EnemiesToSpawn.Add(AllEnemies[2]);
            stageThree.EnemieSpawnPoints.Add(new Point(324, 94));

            stageThree.Player           = Player;
            stageThree.PlayerStartPoint = new Point(74, 144);

            Turn stageFour = new Turn();

            stageFour.EnemiesToSpawn.Add(AllEnemies[0]);
            stageFour.EnemieSpawnPoints.Add(new Point(324, 94));
            stageFour.EnemiesToSpawn.Add(AllEnemies[1]);
            stageFour.EnemieSpawnPoints.Add(new Point(324, 144));

            stageFour.Player           = Player;
            stageFour.PlayerStartPoint = new Point(74, 144);

            Turn stageFive = new Turn();

            stageFive.EnemiesToSpawn.Add(AllEnemies[0]);
            stageFive.EnemieSpawnPoints.Add(new Point(324, 94));
            stageFive.EnemiesToSpawn.Add(AllEnemies[2]);
            stageFive.EnemieSpawnPoints.Add(new Point(324, 144));

            stageFive.Player           = Player;
            stageFive.PlayerStartPoint = new Point(74, 144);

            Turn stageSix = new Turn();

            stageSix.EnemiesToSpawn.Add(AllEnemies[1]);
            stageSix.EnemieSpawnPoints.Add(new Point(324, 94));
            stageSix.EnemiesToSpawn.Add(AllEnemies[2]);
            stageSix.EnemieSpawnPoints.Add(new Point(324, 144));

            stageSix.Player           = Player;
            stageSix.PlayerStartPoint = new Point(74, 144);

            Turn stageSeven = new Turn();

            stageSeven.EnemiesToSpawn.Add(AllEnemies[0]);
            stageSeven.EnemieSpawnPoints.Add(new Point(324, 94));
            stageSeven.EnemiesToSpawn.Add(AllEnemies[1]);
            stageSeven.EnemieSpawnPoints.Add(new Point(324, 144));
            stageSeven.EnemiesToSpawn.Add(AllEnemies[2]);
            stageSeven.EnemieSpawnPoints.Add(new Point(274, 144));

            stageSeven.Player           = Player;
            stageSeven.PlayerStartPoint = new Point(74, 144);

            DefinedTurns.Add(stageOne);
            DefinedTurns.Add(stageTwo);
            DefinedTurns.Add(stageThree);
            DefinedTurns.Add(stageFour);
            DefinedTurns.Add(stageFive);
            DefinedTurns.Add(stageSix);
            DefinedTurns.Add(stageSeven);
        }
Exemple #3
0
        /*
         *  THROW etc.
         */
        public static string vthrow(State globals)
        {
            int msg;
            int i;

            if (Database.toting(globals, Definitions.ROD2) && globals.@object == Definitions.ROD && !Database.toting(globals, Definitions.ROD))
            {
                globals.@object = Definitions.ROD2;
            }
            if (!Database.toting(globals, globals.@object))
            {
                return(actspk(globals.verb));
            }

            /*
             * treasure to troll
             */
            if (Database.at(globals, Definitions.TROLL) && globals.@object >= 50 && globals.@object < Definitions.MAXOBJ)
            {
                Database.drop(globals, globals.@object, 0);
                Database.move(globals, Definitions.TROLL, 0);
                Database.move(globals, (Definitions.TROLL + Definitions.MAXOBJ), 0);
                Database.drop(globals, Definitions.TROLL2, 117);
                Database.drop(globals, (Definitions.TROLL2 + Definitions.MAXOBJ), 122);
                Database.juggle(Definitions.CHASM);
                return(Database.rspeak(159));
            }

            /*
             * feed the bears...
             */
            if (globals.@object == Definitions.FOOD && Database.here(globals, Definitions.BEAR))
            {
                globals.@object = Definitions.BEAR;
                return(vfeed(globals));
            }

            /*
             * if not axe, same as drop...
             */
            if (globals.@object != Definitions.AXE)
            {
                return(vdrop(globals));
            }

            /*
             * AXE is THROWN
             */
            /*
             * at a dwarf...
             */
            if ((i = Database.dcheck(globals)) > 0)
            {
                msg = 48;
                if (Database.pct(33))
                {
                    globals.dseen[i] = false;
                    globals.dloc[i]  = 0;
                    msg = 47;
                    ++globals.dkill;
                    if (globals.dkill == 1)
                    {
                        msg = 149;
                    }
                }
            }

            /*
             * at a dragon...
             */
            else if (Database.at(globals, Definitions.DRAGON) && globals.prop[Definitions.DRAGON] == 0)
            {
                msg = 152;
            }

            /*
             * at the troll...
             */
            else if (Database.at(globals, Definitions.TROLL))
            {
                msg = 158;
            }

            /*
             * at the bear...
             */
            else if (Database.here(globals, Definitions.BEAR) && globals.prop[Definitions.BEAR] == 0)
            {
                Database.drop(globals, Definitions.AXE, globals.loc);
                globals.@fixed[Definitions.AXE] = -1;
                globals.prop[Definitions.AXE]   = 1;
                Database.juggle(Definitions.BEAR);
                return(Database.rspeak(164));
            }

            /*
             * otherwise it is an attack
             */
            else
            {
                globals.verb    = Definitions.KILL;
                globals.@object = 0;
                return(itverb(globals));
            }

            /*
             * handle the left over axe...
             */
            string output = Database.rspeak(msg);

            Database.drop(globals, Definitions.AXE, globals.loc);
            return(Environment.NewLine + Turn.describe(globals));
        }
Exemple #4
0
        /*
         *  ATTACK, KILL etc.
         */
        public static string vkill(State globals)
        {
            string output = string.Empty;
            int    msg    = 0;
            int    i;

            switch (globals.@object)
            {
            case Definitions.BIRD:
                if (globals.closed)
                {
                    msg = 137;
                }
                else
                {
                    Database.dstroy(globals, Definitions.BIRD);
                    globals.prop[Definitions.BIRD] = 0;
                    if (globals.place[Definitions.SNAKE] == 19)
                    {
                        ++globals.tally2;
                    }
                    msg = 45;
                }
                break;

            case 0:
                msg = 44;
                break;

            case Definitions.CLAM:
            case Definitions.OYSTER:
                msg = 150;
                break;

            case Definitions.SNAKE:
                msg = 46;
                break;

            case Definitions.DWARF:
                if (globals.closed)
                {
                    output += Turn.dwarfend(globals);
                }
                msg = 49;
                break;

            case Definitions.TROLL:
                msg = 157;
                break;

            case Definitions.BEAR:
                msg = 165 + (globals.prop[Definitions.BEAR] + 1) / 2;
                break;

            case Definitions.DRAGON:
                if (globals.prop[Definitions.DRAGON] != 0)
                {
                    msg = 167;
                    break;
                }
                output += Database.rspeak(49);
                output += Environment.NewLine + Database.pspeak(Definitions.DRAGON, 1);
                globals.prop[Definitions.DRAGON] = 2;
                globals.prop[Definitions.RUG]    = 0;
                Database.move(globals, (Definitions.DRAGON + Definitions.MAXOBJ), -1);
                Database.move(globals, (Definitions.RUG + Definitions.MAXOBJ), 0);
                Database.move(globals, Definitions.DRAGON, 120);
                Database.move(globals, Definitions.RUG, 120);
                for (i = 1; i < Definitions.MAXOBJ; ++i)
                {
                    if (globals.place[i] == 119 || globals.place[i] == 121)
                    {
                        Database.move(globals, i, 120);
                    }
                }
                globals.newloc = 120;
                return(output);

            default:
                output += actspk(globals.verb);
                return(output);
            }

            output += Database.rspeak(msg);
            return(output);
        }
Exemple #5
0
        /*
         *  DROP etc.
         */
        public static string vdrop(State globals)
        {
            int    i;
            string output = string.Empty;

            /*
             * check for dynamite
             */
            if (Database.toting(globals, Definitions.ROD2) && globals.@object == Definitions.ROD && !Database.toting(globals, Definitions.ROD))
            {
                globals.@object = Definitions.ROD2;
            }
            if (!Database.toting(globals, globals.@object))
            {
                return(actspk(globals.verb));
            }

            /*
             * snake and bird
             */
            if (globals.@object == Definitions.BIRD && Database.here(globals, Definitions.SNAKE))
            {
                output += Database.rspeak(30);
                if (globals.closed)
                {
                    output += Turn.dwarfend(globals);
                }
                Database.dstroy(globals, Definitions.SNAKE);
                globals.prop[Definitions.SNAKE] = -1;
            }

            /*
             * coins and vending machine
             */
            else if (globals.@object == Definitions.COINS && Database.here(globals, Definitions.VEND))
            {
                Database.dstroy(globals, Definitions.COINS);
                Database.drop(globals, Definitions.BATTERIES, globals.loc);
                output += Database.pspeak(Definitions.BATTERIES, 0);
                return(output);
            }

            /*
             * bird and dragon (ouch!!)
             */
            else if (globals.@object == Definitions.BIRD && Database.at(globals, Definitions.DRAGON) && globals.prop[Definitions.DRAGON] == 0)
            {
                output += Database.rspeak(154);
                Database.dstroy(globals, Definitions.BIRD);
                globals.prop[Definitions.BIRD] = 0;
                if (globals.place[Definitions.SNAKE] != 0)
                {
                    ++globals.tally2;
                }
                return(output);
            }

            /*
             * Bear and troll
             */
            if (globals.@object == Definitions.BEAR && Database.at(globals, Definitions.TROLL))
            {
                output += Database.rspeak(163);
                Database.move(globals, Definitions.TROLL, 0);
                Database.move(globals, (Definitions.TROLL + Definitions.MAXOBJ), 0);
                Database.move(globals, Definitions.TROLL2, 117);
                Database.move(globals, (Definitions.TROLL2 + Definitions.MAXOBJ), 122);
                Database.juggle(Definitions.CHASM);
                globals.prop[Definitions.TROLL] = 2;
            }

            /*
             * vase
             */
            else if (globals.@object == Definitions.VASE)
            {
                if (globals.loc == 96)
                {
                    output += Database.rspeak(54);
                }
                else
                {
                    globals.prop[Definitions.VASE] = Database.at(globals, Definitions.PILLOW) ? 0 : 2;
                    Database.pspeak(Definitions.VASE, globals.prop[Definitions.VASE] + 1);
                    if (globals.prop[Definitions.VASE] != 0)
                    {
                        globals.@fixed[Definitions.VASE] = -1;
                    }
                }
            }

            /*
             * handle liquid and bottle
             */
            i = Database.liq(globals);
            if (i == globals.@object)
            {
                globals.@object = Definitions.BOTTLE;
            }
            if (globals.@object == Definitions.BOTTLE && i != 0)
            {
                globals.place[i] = 0;
            }

            /*
             * handle bird and cage
             */
            if (globals.@object == Definitions.CAGE && globals.prop[Definitions.BIRD] != 0)
            {
                Database.drop(globals, Definitions.BIRD, globals.loc);
            }
            if (globals.@object == Definitions.BIRD)
            {
                globals.prop[Definitions.BIRD] = 0;
            }
            Database.drop(globals, globals.@object, globals.loc);

            return(output);
        }
Exemple #6
0
        /*
         *  Routines to process intransitive verbs
         */
        public static string itverb(State globals)
        {
            switch (globals.verb)
            {
            case Definitions.DROP:
            case Definitions.SAY:
            case Definitions.WAVE:
            case Definitions.CALM:
            case Definitions.RUB:
            case Definitions.THROW:
            case Definitions.FIND:
            case Definitions.FEED:
            case Definitions.BREAK:
            case Definitions.WAKE:
                return(needobj(globals));

            case Definitions.TAKE:
                return(ivtake(globals));

            case Definitions.OPEN:
            case Definitions.LOCK:
                return(ivopen(globals));

            case Definitions.NOTHING:
                return(Database.rspeak(54));

            case Definitions.ON:
            case Definitions.OFF:
            case Definitions.POUR:
                return(trverb(globals));

            case Definitions.WALK:
                return(actspk(globals.verb));

            case Definitions.KILL:
                return(ivkill(globals));

            case Definitions.EAT:
                return(iveat(globals));

            case Definitions.DRINK:
                return(ivdrink(globals));

            case Definitions.QUIT:
                return(Turn.normend(globals));

            case Definitions.FILL:
                return(ivfill(globals));

            case Definitions.BLAST:
                return(vblast(globals));

            case Definitions.SCORE:
                return(Turn.score(globals));

            case Definitions.FOO:
                return(ivfoo(globals));

            case Definitions.INVENTORY:
                return(inventory(globals));

            default:
                return("This intransitive not implemented yet\n");
            }
        }