Пример #1
0
 public EggBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
 {
     hub                 = Hub;
     Counts              = Hub.Counts;
     DumpSetting         = Hub.Config.Folder;
     ContinueGettingEggs = Hub.Config.Egg.ContinueAfterMatch;
     Ping                = !Hub.Config.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.PingOnMatch}>\n" : "";
 }
Пример #2
0
        private void DumpModule(IntPtr moduleHandle, ImageLayout imageLayout, string filePath)
        {
            bool result;

            using (IDumper dumper = DumperFactory.GetDumper(_process.Id, _dumperType.Value))
                result = dumper.DumpModule(moduleHandle, imageLayout, filePath);
            MessageBoxStub.Show(result ? $"{_resources.GetString("StrDumpModuleSuccessfully")}{Environment.NewLine}{filePath}" : _resources.GetString("StrFailToDumpModule"), result ? MessageBoxIcon.Information : MessageBoxIcon.Error);
        }
Пример #3
0
        public override IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            Type       loadedType = base.GetTypeFromFullname(typeFullName);
            MethodInfo method     = loadedType.GetMethod("CreateFromDump", new Type[] { typeof(SafeSharedObjects), typeof(Dump) });
            IDumper    instance   = (IDumper)method.Invoke(null, new object[] { sharedObjects, data });

            return(instance);
        }
Пример #4
0
 public FossilBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
 {
     Counts        = Hub.Counts;
     DumpSetting   = Hub.Config.Folder;
     Settings      = Hub.Config.Fossil;
     FossilSpecies = Settings.Species;
     CaptureVideo  = Hub.Config.CaptureVideoClip;
 }
Пример #5
0
 public RaidBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub      = hub;
     Settings = Hub.Config.Raid;
     Dump     = Hub.Config.Folder;
     Counts   = Hub.Counts;
     ldn      = Settings.UseLdnMitm;
 }
Пример #6
0
 public EncounterBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub         = hub;
     Counts      = Hub.Counts;
     DumpSetting = Hub.Config.Folder;
     DesiredIVs  = StopConditionSettings.InitializeTargetIVs(Hub);
     Ping        = !Hub.Config.StopConditions.PingOnMatch.Equals(string.Empty) ? $"<@{Hub.Config.StopConditions.PingOnMatch}>\n" : "";
 }
Пример #7
0
        public virtual IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            IDumper instance = CreateInstance(typeFullName);

            instance.LoadDump(data);

            return(instance);
        }
Пример #8
0
 private void DumpProcess(uint processId, string directoryPath)
 {
     if (!Directory.Exists(directoryPath))
     {
         Directory.CreateDirectory(directoryPath);
     }
     using (IDumper dumper = DumperFactory.GetDumper(processId, _dumperType.Value))
         MessageBoxStub.Show($"{dumper.DumpProcess(directoryPath).ToString()} {_resources.GetString("StrDumpFilesSuccess")}{Environment.NewLine}{directoryPath}", MessageBoxIcon.Information);
 }
 private object InvokeDelegate(IDumper list, string suffixName, params object[] parameters)
 {
     var lengthObj = list.GetSuffix(suffixName);
     Assert.IsNotNull(lengthObj);
     var lengthDelegate = lengthObj as Delegate;
     Assert.IsNotNull(lengthDelegate);
     var length = lengthDelegate.DynamicInvoke(parameters);
     return length;
 }
Пример #10
0
 public DumpContext(IDumper dumper, DumpInfo dumpInfo, Set <INode> matchedNodes, Set <INode> multiMatchedNodes,
                    Set <IEdge> matchedEdges, Set <IEdge> multiMatchedEdges)
 {
     Dumper            = dumper;
     DumpInfo          = dumpInfo;
     MatchedNodes      = matchedNodes;
     MultiMatchedNodes = multiMatchedNodes;
     MatchedEdges      = matchedEdges;
     MultiMatchedEdges = multiMatchedEdges;
 }
Пример #11
0
        private object InvokeDelegate(IDumper stack, string suffixName, params object[] parameters)
        {
            var lengthObj = stack.GetSuffix(suffixName);

            Assert.IsNotNull(lengthObj);
            var lengthDelegate = lengthObj as Delegate;

            Assert.IsNotNull(lengthDelegate);
            var length = lengthDelegate.DynamicInvoke(parameters);

            return(length);
        }
