public Competition CreateCompetition(AssemblyFile[] files, IEnumerable<TeamInfo> teams, IEnumerable<TeamInfo> networkTeams) { DynamicAssemblyTypeFinder dynamicAssemblyTypeFinder = new DynamicAssemblyTypeFinder(); dynamicAssemblyTypeFinder.AddAll(files); IGame game = dynamicAssemblyTypeFinder.Create<IGame>().Single(); Competition competition = new Competition(game); IEnumerable<string> teamNames = teams.Select(team => team.Name); foreach (IBotFactory botFactory in dynamicAssemblyTypeFinder.Create<IBotFactory>()) { string teamName = Path.GetFileNameWithoutExtension(botFactory.GetType().Assembly.Location); if (teamNames.Contains(teamName)) { competition.AddPlayer(new BotPlayer(teamName, botFactory.CreateBot())); } } INetworkBotFactory factory = dynamicAssemblyTypeFinder.Create<INetworkBotFactory>().Single(); foreach (TeamInfo team in networkTeams) { competition.AddPlayer(new BotPlayer(team.Name, factory.CreateBot(team.Url))); } return competition; }
public Competition CreateCompetition(AssemblyFile[] files) { DynamicAssemblyTypeFinder dynamicAssemblyTypeFinder = new DynamicAssemblyTypeFinder(); dynamicAssemblyTypeFinder.AddAll(files); IGame game = new RockPaperScissorsPro.CompeteGameWrapper(); Competition competition = new Competition(game); IEnumerable<IBotFactory> botFactoryList = dynamicAssemblyTypeFinder.Create<IBotFactory>(); foreach (IBotFactory botFactory in botFactoryList) { //if unable to create botFactory, skip adding it to the list if (botFactory != null) { string teamName = Team.ConvertFileToTeamName(botFactory.GetType().Assembly.Location); competition.AddPlayer(new BotPlayer(teamName, null, botFactory)); } } // look for any players that were downloaded but not in competition. make sure they // get a bot that forfeits foreach (AssemblyFile f in files) { string teamName = Team.ConvertFileToTeamName(f.Path); if (!competition.ContainsPlayer(teamName)) { competition.AddPlayer(new BotPlayer(teamName, null, null)); } } return competition; }
public StagingArea(IEnumerable<AssemblyFile> files) { _root = Path.Combine(@"E:\Compete\Staging", Guid.NewGuid().ToString("D")); DirectoryHelpers.CreateIfNecessary(_root); AppDomainHelper.CopyDependencies(_root); foreach (AssemblyFile file in files) { var stagedFile = new AssemblyFile(Path.Combine(_root, Path.GetFileName(file.Path))); _stagedAssemblies.Add(stagedFile); File.Copy(file.Path, stagedFile.Path, true); } }
public StagingArea(IEnumerable<AssemblyFile> files = null) { _root = Path.Combine(RockPaperAzure.AzureHelper.GetLocalFolder() + @"staging", Guid.NewGuid().ToString("D")); DirectoryHelpers.CreateIfNecessary(_root); AppDomainHelper.CopyDependencies(_root); if (files != null) { foreach (AssemblyFile file in files) { var stagedFile = new AssemblyFile(Path.Combine(_root, Path.GetFileName(file.Path))); _stagedAssemblies.Add(stagedFile); File.Copy(file.Path, stagedFile.Path, true); } } }
public RoundParameters(AssemblyFile[] files, IEnumerable<TeamInfo> teams, IEnumerable<TeamInfo> networkTeams) { AssemblyFiles = files; Teams = teams.ToList(); NetworkTeams = networkTeams.ToList(); }
public bool Equals(AssemblyFile obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return Equals(obj._path, _path); }
public RoundParameters(AssemblyFile[] files, string[] teamNames) { AssemblyFiles = files; TeamNames = teamNames; }