public FifaLadderNode ComputeWorldCup() { while (TeamCollection.Any()) { var tmpNode = new FifaLadderNode(); tmpNode.TeamA = RandTeam(); tmpNode.TeamB = RandTeam(); tmpNode.PlayMatch(); Root.LadderNodes.Add(tmpNode); } while (Root.LadderNodes.Count > 1) { var tmpRoot = new FifaLadderNode(); for (int i = 0; i < Root.LadderNodes.Count; i += 2) { var tmpNode = new FifaLadderNode(); tmpNode.TeamA = Root.LadderNodes[i].WinningTeam; tmpNode.LadderNodes.Add(Root.LadderNodes[i]); tmpNode.TeamB = Root.LadderNodes[i + 1].WinningTeam; tmpNode.LadderNodes.Add(Root.LadderNodes[i + 1]); tmpNode.PlayMatch(); tmpRoot.LadderNodes.Add(tmpNode); } Root = tmpRoot.Clone() as FifaLadderNode; } return(Root.LadderNodes[0]); }
public FifaWorldCupRepository() { Root = new FifaLadderNode(); }