Пример #12
0
 public RaidBot(PokeBotConfig cfg, PokeTradeHub <PK8> hub) : base(cfg)
 {
     Hub               = hub;
     Settings          = hub.Config.Raid;
     Dump              = hub.Config.Folder;
     Counts            = hub.Counts;
     ldn               = Settings.UseLdnMitm;
     RaidLog           = Settings.RaidLog;
     FriendCode        = Settings.FriendCode;
     Roll              = Settings.AutoRoll;
     FRBoth            = Settings.FriendCombined;
     FRAdd             = Settings.FriendAdd;
     FriendRemoveCount = Settings.FriendPurge;
 }
Пример #13
0
        public Dump Dump(IDumper dumper, bool includeType = true)
        {
            var dump = dumper.Dump();

            List <object> keys = new List <object>(dump.Keys);

            foreach (object key in keys)
            {
                dump[key] = DumpValue(dump[key], includeType);
            }

            if (includeType)
            {
                dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name);
            }

            return(dump);
        }
Пример #14
0
        public EncounterBot(PokeBotConfig cfg, PokeTradeHub <PK8> Hub) : base(cfg)
        {
            hub           = Hub;
            Counts        = Hub.Counts;
            DumpSetting   = Hub.Config.Folder;
            DesiredNature = Hub.Config.Encounter.DesiredNature;

            /* Populate DesiredIVs array.  Bot matches 0 and 31 IVs.
             * Any other nonzero IV is treated as a minimum accepted value.
             * If they put "x", this is a wild card so we can leave -1. */
            string[] splitIVs = Hub.Config.Encounter.DesiredIVs.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // Only accept up to 6 values in case people can't count.
            for (int i = 0; i < 6 && i < splitIVs.Length; i++)
            {
                if (splitIVs[i] == "x" || splitIVs[i] == "X")
                {
                    continue;
                }
                DesiredIVs[i] = Convert.ToInt32(splitIVs[i]);
            }
        }
Пример #15
0
        public override IDumper CreateAndLoad(string typeFullName, Dump data)
        {
            IDumper instance = base.CreateInstance(typeFullName);

            if (instance is IHasSharedObjects)
            {
                IHasSharedObjects withSharedObjects = instance as IHasSharedObjects;
                withSharedObjects.Shared = sharedObjects;
            }
            else if (instance is IHasSafeSharedObjects)
            {
                IHasSafeSharedObjects withSharedObjects = instance as IHasSafeSharedObjects;
                withSharedObjects.Shared = sharedObjects;
            }

            if (instance != null)
            {
                instance.LoadDump(data);
            }

            return(instance);
        }
Пример #16
0
        public EncounterBot(PokeBotConfig cfg, EncounterSettings encounter, IDumper dump, BotCompleteCounts count) : base(cfg)
        {
            Counts        = count;
            DumpSetting   = dump;
            StopOnSpecies = encounter.StopOnSpecies;
            Mode          = encounter.EncounteringType;
            DesiredNature = encounter.DesiredNature;

            /* Populate DesiredIVs array.  Bot matches 0 and 31 IVs.
             * Any other nonzero IV is treated as a minimum accepted value.
             * If they put "x", this is a wild card so we can leave -1. */
            string[] splitIVs = encounter.DesiredIVs.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // Only accept up to 6 values in case people can't count.
            for (int i = 0; i < 6 && i < splitIVs.Length; i++)
            {
                if (splitIVs[i] == "x" || splitIVs[i] == "X")
                {
                    continue;
                }
                DesiredIVs[i] = Convert.ToInt32(splitIVs[i]);
            }
        }
Пример #17
0
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
     _dumper = dumper;
     _subPath = subPath;
 }
Пример #18
0
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Hub             = hub;
     DumpSetting     = hub.Config.Folder;
     GiveawaySetting = hub.Config.Giveaway;
 }
Пример #19
0
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotState cfg) : base(cfg)
 {
     Hub         = hub;
     DumpSetting = hub.Config.Folder;
 }
Пример #20
0
 /// <summary>
 /// Dumps the graph with a given graph dumper.
 /// </summary>
 /// <param name="graph">The graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
 public static void Dump(IGraph graph, IDumper dumper, DumpInfo dumpInfo)
 {
     DumpMatch(graph, dumper, dumpInfo, null, 0);
 }
Пример #21
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
                              int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
                     textColor, color, style, thickness);
 }
Пример #22
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
     int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
         textColor, color, style, thickness);
 }
Пример #23
0
 /// <summary>
 /// Dumps the named graph with a given graph dumper and default dump style.
 /// </summary>
 /// <param name="namedGraph">The named graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 public static void Dump(INamedGraph namedGraph, IDumper dumper)
 {
     DumpMatch(namedGraph, dumper, new DumpInfo(namedGraph.GetElementName), null, 0);
 }
