public IPs NextHackabletIp(IPersistanceMgr pm) { //var scannables = from ip in pm.ScannableIps() // where ip.IP != "127.0.0.1" // select ip; //var i = r.Next(0, scannables.Count()); //return scannables.ElementAt(i); // takes the richest ips that are actually hackable and select randomly var scannablesASAP = pm.ScannableIps() .Where(ip => ip.IP != "127.0.0.1") // filter dev ip .OrderBy(ip => ip.Money) .ThenByDescending(ip => ip.LastAttack); if (scannablesASAP.Count() == 0) { return(null); } // randomly generated index, the lowest are more likely var i = (int)(Math.Pow(r.NextDouble(), 3) * (double)scannablesASAP.Count()); return(scannablesASAP.ElementAt(i)); }
public IPs NextHackabletIp(IPersistanceMgr pm) { IEnumerable <IPs> ips = pm.ScannableIps(); var first = ips .Where(ip => ip.IP != "127.0.0.1") // filter dev ip .OrderBy(ip => ip.Money) .ThenByDescending(ip => ip.LastAttack) .FirstOrDefault(); return(first); }