Esempio n. 1
0
        public static string GetTreeBody(ResearchTree tree, ApplicationDbContext db, ActionModel model)
        {
            var text = "";
            text = SerializeRecursive(tree.StartingNode, text, db, model);

            return text;
        }
Esempio n. 2
0
        public static ResearchTree BuildTreeForView(ActionModel model, ApplicationDbContext db)
        {
            var nodes = db.ResearchNodes.Where(x => true).ToList();
            var learnedNodes = db.LearnedResearchNodes.Where(lrn => model.Corporation.Id == lrn.Corporation.Id).Include(n => n.ResearchNode).Select(n=>n.ResearchNode.Name).ToList();
            var activeNodes =
                db.ActiveResearchNodes.Where(arn => arn.Corporation.Id == model.Corporation.Id).Select(n => n.ResearchNode.Name).ToList();

            var t = new ResearchTree
            {
                Name = "Rocketry",
                StartingNode = nodes.FirstOrDefault(n => n.Name == "Basic Rocketry")
            };

            nodes.ForEach(
                node =>
                    node.Enabled =
                        !learnedNodes.Contains(node.Name)
                        && !activeNodes.Contains(node.Name)//Not actively being researched or already researched
                        && node.PrereqsMet(db, model.DataCache.LearnedResearchNodes)); //has prereqs met or has none

            return t;
        }