Пример #24
0
 private string Serialize(IDumper o)
 {
     return new SafeSerializationMgr(null).Serialize(o, FormatWriter);
 }
Пример #25
0
 public string ToString(IDumper dumper)
 {
     return Serialize(dumper, TerminalFormatter.Instance, false);
 }
Пример #26
0
 public string Serialize(IDumper serialized, IFormatWriter formatter, bool includeType = true)
 {
     return formatter.Write(Dump(serialized, includeType));
 }
Пример #27
0
        public Dump Dump(IDumper dumper, bool includeType = true)
        {
            var dump = dumper.Dump();

            List<object> keys = new List<object>(dump.Keys);

            foreach (object key in keys)
            {
                dump[key] = DumpValue(dump[key], includeType);
            }

            if (includeType)
            {
                dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name);
            }

            return dump;
        }
Пример #28
0
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
 }
Пример #29
0
        public void DumpScript(byte[] data, IDumper dumper)
        {
            try
            {
                var scriptInterpreter = ScriptParser.Create(Game);
                var compilationUnit = scriptInterpreter.Parse(data);
                var replacers = new IAstReplacer[]
                {
                    //new ReplacePushAndPop(),
                    new ResolveVariables(scriptInterpreter.KnownVariables),
                    //new ResolveAllTypesOfVariables(Game.Version),
                    // OK forget about this, I have to use structuring...
                    //new ReplaceJumpToIf(),
                    //new ReplaceJumpToWhile(),
                    //new ReplaceJumpToGoTo()
                };
                Array.ForEach(replacers, r => compilationUnit = r.Replace(compilationUnit));

                dumper.Write(compilationUnit.Accept(new DumpAstVisitor()));
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e);
                Console.ResetColor();
            }
        }
Пример #30
0
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
 }
Пример #31
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
                              GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
                     color, borderColor, shape);
 }
Пример #32
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
     GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
         color, borderColor, shape);
 }
