//differentiates the same way humans do, with visual shortcuts static string differentiate(string inString, string expression) { if (inString == "+" || inString == "-") { Logger.LogToConsole("0"); return(inString); } Regex numberPolyRegex = new Regex(@"[0-9]+x\^[0-9]+"); //nx^c Regex polyRegex = new Regex(@"x\^[0-9]+"); //x^n Regex linearRegex = new Regex(@"[0-9]+x"); //nx if (numberPolyRegex.IsMatch(expression)) { Logger.LogToConsole("1"); int coefficient = Convert.ToInt32(inString.Substring(0, inString.IndexOf("x"))); int exp = Convert.ToInt32(inString.Substring(inString.IndexOf("x") + 2)); return(exp * coefficient + "x^" + (exp - 1)); } else if (polyRegex.IsMatch(expression)) { Logger.LogToConsole("2"); int exp = Convert.ToInt32(inString.Substring(2)); return(exp + "x^" + (exp - 1)); } else if (linearRegex.IsMatch(expression)) { Logger.LogToConsole("3"); Logger.LogToConsole(inString.Length.ToString()); Logger.LogToConsole(inString.IndexOf("x").ToString()); return(inString.Substring(0, inString.IndexOf("x"))); } return("0"); }
/// <summary> /// Main IO loop, handles the networking of the bot. /// </summary> private void NetworkLoop() { if (isMoving) { if (followTarget != null) { Player p = Server.FindPlayers(followTarget.Name, false)[0]; Logger.LogToConsole("Chaning pos to " + p.Name + " at " + p.Position.ToString()); NewPosition = p.Position; beganMoving = false; } //move bot 1 block after every period if (timeCheck.ElapsedMilliseconds > period) { Move(); timeCheck.Restart(); } } //If bot is not flying, drop down to nearest solid block if (!isFlying) { //Drop(); } }
internal void MessageNow([NotNull] string message, [NotNull] params object[] args) { if (message == null) { throw new ArgumentNullException("message"); } if (args == null) { throw new ArgumentNullException("args"); } if (IsDeaf) { return; } if (args.Length > 0) { message = String.Format(message, args); } if (this == Console) { Logger.LogToConsole(message); } else { if (Thread.CurrentThread != ioThread) { throw new InvalidOperationException("SendNow may only be called from player's own thread."); } foreach (Packet p in LineWrapper.Wrap(ChatColor.Sys + message)) { SendNow(p); } } }
public void MessagePrefixed([NotNull] string prefix, [NotNull] string message, [NotNull] params object[] formatArgs) { if (prefix == null) { throw new ArgumentNullException("prefix"); } if (message == null) { throw new ArgumentNullException("message"); } if (formatArgs == null) { throw new ArgumentNullException("formatArgs"); } if (formatArgs.Length > 0) { message = String.Format(message, formatArgs); } if (this == Console) { Logger.LogToConsole(message); } else { foreach (Packet p in LineWrapper.WrapPrefixed(prefix, message)) { Send(p); } } }
public void Message([NotNull] string message, [NotNull] params object[] formatArgs) { if (message == null) { throw new ArgumentNullException("message"); } if (formatArgs == null) { throw new ArgumentNullException("formatArgs"); } if (formatArgs.Length > 0) { message = String.Format(message, formatArgs); } if (IsSuper) { Logger.LogToConsole(message); } else { foreach (Packet p in LineWrapper.Wrap(ChatColor.Sys + message)) { Send(p); } } }
// Sends a message directly (synchronously). Should only be used from Session.IoThread internal void MessageNow(string message, params object[] args) { if (message == null) { throw new ArgumentNullException("message"); } if (args.Length > 0) { message = String.Format(message, args); } if (Session == null) { Logger.LogToConsole(message); } else { foreach (Packet p in PacketWriter.MakeWrappedMessage(">", Color.Sys + message, false)) { Session.Send(p); } } }
// Queues a system message with a custom color public void MessagePrefixed(string prefix, string message, params object[] args) { if (message == null) { throw new ArgumentNullException("message"); } if (args.Length > 0) { message = String.Format(message, args); } if (this == Console) { Logger.LogToConsole(message); } else { foreach (Packet p in PacketWriter.MakeWrappedMessage(prefix, Color.Sys + message, false)) { Session.Send(p); } } }