private static void MoveClick(object sender, EventArgs e) { var p = Game.Instance.ActivePlayer; p.Character.EditCharProperty(CharacterAttribute.CurrentEnergy, EditCharPropertyChangeType.Subtract, 1); p.CurrentLocation = ((LocationSelectionButton)sender).LocationNumber; _MainForm.Instance.LocationCardsPanel.AddMissingMapTiles(); DisableMoveMode(); ActionFinished.Invoke(); }
public virtual void Finish() { FinishTime = null; ActionFinished?.Invoke(this, this); }
internal void on_ActionFinished(Pawn ControlledPawn, byte WithResult) => ActionFinished?.Invoke(ControlledPawn, WithResult);
static void PassClick(object sender, EventArgs e) { Game.Instance.PlayerPassed(); ActionFinished.Invoke(); }
static void ExplorationActionClick(object sender, EventArgs e) { ExplorationManager.StartExploration(Game.Instance.ActivePlayer.CurrentLocation); ActionFinished.Invoke(); }
static void LocationActionClick(object sender, EventArgs e) { CombatManager.Start(); ActionFinished.Invoke(); }
public override async Task <NodeActionFinishedArgs> InvokeNodeFunction(NodeActionTriggerTypes actionType, string[] otherData, string altFunction = "") { if (!(bool)IsActivated) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_ACTIVATED", data = $"MQTT Publish Node - {Name} - Node is not activated. You cannot invoke action!" })); } if (actionType != ActualTriggerType) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_INVOKED", data = $"MQTT Publish Node - {Name} - Node is not set to this {Enum.GetName(actionType)} of trigger. It is set to {Enum.GetName(ActualTriggerType)}!" })); } JSResultDto jsRes = new JSResultDto(); // Node Custom JavaScript call if (ParsedParams.IsScriptActive) { if (!string.IsNullOrEmpty(ParsedParams.Script) && (otherData.Length > 0)) { if (!string.IsNullOrEmpty(altFunction)) { jsRes = JSScriptHelper.RunNodeJsScript(altFunction, ParsedParams.ScriptParametersList, otherData); } jsRes = JSScriptHelper.RunNodeJsScript(ParsedParams.Script, ParsedParams.ScriptParametersList, otherData); if (!jsRes.done) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_INVOKED", data = $"MQTT Publish Node - {Name} - Custom JS script runned with error {jsRes.payload}!" })); } } } try { var p = JsonConvert.DeserializeObject <MQTTNodeParams>(ParsedParams.Parameters); if (p != null) { if (string.IsNullOrEmpty(p.Topic)) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_INVOKED", data = $"MQTT Publish Node - {Name} - Topic is not set!" })); } if (ParsedParams.TimeDelay > 0) { await Task.Delay(ParsedParams.TimeDelay); } var res = string.Empty; if (ParsedParams.Command != null) { var payload = string.Empty; if (ParsedParams.IsScriptActive && !string.IsNullOrEmpty(jsRes.payload)) { payload = jsRes.payload; } else { payload = p.Data; } LastPayload = payload; LastOtherData = otherData; NodeActionRequestTypes type = NodeActionRequestTypes.MQTTPublishNotRetain; if (p.Retain) { type = NodeActionRequestTypes.MQTTPublishRetain; } ActionRequest?.Invoke(this, new NodeActionRequestArgs() { Type = type, Topic = p.Topic, Payload = payload }); } else { res = $"MQTT Publish Node - {Name} - Command cannot be null. Please fill full Topic name!"; log.Warn($"Node {Name} MQTT Publish Node - Command cannot be null. Please fill full Topic name!!"); } ActionFinished?.Invoke(this, new NodeActionFinishedArgs() { result = "OK", data = res }); return(await Task.FromResult(new NodeActionFinishedArgs() { result = "OK", data = res })); } else { log.Warn($"Node {Name} cannot send MQTT Publish. Cannot parse the parameters!"); return(await Task.FromResult(new NodeActionFinishedArgs() { result = "ERROR", data = $"MQTT Publish Node - {Name} - Cannot parse the parameters!" })); } } catch (Exception ex) { log.Error($"Node {Name} cannot send MQTT Publish. ", ex); } return(await Task.FromResult(new NodeActionFinishedArgs() { result = "ERROR", data = "Unexpected error!" })); }
public override async Task <NodeActionFinishedArgs> InvokeNodeFunction(NodeActionTriggerTypes actionType, string[] otherData, string altFunction = "") { if (!(bool)IsActivated) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_ACTIVATED", data = "HTTP API Node - Node is not activated. You cannot invoke action!" })); } if (actionType != ActualTriggerType) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_INVOKED", data = $"HTTP API Node - Node is not set to this {Enum.GetName(actionType)} of trigger. It is set to {Enum.GetName(ActualTriggerType)}!" })); } JSResultDto jsRes = new JSResultDto(); // Node Custom JavaScript call if (ParsedParams.IsScriptActive) { if (!string.IsNullOrEmpty(ParsedParams.Script) && (otherData.Length > 0)) { if (!string.IsNullOrEmpty(altFunction)) { jsRes = JSScriptHelper.RunNodeJsScript(altFunction, ParsedParams.ScriptParametersList, otherData); } jsRes = JSScriptHelper.RunNodeJsScript(ParsedParams.Script, ParsedParams.ScriptParametersList, otherData); if (!jsRes.done) { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "NOT_INVOKED", data = $"HTTP API Node - Custom JS script runned with error {jsRes.payload}!" })); } } } try { var p = JsonConvert.DeserializeObject <HTTPApiRequestNodeParams>(ParsedParams.Parameters); if (p != null) { var url = string.Empty; if (!p.UseHttps) { url = $"http://{p.Host}"; } else { url = $"https://{p.Host}"; } if (!string.IsNullOrEmpty(p.Port)) { url += $":{p.Port}/"; } else { url += "/"; } if (!string.IsNullOrEmpty(p.ApiCommand)) { url += p.ApiCommand; } if (ParsedParams.TimeDelay > 0) { await Task.Delay(ParsedParams.TimeDelay); } var payload = string.Empty; if (ParsedParams.IsScriptActive && !string.IsNullOrEmpty(jsRes.payload)) { payload = jsRes.payload; } else { payload = p.Data; } LastPayload = payload; LastOtherData = otherData; var res = string.Empty; if (ParsedParams.Command != null) { switch (ParsedParams.Command) { case "GET": res = await SendGETRequest(url, payload); break; case "PUT": res = await SendPURequest(url, payload); break; case "": res = "HTTP API Node - Command cannot be empty. Please fill GET, POST or PUT!"; log.Warn($"Node {Name} cannot send HTTP Request. Command is empty. Please fill GET, POST or PUT!"); break; } } else { res = "HTTP API Node - Command cannot be null. Please fill GET, POST or PUT!"; log.Warn($"Node {Name} cannot send HTTP Request. Command is null. Please fill GET, POST or PUT!"); } ActionFinished?.Invoke(this, new NodeActionFinishedArgs() { result = "OK", data = res }); return(await Task.FromResult(new NodeActionFinishedArgs() { result = "OK", data = res })); } else { return(await Task.FromResult(new NodeActionFinishedArgs() { result = "ERROR", data = "HTTP API Node - Cannot parse the parameters!" })); log.Warn($"Node {Name} cannot send HTTP Request. Cannot parse the parameters!"); } } catch (Exception ex) { log.Error($"Node {Name} cannot send HTTP Request. ", ex); } return(await Task.FromResult(new NodeActionFinishedArgs() { result = "ERROR", data = "Unexpected error!" })); }