1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace MISTBowl_Brackets
- {
- public static class Matches
- {
- static readonly Hashtable matches = new Hashtable(0);
- public static void AddMatch(params Team[] teams)
- {
- try
- {
- if (teams.Length < 2)
- throw new ArgumentOutOfRangeException();
- foreach (List<Team> teamPair in Combinations.GetAllCombinations(teams, 2))
- {
- for (int i = 0; i < 2; i++)
- {
- if (matches[teams[i].teamId + "v" + teams[1 - i].teamId] == null)
- matches.Add(teams[i].teamId + "v" + teams[1 - i].teamId, 1);
- else
- matches[teams[i].teamId + "v" + teams[1 - i].teamId] = (int)matches[teams[i].teamId + "v" + teams[1 - i].teamId] + 1;
- }
- }
- }
- catch (Exception e)
- {
- Traceback.Write("At void AddMatch(Team, params Team[]) (class Matches):");
- throw e;
- }
- }
- public static int GetMatchCount(Team team1, Team opposition)
- {
- try
- {
- object count = matches[team1.teamId + "v" + opposition.teamId];
- return count == null ? (int)(matches[team1.teamId + "v" + opposition.teamId] = 0) : (int)count;
- }
- catch (Exception e)
- {
- Traceback.Write("At int GetMatchCount(string, string) (class Matches):");
- throw e;
- }
- }
- }
- }
|