protected IHeatEvent getLeatPopulatedEvent() { if (Heats.Count() == 0) { throw new ArgumentException("There are no heats for this event."); } int [] comps = Heats.Select(p => p.countCompetitors()).ToArray(); int minComps = Heats.Select(p => p.countCompetitors()).ToList().Min(); IHeatEvent[] heat = Heats.Where(h => h.countCompetitors() == minComps).ToArray(); foreach (IHeatEvent h in heat) { // is the heat full, if so skip if (h.isEventFull()) { continue; } return(h); } // all events are full throw new ArgumentException("All events are full."); }
public int getHeatNumber(IHeatEvent heat) { if (heat == null) { return(0); } if (Heats.Contains((IndividualTimedHeatEvent)heat)) { int i = 1; foreach (IHeatEvent h in Heats) { if (h == heat) { break; } else { i++; } } return(i); } else { throw new ArgumentException("Heat is not for this event"); } }
/// <summary> /// Returns the least populated event for a Team. /// </summary> /// <returns></returns> protected IHeatEvent getLeatPopulatedEvent(Team team = null) { if (Heats.Count( ) == 0) { throw new ArgumentException("There are no heats for this event."); } int [] comps; int minComps; if (team == null) { comps = Heats.Select(p => p.countCompetitors()).ToArray(); } else { comps = Heats.Select(p => p.Final.allCompetitorsinHeat(p).Where(c => c.Team == team).Count()).ToArray(); } minComps = comps.Min(); IHeatEvent[] heat; if (team == null) { heat = Heats.Where(h => h.countCompetitors( ) == minComps).ToArray( ); } else { heat = Heats.Where(p => p.Final.allCompetitorsinHeat(p).Where(c => c.Team == team).Count( ) == minComps).ToArray(); } foreach (IHeatEvent h in heat) { // is the heat full, if so skip if (h.isEventFull( )) { continue; } return(h); } // all events are full throw new ArgumentException("All events are full."); }
protected IHeatEvent getAllocatedHeatForVest(VestNumber vest) { if (Heats.Count() == 0) { throw new ArgumentException("There are no heats for this event."); } if (!vest.tryIntVest(out int VestNumber)) { throw new ArgumentException("Vest must be able to convert to an integer."); } foreach (IHeatEvent heat in Heats) { if (heat is ILaneAssignedEvent iheat) { if (iheat.hasLaneAssignementInformation( )) { if (buildLaneDraw(iheat).Contains(VestNumber)) { return(heat); } } //{ // // Check to see if a lane has an allocated vest // int[] laneDraw = buildLaneDraw(iheat); // if (laneDraw.Contains(VestNumber)) // return heat; //} } } // none of the heats has a lane allocated for this vest. return(null); }