public void Fight() { // PART 1. Target selection // Clear objectives foreach (var groups in System.Union(Infect)) { groups.AttackObjective = null; groups.IsTargeted = false; } // System select their targets SelectTargets(System, Infect); // Infect select their targets SelectTargets(Infect, System); // PART 2. Attacking foreach (var group in System.Union(Infect).OrderByDescending(g => g.Initiative)) { group.Attack(); } // Clean System.Where(i => i.Units == 0).ToList().ForEach(i => System.Remove(i)); Infect.Where(i => i.Units == 0).ToList().ForEach(i => Infect.Remove(i)); }
public object Clone() { var newSystem = new List <Group>(); var newInfect = new List <Group>(); System.ToList().ForEach(o => newSystem.Add((Group)o.Clone())); Infect.ToList().ForEach(o => newInfect.Add((Group)o.Clone())); return(new Battle(newSystem, newInfect)); }
private void Infect_PE(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); string pePath = null; openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "exe files(*.exe) | *.exe | All files(*.*) | *.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pePath = openFileDialog1.FileName; } tasks.Add(Task.Factory.StartNew(() => { Infect infect = new Infect(); if (pePath != null) { infect.infectPe(pePath); } })); }
public static void RunScript(string inputText) { var arr = inputText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); for (var i = 0; i < arr.Length; i++) { var s = arr[i]; var args = Regex .Split(String.Join(" ", s), "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") .Where(item => !string.IsNullOrEmpty(item)) .ToList(); if (args.Count < 1) { continue; } var cmd = args[0].Trim().ToLower(); args.RemoveAt(0); if (cmd.StartsWith("#") || cmd.StartsWith("//") || cmd == string.Empty) { continue; } switch (cmd) { case "spawn": Spawn.Run(args, i); break; case "roundlock": RoundSummary.RoundLock = true; break; case "detonate": ScriptActions.scriptData.detonate = true; break; case "teleport": Teleport.Run(args, i); break; case "createclass": CreateClass.Run(args, i); break; case "clearitems": ClearItems.Run(args, i); break; case "give": Give.Run(args, i); break; case "infect": Infect.Run(args, i); break; case "hp": HP.Run(args, i); break; case "scale": Scale.Run(args, i); break; case "disabledecontamination": DisableDecontamination.Run(args, i); break; case "last": Last.Run(args, i); break; case "cassie": TextCommand.Run(args, i, "cassie"); break; case "broadcast": TextCommand.Run(args, i, "broadcast"); break; case "hint": TextCommand.Run(args, i, "hint"); break; case "lights": Lights.Run(args, i); break; case "disabledetonation": DisableDetonation.Run(args, i); break; case "escape": Commands.Escape.Run(args, i); break; default: throw new InvalidCommandException("The command \"" + cmd + "\" on line " + i + " was not found."); } } }