public decimal Reserch(string heroName) { var wins = 0m; var battles = 0m; var heroes = Factory.GetAllHeroes().ToList(); var heroToAnalyze = heroes.First(h => h.HeroName == heroName); foreach (var currentHero in heroes) { if (currentHero == heroToAnalyze) { continue; } battles++; var winner = FightAlgorithm.Fight(heroToAnalyze, currentHero, Arena); Console.WriteLine($"{heroToAnalyze.HeroName} fights {currentHero.HeroName} - Winner is {winner.HeroName}!"); if (winner == heroToAnalyze) { wins++; } } return(wins / battles); }
public SuperHero Fight(SuperHero hero1, SuperHero hero2, int numberOfFights) { var hero1Wins = 0; for (int i = 0; i < numberOfFights; i++) { var winner = FightAlgorithm.Fight(hero1, hero2, Arena); hero1Wins += (winner == hero1) ? 1 : -1; } return((hero1Wins > 0) ? hero1 : hero2); }