Пример #33
0
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
                                         ref Set <INode> matchedNodes, ref Set <INode> multiMatchedNodes, ref Set <IEdge> matchedEdges, ref Set <IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set <INode>();
            matchedEdges = new Set <IEdge>();

            if ((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor     vnodeColor       = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeColor       = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeTextColor   = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeTextColor   = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape       = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle   = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int         vedgeThickness   = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set <INode>();
                multiMatchedEdges = new Set <IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach (IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                                    null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach (INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", ++j), null,
                                        vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if (matchedNodes.Contains(node))
                        {
                            multiMatchedNodes.Add(node);
                        }
                        else
                        {
                            matchedNodes.Add(node);
                        }
                    }

                    // Collect matched edges
                    foreach (IEdge edge in match.Edges)
                    {
                        if (matchedEdges.Contains(edge))
                        {
                            multiMatchedEdges.Add(edge);
                        }
                        else
                        {
                            matchedEdges.Add(edge);
                        }
                    }
                    ++i;
                }

                if (which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach (INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if (multiMatchedNodes.Contains(node))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeShape(dumpType),
                                 dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach (IEdge edge in matchedEdges)
                    {
                        if (!matchedNodes.Contains(edge.Source))
                        {
                            DumpNode(edge.Source,
                                     dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                     dumper, dumpInfo);
                        }

                        if (!matchedNodes.Contains(edge.Target))
                        {
                            DumpNode(edge.Target,
                                     dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                     dumper, dumpInfo);
                        }

                        GrElemDumpType dumpType;
                        if (multiMatchedEdges.Contains(edge))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                                 dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                                 dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
Пример #34
0
 /// <summary>
 /// Dumps the graph with a given graph dumper.
 /// </summary>
 /// <param name="graph">The graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
 public static void Dump(IGraph graph, IDumper dumper, DumpInfo dumpInfo)
 {
     DumpMatch(graph, dumper, dumpInfo, null, 0);
 }
Пример #35
0
 /// <summary>
 /// Dumps the named graph with a given graph dumper and default dump style.
 /// </summary>
 /// <param name="namedGraph">The named graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 public static void Dump(INamedGraph namedGraph, IDumper dumper)
 {
     DumpMatch(namedGraph, dumper, new DumpInfo(namedGraph.GetElementName), null, 0);
 }
Пример #36
0
        /// <summary>
        /// Dumps one or more matches with a given graph dumper.
        /// </summary>
        /// <param name="graph">The graph to be dumped.</param>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatch(IGraph graph, IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which)
        {
            Set<INode> matchedNodes = null;
            Set<INode> multiMatchedNodes = null;
            Set<IEdge> matchedEdges = null;
            Set<IEdge> multiMatchedEdges = null;

            if(matches != null)
            {
                DumpMatchOnly(dumper, dumpInfo, matches, which,
                    ref matchedNodes, ref multiMatchedNodes, ref matchedEdges, ref multiMatchedEdges);
            }

            // Dump the graph, but color the matches if any exist

            DumpContext dc = new DumpContext(dumper, dumpInfo,
                matchedNodes, multiMatchedNodes, matchedEdges, multiMatchedEdges);

            foreach(NodeType nodeType in graph.Model.NodeModel.Types)
            {
                if(dumpInfo.IsExcludedNodeType(nodeType)) continue;
                dc.Nodes.Add(graph.GetExactNodes(nodeType));
            }

            dc.InitialNodes = new Set<INode>(dc.Nodes);
            Set<INode> nodes = new Set<INode>(dc.Nodes);
            DumpGroups(graph, nodes, dc);
        }
Пример #37
0
 public EggBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Counts      = hub.Counts;
     DumpSetting = hub.Config;
 }
Пример #38
0
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
            ref Set<INode> matchedNodes, ref Set<INode> multiMatchedNodes, ref Set<IEdge> matchedEdges, ref Set<IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set<INode>();
            matchedEdges = new Set<IEdge>();

            if((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor vnodeColor = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeColor = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeTextColor = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeTextColor = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int vedgeThickness = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set<INode>();
                multiMatchedEdges = new Set<IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach(IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                        null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach(INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", j++), null,
                            vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if(matchedNodes.Contains(node)) multiMatchedNodes.Add(node);
                        else matchedNodes.Add(node);
                    }

                    // Collect matched edges
                    foreach(IEdge edge in match.Edges)
                    {
                        if(matchedEdges.Contains(edge)) multiMatchedEdges.Add(edge);
                        else matchedEdges.Add(edge);
                    }
                    i++;
                }

                if(which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach(INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if(multiMatchedNodes.Contains(node))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                            dumpInfo.GetNodeDumpTypeColor(dumpType),
                            dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                            dumpInfo.GetNodeDumpTypeShape(dumpType),
                            dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach(IEdge edge in matchedEdges)
                    {
                        if(!matchedNodes.Contains(edge.Source))
                            DumpNode(edge.Source,
                                dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                dumper, dumpInfo);

                        if(!matchedNodes.Contains(edge.Target))
                            DumpNode(edge.Target,
                                dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                dumper, dumpInfo);

                        GrElemDumpType dumpType;
                        if(multiMatchedEdges.Contains(edge))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                            dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                            dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
Пример #39
0
 public EggBot(PokeBotConfig cfg, EggSettings egg, IDumper dump, BotCompleteCounts count) : base(cfg)
 {
     Counts              = count;
     DumpSetting         = dump;
     ContinueGettingEggs = egg.ContinueAfterMatch;
 }
Пример #40
0
 /// <summary>
 ///     Set the dumper.
 /// </summary>
 /// <param name="dumper"></param>
 /// <param name="subPath"></param>
 public static void SetDumper(IDumper dumper, string subPath = "")
 {
     _dumper  = dumper;
     _subPath = subPath;
 }
Пример #41
0
 public static void Emit(IEnumerable<Events.Base> events, IDumper dumper)
 {
     foreach (var @event in events)
         dumper.Emit(@event);
 }
Пример #42
0
 public string ToString(IDumper dumper)
 {
     return(Serialize(dumper, TerminalFormatter.Instance, false));
 }
Пример #43
0
 public CompositesOperations(IDumper dumper)
 {
     _dumper = dumper;
 }
Пример #44
0
 public string Serialize(IDumper serialized, IFormatWriter formatter, bool includeType = true)
 {
     return(formatter.Write(Dump(serialized, includeType)));
 }
Пример #45
0
 public PokeTradeBot(PokeTradeHub <PK8> hub, PokeBotConfig cfg) : base(cfg)
 {
     Hub         = hub;
     DumpSetting = hub.Config;
 }
Пример #46
0
 public DumpContext(IDumper dumper, DumpInfo dumpInfo, Set<INode> matchedNodes, Set<INode> multiMatchedNodes,
     Set<IEdge> matchedEdges, Set<IEdge> multiMatchedEdges)
 {
     Dumper = dumper;
     DumpInfo = dumpInfo;
     MatchedNodes = matchedNodes;
     MultiMatchedNodes = multiMatchedNodes;
     MatchedEdges = matchedEdges;
     MultiMatchedEdges = multiMatchedEdges;
 }