Exemple #1
0
        private void recipe(object drop, List <string> ingredientNames)
        {
            List <string> produces;
            var           ingredients   = ItemTypeFactory.Instance.ToItemType(ingredientNames);
            Drop          processedDrop = null;

            if (drop is string)
            {
                produces = new List <string> {
                    $"Produces: {(string) drop}"
                };
                processedDrop = DropFactory.parseDrop((string)drop);
            }
            else
            {
                produces = new List <string>
                {
                    "May create a random piece of equipment similar to",
                    "the placed item. Add coins to improve the quality",
                    "and chance of a successful forging."
                };
                processedDrop = drop as Drop;
            }
            Recipes.Add(new Recipe(ingredients, processedDrop, produces));
        }
Exemple #2
0
        private Breed breed(string name, string foreColour, int maxHealth, List <object> actions,
                            object drop = null, int?tracking = null, int meander = 0, int speed = 0, string flags = null  // All optional
                            )
        {
            if (tracking == null)
            {
                tracking = _tracking;
            }

            var attacks = new List <Attack>();
            var moves   = new List <Move>();

            foreach (var action in actions)
            {
                if (action is Attack)
                {
                    attacks.Add(action as Attack);
                }
                if (action is Move)
                {
                    moves.Add(action as Move);
                }
            }

            Drop processedDrop = null;

            if (drop is List <Drop> )
            {
                processedDrop = DropFactory.dropAllOf(drop as List <Drop>);
            }
            else if (drop is Drop)
            {
                processedDrop = DropFactory.dropAllOf(new List <Drop>()
                {
                    drop as Drop
                });
            }
            else if (drop is String)
            {
                processedDrop = DropFactory.parseDrop(drop as string);
            }
            else
            {
                // Non-null way of dropping nothing.
                processedDrop = DropFactory.dropAllOf(new List <Drop>());
            }

            var flagSet = new List <string>();

            if (_flags != null)
            {
                flagSet.AddRange(_flags.Split(' '));
            }
            if (flags != null)
            {
                flagSet.AddRange(flags.Split(' '));
            }

            var breed = new Breed(
                name, Pronouns.It, new Glyph(_glyph, foreColour),
                attacks, moves,
                processedDrop,
                maxHealth: maxHealth,
                tracking: tracking.Value,
                meander: meander + _meander,
                speed: speed + _speed,
                flags: flagSet,
                slug: string.Empty);

            Breeds.Add(breed.Name, breed);
            return(breed);
        }
Exemple #3
0
        private void ProcessCommand()
        {
            var rex = new Regex(@"("".*?""|[^ ""]+)+");
            //string test = "CALL \"C:\\My File Name With Space\" /P1 P1Value /P1 P2Value";
            //var array = rex.Matches(test).OfType<Match>().Select(m => m.Groups[0]).ToArray();

            var matches        = rex.Matches(Command).OfType <Match>().Select(m => m.Groups[0]).ToArray();
            var primaryCommand = matches[0].Value;

            switch (primaryCommand.ToLower())
            {
            case "goto":
            {
                var location = matches[1].Value;

                VectorBase pos = null;
                switch (location.ToLower())
                {
                case "stairsdown":
                {
                    pos = Game.CurrentStage.StairDownPosition;
                    break;
                }

                case "stairsup":
                {
                    pos = Game.CurrentStage.StairUpPosition;
                    break;
                }
                }

                if (pos == null)
                {
                    Command = string.Empty;
                    break;
                }
                pos = Game.CurrentStage.FindDistantOpenTileNear(pos);

                Game.CurrentStage.currentActor.Position = pos;
                Game.CurrentStage.refreshVisibility(Game.CurrentStage.CurrentHero);
                Command = string.Empty;
                break;
            }

            case "giveitem":
            {
                var itemType = matches[1].Value;
                if (itemType[0] == '"')
                {
                    itemType = itemType.Substring(1, itemType.Length - 2);
                }
                var quantity = 1;
                if (matches.Length == 3)
                {
                    quantity = int.Parse(matches[2].Value);
                }
                Drop processedDrop = DropFactory.parseDrop(itemType);
                for (int index = 0; index < quantity; index++)
                {
                    processedDrop.SpawnDrop(Game.Hero.Inventory.tryAdd);
                }
                Command = string.Empty;
                break;
            }

            case "giveset":
            {
                var setType  = matches[1].Value;
                var quantity = 1;

                switch (setType.ToLower())
                {
                case "warrior":
                {
                    DropFactory.parseDrop("Chain Mail Cap").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Chain Mail Gloves").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Large Shield").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Falchion").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Crossbow").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Greaves").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Scale Mail").SpawnDrop(Game.Hero.Equipment.replace);
                    DropFactory.parseDrop("Fur Cloak").SpawnDrop(Game.Hero.Equipment.replace);
                    break;
                }
                }


                Command = string.Empty;
                break;
            }

            case "sethealth":
            {
                var newHealth = int.Parse(matches[1].Value);
                Game.Hero.Health.Current = newHealth;
                Command = string.Empty;
                break;
            }
            }
        }