示例#1
0
        public override double Calculate(double number, Forest forest)
        {
            double x  = number;
            double lf = forest.GetValue(Limit);
            double a  = forest.GetValue(Growth);

            return(lf - Math.Pow(Math.E, -a * x) * lf);
        }
示例#2
0
        public override double Calculate(double number, Forest forest)
        {
            double x     = number;
            double lf    = forest.GetValue(Limit);
            double spd   = forest.GetValue(Speed);
            double start = forest.GetValue(Start);
            double etox  = start * Math.Pow(Math.E, lf * spd * x);

            return((lf * etox) / (etox + lf - start));
        }
示例#3
0
        public bool Perform()
        {
            if (Forest.Mana < Forest.GetValue(ManaCost))
            {
                Console.WriteLine("Not enough mana! " + Name + " costs " + Forest.GetValue(ManaCost));
                return(false);
            }
            if ((ResourceChange == null || ResourceChange.CanAfford(Forest, 1)) &&
                TestRequirements())
            {
                Forest.SpendMana(Forest.GetValue(ManaCost));
                if (ResourceChange != null)
                {
                    ResourceChange.Print(Forest, 1);
                    ResourceChange.Apply(Forest, 1);
                }
                foreach (CodeInject c in Injects["perform"])
                {
                    c(Forest, this, null);
                }
                Console.WriteLine(Text);
                Unlocked = RemainUnlocked;

                return(true);
            }
            else
            {
                Console.WriteLine(FailText);
                return(false);
            }
        }
示例#4
0
        public string GetTooltip()
        {
            string result = Name;

            if (ManaCost != null && Forest.GetValue(ManaCost) > 0)
            {
                result += " (" + Forest.GetValue(ManaCost) + "mp)";
            }
            if (Injects["tooltip"].Count > 0)
            {
                result += " " + (string)Injects["tooltip"][0](Forest, this, null);
            }
            return(result);
        }
示例#5
0
 /// <summary>
 /// Returns what the price of a given purchase will be modified by.
 /// The modification is equal to Inc^(lift+base)
 ///
 /// Lift indicates how many more purchases this modifier counts for than the current base.
 /// This is used for getting the price of paying this Resources several times at the same time.
 /// </summary>
 /// <param name="lift"></param>
 /// <param name="forest"></param>
 /// <returns></returns>
 public double Modifier(int lift, Forest forest)
 {
     return(Math.Pow(forest.GetValue(Inc), forest.GetValue(XValue) + lift));
 }
