public string GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); var HtmlReportGenerator = new HtmlRenderer.HtmlReportGenerator(comparisonResults); return(HtmlReportGenerator.CreateHtmlReport()); }
public string GetResponse(WebService service) { StrategyComparisonResults comparisonResults = service.GetResultsFor(this); var HtmlReportGenerator = new HtmlRenderer.HtmlReportGenerator(comparisonResults); return HtmlReportGenerator.CreateHtmlReport(); }
private void SimulateGameButtonClick(object sender, RoutedEventArgs e) { if (!CanSimulateStrategies()) { return; } var uiScheduler = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext(); Dominion.Strategy.Description.StrategyDescription player1Descr = this.appDataContext.player1Strategy.ConvertToDominionStrategy(); Dominion.Strategy.Description.StrategyDescription player2Descr = this.appDataContext.player2Strategy.ConvertToDominionStrategy(); System.Threading.Tasks.Task <StrategyUIResults> .Factory.StartNew(() => { string player1nameAppend, player2nameAppend; GetStrategyNames(player1Descr, player2Descr, out player1nameAppend, out player2nameAppend); string player1Name = "Player 1: " + player1nameAppend; string player2Name = "Player 2: " + player2nameAppend; var playerActions = new Dominion.Strategy.PlayerAction[] { player1Descr.ToPlayerAction(player1Name), player2Descr.ToPlayerAction(player2Name) }; var builder = new Dominion.GameConfigBuilder(); Dominion.Strategy.PlayerAction.SetKingdomCards(builder, playerActions[0], playerActions[1]); builder.useColonyAndPlatinum = false; builder.useShelters = false; builder.CardSplit = Dominion.StartingCardSplit.Split43; bool rotateWhoStartsFirst = true; int numberOfGames = 1000; Dominion.GameConfig gameConfig = builder.ToGameConfig(); var strategyComparison = new Dominion.Data.StrategyComparison(playerActions, gameConfig, rotateWhoStartsFirst, numberOfGames); Dominion.Data.StrategyComparisonResults strategyComparisonResults = strategyComparison.ComparePlayers(); var htmlGenerator = new HtmlRenderer.HtmlReportGenerator(strategyComparisonResults); var stringWriter = new System.IO.StringWriter(); var textWriter = new Dominion.IndentedTextWriter(stringWriter); htmlGenerator.CreateHtmlReport(textWriter); stringWriter.Flush(); string resultHtml = stringWriter.GetStringBuilder().ToString(); return(new StrategyUIResults() { StrategyReport = resultHtml, Player1Name = player1Name, Player2Name = player2Name, Player1WinPercent = strategyComparisonResults.PlayerWinPercent(0), Player2WinPercent = strategyComparisonResults.PlayerWinPercent(1), TiePercent = strategyComparisonResults.TiePercent, }); }).ContinueWith(async(continuation) => { var results = (StrategyUIResults )continuation.Result; this.appDataContext.StrategyReport.Value = results.StrategyReport; this.appDataContext.Player1Name.Value = results.Player1Name; this.appDataContext.Player2Name.Value = results.Player2Name; this.appDataContext.Player1WinPercent.Value = results.Player1WinPercent; this.appDataContext.Player2WinPercent.Value = results.Player2WinPercent; this.appDataContext.TiePercent.Value = results.TiePercent; this.appDataContext.StrategyResultsAvailable.Value = true; }, uiScheduler); }