private static string GetExceptionMessage(IShred30Contact shred30Contact) { return(string.Format( "{0} was marked as being a same side variant, but {0} does not have a same side variant", shred30Contact.Name )); }
/// <summary>Validates the contacts.</summary> /// <param name="shred30Contacts">The shred30 contacts.</param> /// <exception cref="SurfacesDoNotLineUpException"></exception> public void ValidateContacts(IEnumerable <IShred30Contact> shred30Contacts) { if (shred30Contacts.Count() <= 1) { return; } foreach (Shred30ContactPair shred30ContactPair in shred30Contacts.GetCollection().GetPairCollection()) { IShred30Contact firstContact = shred30ContactPair.FirstContact; IShred30Contact secondContact = shred30ContactPair.SecondContact; // drops don't have surfaces, so it is automatically a valid surface pair if (firstContact.IsDrop || secondContact.IsDrop) { continue; } SurfaceType firstContactEndSurface = firstContact.FootbagTrick.EndDelay.Surface; SurfaceType secondContactStartSurface = secondContact.FootbagTrick.StartDelay.Surface; bool surfacesLineUpExactly = firstContactEndSurface == secondContactStartSurface; bool secondTrickCanStartFromEitherSurface = secondContactStartSurface == SurfaceType.Either; if (!(surfacesLineUpExactly || secondTrickCanStartFromEitherSurface)) { throw new SurfacesDoNotLineUpException(shred30ContactPair); } } }
/// <summary>Gets the adds for a single contact.</summary> /// <param name="shred30Contact">The shred30 contact.</param> public int GetAdds(IShred30Contact shred30Contact) { if (shred30Contact.UseXDex) { return(shred30Contact.Adds - 1); } else { return(shred30Contact.Adds); } }
/// <summary>Validates the contacts.</summary> /// <param name="shred30Contacts">The shred30 contacts.</param> /// <exception cref="TrickAfterDropDoesNotSpecifySideException"></exception> public void ValidateContacts(IEnumerable <IShred30Contact> shred30Contacts) { foreach (Shred30ContactPair shred30ContactPair in shred30Contacts.GetCollection().GetPairCollection()) { IShred30Contact firstContact = shred30ContactPair.FirstContact; IShred30Contact secondContact = shred30ContactPair.SecondContact; bool trickFollowsDrop = firstContact.IsDrop && !secondContact.IsDrop; if (trickFollowsDrop) { if (secondContact.StartSide != OrdinalSideType.None) { continue; } else { throw new TrickAfterDropDoesNotSpecifySideException(secondContact); } } } }
/// <summary>Sets the ordinal sides for each contact.</summary> /// <param name="shred30Contacts">The shred30 contacts.</param> public IEnumerable <IShred30Contact> ArrangeContacts(IEnumerable <IShred30Contact> shred30Contacts) { if (shred30Contacts.Count() <= 1) { return(shred30Contacts); } foreach (Shred30ContactPair shred30ContactPair in shred30Contacts.GetCollection().GetPairCollection()) { IShred30Contact firstContact = shred30ContactPair.FirstContact; IShred30Contact secondContact = shred30ContactPair.SecondContact; if (firstContact.IsDrop || secondContact.IsDrop) { continue; } secondContact.StartSide = firstContact.GetEndSide(); } return(shred30Contacts); }
/// <summary>Determines whether [is instace of contact unique] [the specified shred30 contacts].</summary> /// <param name="shred30Contacts">The shred30 contacts.</param> /// <param name="shred30Contact">The shred30 contact.</param> public bool IsInstaceOfContactUnique(IEnumerable <IShred30Contact> shred30Contacts, IShred30Contact shred30Contact) { return(this .GetUniqueContacts(shred30Contacts) .Any(uniqueContact => uniqueContact.UniqueId == shred30Contact.UniqueId)); }
public SameSideVariantMismatchException(IShred30Contact shred30Contact) : base(GetExceptionMessage(shred30Contact)) { }
public NotAllTricksSpecifySidesException(IShred30Contact shred30Contact) : base(GetExceptionMessage(shred30Contact)) { }
private static string GetExceptionMessage(IShred30Contact shred30Contact) { return(string.Format("Could not figure out side for trick '{0}'", shred30Contact.Name)); }
/// <summary>Gets the adds for a single contact.</summary> /// <param name="shred30Contact">The shred30 contact.</param> public int GetAdds(IShred30Contact shred30Contact) { return(shred30Contact.Adds); }
public TrickAfterDropDoesNotSpecifySideException(IShred30Contact shred30Contact) : base(GetExceptionMessage(shred30Contact)) { }
private static string GetExceptionMessage(IShred30Contact shred30Contact) { return(string.Format("'{0}' must specify a starting side because it comes after a drop.", shred30Contact.Name)); }