Here's the high level pseudocode:
- Start with the final match and work back along the player entry locations until all matches have been processed into a list (vettedMatchList) and all the players are in another list (competitorList). This also sets the match layer (how deep into the tournament that this match represents)
- Check to make sure that all TournamentTemplateMatches for this TournamentTemplate have been accounted for.
- Check to make sure that all competitors have an entry into the tournament
- Build a list (noExitMatchList) for each match that 2nd place continues in the tournament.This is combined with the match layer to evaluate final exit position for 2nd placegetters that do NOT continue.
- Mark the tournament as valid and update the database with match layers & exit positions.