//Checks all Files on runtime private static void File_Check() { if (!Directory.Exists("Files/")) { Directory.CreateDirectory("Files/"); } if (!File.Exists("Files/auth.json")) { File.Create("Files/auth.json"); auth_Exists = false; } if (!File.Exists(CommandFunctions.linkPath)) { File.Create(CommandFunctions.linkPath).Close(); } else { CommandFunctions.UpdateLinks(File.ReadAllLines("Files/Links.txt").ToList()); } if (!File.Exists(CommandFunctions.usercommandsPath)) { File.Create(CommandFunctions.usercommandsPath).Close(); } if (!File.Exists(CommandFunctions.usermessagesPath)) { File.Create(CommandFunctions.usermessagesPath).Close(); } }
private void bd_OnExecute(NameValueMap Context) { // Link button clicks to their respective commands. switch (bd.InternalName) { case "my_first_button": CommandFunctions.RunAnExe(); return; case "my_second_button": CommandFunctions.PopupMessage(); return; case "close_doc_button": CommandFunctions.CloseDocument(); return; case "export_dxf_button": CommandFunctions.ExportDxf(); return; default: return; } }
public void Place_XYvalueInRange_ReturntTrue() { var commandFunctions = new CommandFunctions(); var x = 3; var y = 0; var direction = EnumFaces.NORTH; var result = commandFunctions.Place(x, y, direction); Assert.IsTrue(result); }
public void Place_XYvaluesOutOfRange_ReturnFalse() { var commandFunctions = new CommandFunctions(); var x = 5; var y = 0; var direction = EnumFaces.NORTH; var result = commandFunctions.Place(x, y, direction); Assert.IsFalse(result); }
public void Turn_LeftTurnWithNorthFace_ReurnWest() { //Arrange var commandFunctions = new CommandFunctions(); var expectedValue = EnumFaces.WEST; //Act commandFunctions.Turn(EnumFaces.NORTH, EnumTurn.LEFT); //Assert Assert.AreEqual(commandFunctions.CurrentFace, expectedValue); }
public async Task AddLink(string link) { string linktest = link.Substring(0, 5); if (linktest.ToLower() != "https") { await ReplyAsync("Please provide a link with https at the beginning"); } int tmp = CommandFunctions.AddLink(link); await ReplyAsync($"Link added successfully and is #{tmp}"); }
//Command Handler private async Task HandleCommandAsync(SocketMessage arg) { //Stores user message and initilizes message position SocketUserMessage message = arg as SocketUserMessage; int argPos = 0; IGuildChannel bots; if (message == null) { return; } //checks to see if the user is a bot else //Checks for prefix or specified passthrough commands if (message.HasStringPrefix("!", ref argPos) || message.Content.ToLower() == "help" || message.Content.ToLower() == "linking" || message.Content.ToLower() == "calculator" || message.Content.ToLower() == "blackjack" || message.Content.ToLower() == "k") { //Saves user Input to a debug file for later inspection CommandFunctions.UserCommand(message); if (message.Author.IsBot) { return; } //generates an object from the user message SocketCommandContext context = new SocketCommandContext(_client, message); //Attempts to run the command and outputs accordingly IResult result = await _commands.ExecuteAsync(context, argPos, _services); if (!result.IsSuccess) { Console.WriteLine(result.ErrorReason); await message.Channel.SendMessageAsync(result.ErrorReason); } if (result.Error.Equals(CommandError.UnmetPrecondition)) { await message.Channel.SendMessageAsync(result.ErrorReason); } } //if something fails the Prefix check it just returns else { if (!message.Author.IsBot) { CommandFunctions.UserMessages(message); } return; } }
public void Move_WithNorthDirectionAndInValidValue_ReturnTrue() { var commandFunctions = new CommandFunctions { XValue = 1, YValue = 4, CurrentFace = EnumFaces.NORTH }; var expectedValue = 4; commandFunctions.Move(); Assert.AreEqual(expectedValue, commandFunctions.YValue); }
/// <summary> /// 痉挛复位 /// </summary> /// <param name="Pos">复位点位置</param> /// <param name="Speed">复位速度</param> /// <param name="Deviation">误差</param> /// <returns></returns> IEnumerator WaitForSpasmReset(Vector2 Pos, int Speed, int Deviation) { //如果有痉挛,清除痉挛 if (CommandFunctions.IsCaution) { DynaLinkHS.CmdClearAlm(); } float waittime = 0; do { yield return(new WaitForSeconds(0.5f)); waittime += 0.5f; DynaLinkHS.CmdClearAlm(); }while (CommandFunctions.IsCaution && waittime <= 2f); if (waittime > 2) { Debug.Log("清除痉挛失败"); CommandFunctions.spasmState = CommandFunctions.SpasmState.Recovering; yield break; } DynaLinkHS.CmdServoOff(); Ienumerator = CommandFunctions.WaitForResetting(Pos, Speed, Deviation); //等待复位到上一个点 yield return(StartCoroutine(Ienumerator)); //如果痉挛复位中出现断开连接或者急停,停止复位,并把状态重新切换为在痉挛复位阶段 if (CommandFunctions.IsEmrgencyStop || !CommandFunctions.IsConnected || CommandFunctions.IsCaution) { Debug.Log("出现急停或者断开连接,ResettingFailed"); //把状态重新切换为在痉挛复位阶段 CommandFunctions.spasmState = CommandFunctions.SpasmState.Recovering; yield break; } if (CommandFunctions.IsFault) { if (CommandFunctions.IsCaution) { DynaLinkHS.CmdClearAlm(); } } Debug.Log("痉挛复位完成"); //复位完成,痉挛处理过程结束,切换标志位 ControlSpasmAgain = false; //CommandFunctions.IsSpasmFinished = true; CommandFunctions.spasmState = CommandFunctions.SpasmState.NoSpasm; }
public async Task DeleteLink(int input) { if (input == 0) { input = 1; } if (input > CommandFunctions.LinksPub.Count) { await ReplyAsync($"Your index exceeds the size of the list, the list is currently: {input}" + "\nLinks long"); return; } CommandFunctions.RemoveLink(input - 1); await ReplyAsync("Link removed from list!"); }
/// <summary> /// 游戏结束后复位 /// </summary> /// <param name="Pos">复位点位置</param> /// <param name="Speed">复位速度</param> /// <param name="Deviation">误差</param> /// <returns></returns> IEnumerator WaitForEndReset(Vector2 Pos, int Speed, int Deviation) { //开始等待复位完成 yield return(StartCoroutine(CommandFunctions.WaitForResetting(Pos, Speed, Deviation))); //如果是出现断开连接或者急停或者痉挛,停止复位,等故障清除后重新复位 if (CommandFunctions.IsEmrgencyStop || !CommandFunctions.IsConnected || CommandFunctions.IsCaution || CommandFunctions.IsPause) { Debug.Log("出现急停或者断开连接,ResettingFailed"); CommandFunctions.resettingState = CommandFunctions.ResettingState.EndResetting; yield break; } //复位结束,改变游戏结束复位标志位。 Debug.Log("ResettingFinished"); CommandFunctions.resettingState = CommandFunctions.ResettingState.ResetFinshed; CommandFunctions.IsInReset = false; CommandFunctions.IsResetEndFinished = true; MainCore.Instance.IsGaming = false; }
IEnumerator PassiveMoveToRespawnLoc() { while (DynaLinkHS.MotionInProcess) { Debug.LogWarning("<color=orange>Motion in process! Waiting one frame!</color>"); yield return("Wait for one frame"); } Vector2 targetVec = MachinePara.ResetVect; CommandFunctions.InitializeStartReset(targetVec, 150000, 300); Debug.Log(string.Format("<color=cyan>PassiveMoveTo:</color> ({0}, {1})", (int)targetVec.x, (int)targetVec.y)); do { yield return(new WaitForSeconds(1f)); } while (!CommandFunctions.IsResetStartFinished || DynaLinkHS.MotionInProcess); CommandFunctions.IsResetStartFinished = false; GameStart.Instance.OpenOrCloseMessagePage(false, HiddenObjectPage.ResettingPage); Debug.Log("<color=yellow>End resetting!</color>"); yield return("End resetting!"); }
private void MySecondButton_OnExecute(NameValueMap Context) { CommandFunctions.PopupMessage(); }
/// <summary> /// Called on Update /// </summary> void MonitorMachineStatus() { if (DiagnosticStatus.MotStatus.Caution && !_isbool) { OpenUIForm("Spasm"); _isCaution = true; //CommandFunctions.SpasmRecover(new Vector2(81500, 35600), 150000, 300, 3, 60); Vector2 rePoint = new Vector2(); if (_canStartGame) { rePoint.x = Mathf.CeilToInt(_lastPos.x / MachinePara.WidthScale); rePoint.y = Mathf.CeilToInt(_lastPos.y / MachinePara.HeightScale); } else { rePoint = MachinePara.ResetVect; } CommandFunctions.SpasmRecover(rePoint, 150000, 300, 3, 60); _isbool = true; } if (CommandFunctions.IsSpasmFinished) { Debug.LogWarning("<color=orange>" + CommandFunctions.IsInReset + "</color>"); if (CommandFunctions.IsInReset) { CommandFunctions.RestartReset(); } //else //{ // if (GlobalApplication.CanRecord) // SendMachineCmd(); //} CommandFunctions.IsSpasmFinished = false; _isbool = false; _isCaution = false; } //if (CommandFunctions.IsSpasmAgain) //{ // Debug.Log("二次痉挛"); // CommandFunctions.SpasmAgainRecover(); // CommandFunctions.IsSpasmAgain = false; //} if (!CommandFunctions.IsConnected || DynaLinkHS.EMstop || _isCaution) { GlobalApplication.IsPause = true; _canSendCmd = true; } else { if (!_isGameStop) { GlobalApplication.IsPause = false; } } if (_canSendCmd && _canStartGame && !_isCaution && CommandFunctions.IsConnected && !DynaLinkHS.EMstop) { if (_isGameStop) { DynaLinkHS.CmdServoOn(); } else { SendMachineCmd(); } _canSendCmd = false; } }
private void CloseDocButton_OnExecute(NameValueMap Context) { CommandFunctions.CloseDocument(); }
public async Task Roll(int dice_size = 6) { await ReplyAsync($"You rolled a {CommandFunctions.DiceRoll(dice_size + 1)}"); }
// Link button clicks to their respective commands. private void MyFirstButton_OnExecute(NameValueMap Context) { CommandFunctions.RunAnExe(); }