private static List <round> run_sim(Faction attacking_faction, Faction defending_faction, List <Asset> attackers, List <Asset> defenders) { List <round> results = new List <round> (); total_direct_damage = 0; if (attacking_faction == null) { for (int i = 0; i < _runoptions.attacking_faction_ids.Count(); i++) { attackers[i].owner = _dbc.get_faction(con, Convert.ToInt32(_runoptions.attacking_faction_ids[i])); } } else { foreach (var attacker in attackers) { attacker.owner = attacking_faction; } } if (defending_faction == null) { for (int i = 0; i < _runoptions.defending_faction_ids.Count(); i++) { defenders[i].owner = _dbc.get_faction(con, Convert.ToInt32(_runoptions.defending_faction_ids[i])); } } else { foreach (var defender in defenders) { defender.owner = defending_faction; } } foreach (Asset attacker in attackers) { var atk = attacker; List <Asset> eligible_defenders = defenders.Where(e => e.hp > 0).ToList(); if (atk.AttackStats == "None" || attacker.hp == 0) { continue; } if (eligible_defenders.Count == 0) { round result = run_round(atk, null, attacker.owner, defenders.Select(e => e.owner).First()); results.Add(result); } else { Asset rand_defender = eligible_defenders.ToArray() [rand.Next(eligible_defenders.Count())]; round result = run_round(atk, rand_defender, attacker.owner, rand_defender.owner); results.Add(result); } eligible_defenders = null; } return(results); }