示例#6
0
        static void Main(string[] args)
        {
            var culture = new CultureInfo("en-US");

            Thread.CurrentThread.CurrentCulture = culture;
            Forest forest = new Forest();

            Initializer.Init(forest);

            while (true)
            {
                Console.Write("\nWhat do you do? ");
                string l = Console.ReadLine();
                if (l.StartsWith("do"))
                {
                    if (l.Split(' ').Length == 1)
                    {
                        forest.ListDoables();
                    }
                    else if (forest.Doables.ContainsKey(l.Substring(3).Trim()))
                    {
                        forest.PerformDoable(l.Substring(3));
                    }
                    else
                    {
                        Console.WriteLine("No doable by name " + l.Substring(3).Trim());
                    }
                }
                else if (l.StartsWith("count"))
                {
                    forest.ListGrowths();
                }
                else if (l.ToLower().StartsWith("growth"))
                {
                    if (l.Split(' ').Length == 1)
                    {
                        forest.ListGrowths();
                    }
                    else
                    {
                        string growth = l.Substring(6).Trim();
                        if (!forest.Entities.ContainsKey(growth))
                        {
                            Console.WriteLine("No Growth by name " + growth);
                        }
                        else
                        {
                            forest.Entities[growth].Echo(true);
                        }
                    }
                }
                else if (l.StartsWith("create"))
                {
                    if (l.Split(' ').Length == 1)
                    {
                        forest.ListPrices();
                    }
                    else if (forest.Entities.ContainsKey(l.Substring(7).Trim()))
                    {
                        string thing = l.Substring(7).Trim();
                        if (!forest.Entities.ContainsKey(thing) || !forest.Entities[thing].HasExtension(E.EEXT_BUYABLE))
                        {
                            Console.WriteLine("This cannot be created.");
                        }
                        else
                        {
                            Console.Write("How many? ");
                            l = Console.ReadLine();
                            int res = 0;
                            if (l.EndsWith("%"))
                            {
                                if (int.TryParse(l.Substring(0, l.Length - 1), out res))
                                {
                                    forest.BuyObject(thing, res, true);
                                }
                            }
                            else
                            {
                                res = 0;
                                if (int.TryParse(l, out res))
                                {
                                    if (res > 0)
                                    {
                                        forest.BuyObject(thing, res);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (l.StartsWith("items"))
                {
                    forest.ListGrowths(E.GRP_ITEMS);
                }
                else if (l.StartsWith("skills"))
                {
                    forest.ListSkills();
                }
                else if (l.StartsWith("hp"))
                {
                    Console.WriteLine(Math.Round(forest.Hp, 2) + " / " + Math.Round(forest.Stats[E.HEALTH], 2));
                }
                else if (l.StartsWith("mana"))
                {
                    Console.WriteLine(Math.Round(forest.Mana, 2) + " / " + Math.Round(forest.Stats[E.MAXMANA], 2));
                }
                else if (l.StartsWith("fight"))
                {
                    forest.StartFighting();
                }
                else if (l.StartsWith("boss"))
                {
                    forest.EchoBoss();
                }
                else if (l.StartsWith("stats"))
                {
                    foreach (KeyValuePair <string, double> entry in forest.GetStats())
                    {
                        if (entry.Value != 0)
                        {
                            Console.WriteLine(entry.Key + ": " + entry.Value);
                        }
                    }
                    if (debug && forest.Boss != null)
                    {
                        Console.WriteLine("DEBUG VALUE (hp*(attack-b.def)): " + Statics.GetDisplayNumber(forest.Hp * (forest.Stats[E.ATTACK] - forest.Boss.Stats[E.DEFENSE])));
                        Console.WriteLine("DEBUG VALUE 2 ((b.attack-(def+hpReg))/soothing * 30) - seconds to survive: " + ((forest.Boss.Stats[E.ATTACK] - (forest.Stats[E.DEFENSE] + forest.Stats[E.HEALTHREGEN])) / forest.Stats[E.SOOTHING]) * 30 + "s");
                    }
                }
                else if (l.StartsWith("upgrades"))
                {
                    forest.ListAvailableUpgrades();
                }
                else if (l.StartsWith("upgrade"))     // Get data on a specific Upgrade and maybe buy it
                {
                    if (l.Split(' ').Length == 1)
                    {
                        forest.ListAvailableUpgrades();
                    }
                    else
                    {
                        string upgrade = l.Substring(8);
                        if (upgrade == "all")
                        {
                            foreach (Upgrade u in forest.GetEntities(E.GRP_UPGRADES))
                            {
                                if (u.Unlocked && !u.Owned)
                                {
                                    u.Create(1);
                                }
                            }
                        }
                        else if (!forest.Entities.ContainsKey(upgrade) || !forest.Entities[upgrade].Unlocked || forest.Entities[upgrade].Group != E.GRP_UPGRADES)
                        {
                            Console.WriteLine("No upgrade by name " + upgrade);
                        }
                        else
                        {
                            forest.Entities[upgrade].Echo();
                            if (!((Upgrade)forest.Entities[upgrade]).Owned)   //Let you buy the upgrade
                            {
                                Console.WriteLine("Do you want to buy it? [Y/N]");
                                string answer = Console.ReadLine();
                                if (answer.Trim().ToLower().Equals("y"))
                                {
                                    forest.Entities[upgrade].Create(1);
                                }
                                else
                                {
                                    Console.WriteLine("Okay :)");
                                }
                            }
                        }
                    }
                }
                else if (l.StartsWith("talents"))
                {
                    if (l.Split(' ').Length == 1)
                    {
                        foreach (KeyValuePair <string, int> talentPoints in forest.TalentPoints)
                        {
                            if (forest.Xp[talentPoints.Key] > 101)
                            {
                                Console.WriteLine(talentPoints.Key + ": " + talentPoints.Value + " point" + (talentPoints.Value != 1 ? "s" : "") + ".");
                            }
                        }

                        forest.ListAvailableTalents(null);
                    }
                    else
                    {
                        string skill = l.Substring(8);
                        if (!Statics.skills.Contains(skill))
                        {
                            Console.WriteLine("That skill does not exist!");
                        }
                        else
                        {
                            Console.WriteLine(skill + ": " + forest.TalentPoints[skill] + " point" + (forest.TalentPoints[skill] != 1 ? "s" : "") + ".");
                            forest.ListAvailableTalents(skill);
                        }
                    }
                }
                else if (l.StartsWith("talent"))     // Get data on a specific Talent and maybe buy it
                {
                    if (l.Split(' ').Length == 1)
                    {
                        PrintHelp();
                    }
                    else
                    {
                        string talent = l.Substring(7);
                        if (!forest.Entities.ContainsKey(talent) || !forest.Entities[talent].Unlocked)
                        {
                            Console.WriteLine("No talent by name " + talent);
                        }
                        else
                        {
                            forest.Entities[talent].Echo();
                            if (!((Talent)forest.Entities[talent]).Owned)   //Let you buy the talent
                            {
                                Console.WriteLine("Do you want to buy it? [Y/N]");
                                string answer = Console.ReadLine();
                                if (answer.Trim().ToLower().Equals("y"))
                                {
                                    forest.Entities[talent].Create(1);
                                }
                                else
                                {
                                    Console.WriteLine("Okay :)");
                                }
                            }
                        }
                    }
                }
                else if (l.StartsWith("modifiers"))
                {
                    forest.ListModifiers();
                }
                else if (l.StartsWith("branch"))
                {
                    forest.PickPath();
                }
                else if (l.StartsWith("path"))
                {
                    forest.EchoPath();
                }
                else if (l.StartsWith("path"))
                {
                    forest.EchoPath();
                }
                else if (l.StartsWith("style"))
                {
                    if (forest.GetValue(E.CHANGED_STYLE) > 0)
                    {
                        Console.WriteLine("You have already picked your style. You need time and contemplation if you want to repick.");
                    }
                    else if (l.Length == 5)
                    {
                        Console.WriteLine(E.STYLE_FIGHT + ": Lock in to the path of fighting for your right.");
                        if (forest.Stats[E.SOOTHING] > 0)
                        {
                            Console.WriteLine(E.STYLE_SOOTHE + ": Soothe your enemies, but don't deal them damage");
                        }
                    }
                    else
                    {
                        string style = l.Substring(6);
                        if (style == E.STYLE_FIGHT)
                        {
                            Console.WriteLine("You are now locked in as a fighter.");
                            forest.FightingStyle           = E.STYLE_FIGHT;
                            forest.Values[E.CHANGED_STYLE] = 1;
                        }
                        else if (style == E.STYLE_SOOTHE && forest.Stats[E.SOOTHING] > 0)
                        {
                            Console.WriteLine("You are now a Soother!");
                            forest.FightingStyle           = E.STYLE_SOOTHE;
                            forest.Values[E.CHANGED_STYLE] = 1;
                        }
                        else
                        {
                            Console.WriteLine("Invalid style!");
                        }
                    }
                }
                else if (l.StartsWith("debug"))
                {
                    debug = !debug;
                    if (l.Split(' ').Length > 1)
                    {
                        if (int.TryParse(l.Split(' ')[1], out int res))
                        {
                            if (res > 0)
                            {
                                debugCountTime = res;
                            }
                            debug = true;
                        }
                    }
                    if (debug)
                    {
                        Console.WriteLine("Now debugging...");
                    }
                    else
                    {
                        Console.WriteLine("Not debugging anymore.");
                    }
                }
                else if (l.StartsWith("time"))
                {
                    Console.WriteLine(forest.Count / 5 + "s, offline " + forest.OfflineTicks / 5 + "s");
                    Console.WriteLine(forest.LifeCount / 5 + "s alive");
                }
                else if (l.StartsWith("save"))
                {
                    if (l.Split(' ').Length > 1)
                    {
                        forest.Save(l.Substring(5));
                    }
                    else
                    {
                        forest.Save();
                    }
                }
                else if (l.StartsWith("load"))
                {
                    forest.Running        = false;
                    forest                = new Forest();
                    Initializer.firstInit = true;
                    Initializer.Init(forest);
                    if (l.Split(' ').Length > 1)
                    {
                        forest.Load(l.Substring(5));
                    }
                    else
                    {
                        forest.Load();
                    }
                }
                else if (l.StartsWith("think"))
                {
                    forest.Think();;
                }
                else
                {
                    PrintHelp();
                }
            }
        }
示例#7
0
 public override double Calculate(double number, Forest forest)
 {
     return(forest.GetValue(BaseValue) + forest.GetValue(Proportionality) * number);
 }