Exemplo n.º 1
0
        public void CreatePotion(Flask flask, Solvent solvent, Ingredient[] ingredients, Apothecary apothecary)
        {
            var potion = new Potion(flask, solvent, ingredients);

            this.PotionsForSale.Add(potion);

            this.RemovePotionMaterials(flask, solvent, ingredients);

            this.OnPotionCreated(potion, apothecary);
        }
Exemplo n.º 2
0
        private void CreatePotion(object sender, IntEventArgs e)
        {
            if (World.Instance.Random.Next(0, 100) > 30)
            {
                return;
            }

            foreach (var potionPrototype in World.Instance.Shop.PotionPrototypes)
            {
                Flask flask = null;

                foreach (var shopFlask in World.Instance.Shop.Flasks)
                {
                    if (shopFlask.Name == potionPrototype.FlaskName)
                    {
                        flask = shopFlask;

                        break;
                    }
                }

                if (flask == null)
                {
                    continue;
                }

                Solvent solvent = null;

                var ingredients = new List <Ingredient>();

                foreach (var herbName in potionPrototype.HerbNames)
                {
                    foreach (var shopHerb in World.Instance.Shop.Herbs)
                    {
                        if (shopHerb.Name == herbName)
                        {
                            ingredients.Add(shopHerb);

                            break;
                        }
                    }
                }

                if (ingredients.Count != potionPrototype.IngredientCount)
                {
                    continue;
                }

                this.potionsCrafted++;

                World.Instance.Shop.CreatePotion(flask, solvent, ingredients.ToArray(), this);

                break;
            }
        }
Exemplo n.º 3
0
        private void RemovePotionMaterials(Flask flask, Solvent solvent, Ingredient[] ingredients)
        {
            this.DiscardFlask(flask);

            // DiscardSolvent(solvent);

            foreach (var ingredient in ingredients)
            {
                this.DiscardIngredient(ingredient);
            }
        }
Exemplo n.º 4
0
        public void ResearchPotion(Flask flask, Solvent solvent, Ingredient[] ingredients)
        {
            foreach (var ingredient in ingredients)
            {
                Debug.Log(ingredient.Name);
            }
            var potion = new Potion(flask, solvent, ingredients);

            if (!this.AddPotionPrototype(potion))
            {
                return;
            }

            this.RemovePotionMaterials(flask, solvent, ingredients);

            this.OnPotionResearched(potion);
        }
Exemplo n.º 5
0
        public Potion(Flask flask, Solvent solvent, Ingredient[] ingredients)
        {
            var herbNames = new List <string>();

            // var otherTypeNames = new List<string>();

            foreach (var ingredient in ingredients)
            {
                if (ingredient is Herb)
                {
                    herbNames.Add(ingredient.Name);
                }/* else if (ingredient is OtherType) {
                  * otherTypes.Add(ingredient.Name);
                  * }*/
            }

            var effectsToCheck = new Queue <Effect>();

            foreach (var ingredient in ingredients)
            {
                foreach (var effect in ingredient.Effects)
                {
                    effectsToCheck.Enqueue(effect);
                }
            }

            var effects = new List <Effect>();

            while (effectsToCheck.Count > 0)
            {
                var currentEffect = effectsToCheck.Dequeue();

                foreach (var effect in effectsToCheck)
                {
                    var combinedEffect = currentEffect.Combine(effect);

                    if (combinedEffect != null)
                    {
                        effects.Add(combinedEffect);
                    }
                }
            }

            var name = flask.Quality.ToString() + " Potion of ";

            for (var i = 0; i < effects.Count; i++)
            {
                name += effects[i].Name;

                if (i < effects.Count - 1)
                {
                    name += ", ";
                }
            }

            this.name        = name;
            this.flaskName   = flask.Name;
            this.solventName = solvent == null ? string.Empty : solvent.Name;
            this.herbNames   = herbNames.ToArray();
            // this.otherTypeNames = otherTypeNames.ToArray();
            this.effects = effects.ToArray();
            this.value   = flask.Value * effects.Count;
        }