public ExecutionInfo ExecuteAction(string executionId, ExecutionAction action, string name, List <VariableInfo> variables = null) { string url = string.Format("{0}/{1}", UrlConstants.EXECUTION, executionId); JObject json = new JObject(); switch (action) { case ExecutionAction.Signal: json.Add("action", "signal"); break; case ExecutionAction.SignalEventReceived: json.Add("action", "signalEventReceived"); json.Add("signalName", name); if (variables != null) { json.Add("variables", JsonConvert.SerializeObject(variables)); } break; case ExecutionAction.MessageEventReceived: json.Add("action", "messageEventReceived"); json.Add("messageName", name); if (variables != null) { json.Add("variables", JsonConvert.SerializeObject(variables)); } break; } return(ExecuteOperation(url, HttpMethod.PUT, "kermit", "kermit", json.ToString())); }
public void Write(Record[] records, ExecutionAction action, string outputFile) { if (records.Length == 0) { if (action == ExecutionAction.Compare) { Console.WriteLine("No changes detected"); } else { Console.WriteLine("No results to display"); } } else { if (action == ExecutionAction.Compare) { Console.WriteLine("Comparison results: "); foreach (var record in records) { Console.WriteLine($"* {record.TournamentFile} -> {record.Player} changed from {record.ReferenceArchetype.Archetype} to {record.Archetype.Archetype}"); } } else { Console.WriteLine("Detection results: "); foreach (var record in records) { Console.WriteLine($"* {record.TournamentFile} -> {record.Result} {record.Player} ({record.Archetype.Archetype})"); } } } }
public ToolbarButton(string name, string imageName, string taskName, ExecutionAction clickAction) { this.Name = name; this.ClickAction = clickAction; this.Size = new System.Drawing.Size(23, 22); this.ImageTransparentColor = System.Drawing.Color.Magenta; this.DisplayStyle = ToolStripItemDisplayStyle.Image; //this.TextImageRelation = TextImageRelation.ImageBeforeText; this.Text = DomainModel.Application.ResourceManager.GetText("mnu_caption_" + this.Name); this.ToolTipText = DomainModel.Application.ResourceManager.GetText("mnu_tip_" + this.Name); this.RightToLeft = View.LayoutDirection; if (!string.IsNullOrWhiteSpace(imageName)) { this.Image = DomainModel.Application.ResourceManager.GetImage(imageName); } SetVisibility(taskName); this.Click += new EventHandler(OnClick); }
public MenuItem(string name, string imageName, string taskName, ExecutionAction clickAction) { this.ClickAction = clickAction; this.Name = name; this.Text = DomainModel.Application.ResourceManager.GetText("mnu_caption_" + this.Name); this.ToolTipText = DomainModel.Application.ResourceManager.GetText("mnu_tip_" + this.Name); if (!string.IsNullOrWhiteSpace(imageName)) { this.Image = DomainModel.Application.ResourceManager.GetImage(imageName); } this.RightToLeft = View.LayoutDirection; SetVisibility(taskName); this.Click += new EventHandler(OnClick); }
public void Write(Record[] records, ExecutionAction action, string outputFile) { string date = $"{records.Max(t => t.Date).ToString("yyyy_MM_dd")}"; if (String.IsNullOrEmpty(outputFile)) { outputFile = $"mtgo_data_{date}.json"; } if (File.Exists(outputFile)) { File.Delete(outputFile); } File.WriteAllText(outputFile, JsonConvert.SerializeObject(new JsonOutputRoot() { Data = records })); }
public void Write(Record[] records, ExecutionAction action, string outputFile) { StringBuilder csvData = new StringBuilder(); csvData.AppendLine(GetHeader(action == ExecutionAction.Compare)); foreach (var record in records) { csvData.AppendLine(GetLine(record, action == ExecutionAction.Compare)); } string date = $"{records.Max(t => t.Date).ToString("yyyy_MM_dd")}"; if (String.IsNullOrEmpty(outputFile)) { outputFile = $"mtgo_data_{date}.csv"; } if (File.Exists(outputFile)) { File.Delete(outputFile); } File.WriteAllText(outputFile, csvData.ToString()); }
public static void GetTypeOfAction(Models.Action action, Hero player, List <Hero> firstTeam, List <Hero> secondTeam) { if (action.Type == "friendly") { var allyTeam = TargetTeamGetter.GetAllies(player, firstTeam, secondTeam); if (allyTeam.Where(a => a.Health > 0).ToList().Count > 1) { Hero target = ChooseTarget(allyTeam); FriendlyAction.ExecuteAction(action, player, target); } else { Hero target = allyTeam.Where(a => a.Health > 0).First(); FriendlyAction.ExecuteAction(action, player, target); } } else if (action.Type == "agressive") { var enemyTeam = TargetTeamGetter.GetEnemies(player, firstTeam, secondTeam); if (enemyTeam.Where(a => a.Health > 0).ToList().Count > 1) { Hero target = ChooseTarget(enemyTeam); AgressiveAction.ExecuteAction(action, player, target); } else { Hero target = enemyTeam.Where(a => a.Health > 0).First(); AgressiveAction.ExecuteAction(action, player, target); } } else if (action.Type == "passive") { PassiveAction.ExecuteAction(action, player); } else if (action.Type == "buff") { var allyTeam = TargetTeamGetter.GetAllies(player, firstTeam, secondTeam); if (allyTeam.Where(a => a.Health > 0).ToList().Count > 1) { Hero target = ChooseTarget(allyTeam); BuffAction.ExecuteAction(action, player, target); } else { Hero target = allyTeam.Where(a => a.Health > 0).First(); BuffAction.ExecuteAction(action, player, target); } } else if (action.Type == "debuff") { var enemyTeam = TargetTeamGetter.GetEnemies(player, firstTeam, secondTeam); if (enemyTeam.Where(a => a.Health > 0).ToList().Count > 1) { Hero target = ChooseTarget(enemyTeam); DebuffAction.ExecuteAction(action, player, target); } else { Hero target = enemyTeam.Where(a => a.Health > 0).First(); DebuffAction.ExecuteAction(action, player, target); } } else if (action.Type == "execution") { var enemyTeam = TargetTeamGetter.GetEnemies(player, firstTeam, secondTeam); bool isExecuted; Hero target; if (enemyTeam.Where(a => a.Health > 0).ToList().Count > 1) { target = ChooseTarget(enemyTeam); isExecuted = ExecutionAction.ExecuteAction(action, player, target); } else { target = enemyTeam.Where(a => a.Health > 0).First(); isExecuted = ExecutionAction.ExecuteAction(action, player, target); } if (isExecuted) { HeroCooldownReductor.ReduceCooldowns(player); target.TakeDamage(AbilityConstants.ExecutionDamage); var key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Enter) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Constants.GameTitle); Console.WriteLine($"{target.Name} HAS BEEN BRUTALLY EXECUTED!"); Console.WriteLine("-- PRESS ENTER TO CONTINUE TO ACTION MENU TO SELECT A DIFFERENT ACTION --"); key = Console.ReadKey(); } } else { var key = new ConsoleKeyInfo(); while (key.Key != ConsoleKey.Enter) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Constants.GameTitle); Console.WriteLine($"{target.Name}'S HEALTH IS NOT LOW ENOUGH TO BE EXECUTED!"); Console.WriteLine("-- PRESS ENTER TO CONTINUE TO ACTION MENU TO SELECT A DIFFERENT ACTION --"); key = Console.ReadKey(); } Combat.PlayerTurn(player); } } }
public StepAction(String _name, ExecutionAction action) { name = _name; m_action = action; }
public void ApplyOverrides(string[] args) { this.MinOthersPercent = DefaultMinOthersPercent; string formatArgument = GetArgument(args, nameof(Format)).FirstOrDefault(); string referenceFormatArgument = GetArgument(args, nameof(ReferenceFormat)).FirstOrDefault(); string metaArgument = GetArgument(args, nameof(Meta)).FirstOrDefault(); string metaWeekArgument = GetArgument(args, nameof(MetaWeek)).FirstOrDefault(); string[] filterArgument = GetArgument(args, nameof(Filter)); string[] excludeArgument = GetArgument(args, nameof(Exclude)); string archetypeArgument = GetArgument(args, nameof(Archetype)).FirstOrDefault(); string[] cardArgument = GetArgument(args, nameof(Card)); string[] excludeCardArgument = GetArgument(args, nameof(ExcludeCard)); string breakdownArgument = GetArgument(args, nameof(MetaBreakdown)).FirstOrDefault(); string breakdownCountArgument = GetArgument(args, nameof(MetaBreakdownShowCount)).FirstOrDefault(); string decklistsArgument = GetArgument(args, nameof(IncludeDecklists)).FirstOrDefault(); string[] cacheFoldersArgument = GetArgument(args, nameof(TournamentFolder)); string dataFolderArgument = GetArgument(args, nameof(FormatDataFolder)).FirstOrDefault(); string outputFileArgument = GetArgument(args, nameof(OutputFile)).FirstOrDefault(); string maxDecksPerEventArgument = GetArgument(args, nameof(MaxDecksPerEvent)).FirstOrDefault(); string minOthersPercentArgument = GetArgument(args, nameof(MinOthersPercent)).FirstOrDefault(); if (formatArgument != null) { this.Format = formatArgument; } if (referenceFormatArgument != null) { this.ReferenceFormat = referenceFormatArgument; } if (metaArgument != null) { this.Meta = metaArgument; } if (metaWeekArgument != null) { this.MetaWeek = metaWeekArgument; } if (filterArgument.Length > 0) { this.Filter = filterArgument; } if (excludeArgument.Length > 0) { this.Exclude = excludeArgument; } if (archetypeArgument != null) { this.Archetype = archetypeArgument; } if (cardArgument.Length > 0) { this.Card = cardArgument; } if (excludeArgument.Length > 0) { this.ExcludeCard = excludeCardArgument; } if (breakdownArgument != null) { this.MetaBreakdown = (breakdownArgument.ToLowerInvariant() == "true"); } if (breakdownCountArgument != null) { this.MetaBreakdownShowCount = (breakdownCountArgument.ToLowerInvariant() == "true"); } if (decklistsArgument != null) { this.IncludeDecklists = (decklistsArgument.ToLowerInvariant() == "true"); } if (cacheFoldersArgument.Length > 0) { this.TournamentFolder = cacheFoldersArgument; } if (dataFolderArgument != null) { this.FormatDataFolder = dataFolderArgument; } if (outputFileArgument != null) { this.OutputFile = outputFileArgument; } if (maxDecksPerEventArgument != null && Int32.TryParse(maxDecksPerEventArgument, out int parsedMaxDecks)) { this.MaxDecksPerEvent = parsedMaxDecks; } if (minOthersPercentArgument != null && float.TryParse(minOthersPercentArgument, NumberStyles.Any, CultureInfo.InvariantCulture, out float parsedMinOthers)) { this.MinOthersPercent = parsedMinOthers; } ExecutionAction actionArgument = ExecutionAction.NotSpecified; if (args.Length > 1) { Enum.TryParse <ExecutionAction>(args[1], true, out actionArgument); } if (actionArgument != ExecutionAction.NotSpecified) { this.Action = actionArgument; } ExecutionOutput outputArgument = ExecutionOutput.NotSpecified; if (args.Length > 0) { Enum.TryParse <ExecutionOutput>(args[0], true, out outputArgument); } if (outputArgument != ExecutionOutput.NotSpecified) { this.Output = outputArgument; } }