public static Event FindEvent(Pilot target, EventSpecial specialGroup) { List <Event> filteredLibrary = new List <Event>(); foreach (Event e in library) { if (specialGroup == e.specialGroup && e.filters.IsGood(target) && !target.blockedEvents.Contains(e)) { filteredLibrary.Add(e); } } if (filteredLibrary.Count == 0) { return(null); } else { return(filteredLibrary[Random.Get(0, filteredLibrary.Count)]); } }
/*public static Event FindEvent(Pilot target) * { * int eventGroups = EventGroup.None; * if (target.planet == null) { eventGroups = EventGroup.Space; } * else { eventGroups = target.planet.eventGroups; } * * return FindEvent(target, eventGroups); * }*/ public static Event FindEvent(Pilot target, int eventGroup) { List <Event> filteredLibrary = new List <Event>(); foreach (Event e in library) { if ((eventGroup & e.eventGroup) > 0 && e.filters.IsGood(target) && !target.blockedEvents.Contains(e)) { for (int i = 0; i < e.chance; i++) { filteredLibrary.Add(e); } } } if (filteredLibrary.Count == 0) { return(null); } else { return(filteredLibrary[Random.Get(0, filteredLibrary.Count)]); } }
public bool IsGood(Pilot target) { // Gender check if (!(pilotGender == GenderFilter.Any || (pilotGender == GenderFilter.MaleOnly && target.gender == Gender.Male) || (pilotGender == GenderFilter.FemaleOnly && target.gender == Gender.Female))) { return(false); } // Money check if (target.money < pilotMoney.min || target.money > pilotMoney.max) { return(false); } // Story check if (target.storyStage < storyStage.min || target.storyStage > storyStage.max) { return(false); } // All good return(true); }