public SystemEventPacket(EventType eventType, string message, Connection client = null) { Client = client; packetType = PacketType.system; this.eventType = eventType; this.message = message; }
public Packet(string verb, string parameter, Connection client) { Client = client; packetType = PacketType.verb; this.verb = verb; this.parameter = parameter; }
public string DontKnowHow(string value, Connection player) { string response = string.Empty; if (!player.ResponseStack.Any()) { Responses.Shuffle(); foreach (string item in Responses) { player.ResponseStack.Push(item); } } response = player.ResponseStack.Pop(); string command = " \"".Ansi(Style.white) + value + "\"".Ansi(Style.white, Style.yellow); response = response.Replace("%%", command).Ansi(Style.yellow).NewLine(); return response; }
private Packet Parse(string message, Connection player) { Packet packet = new Packet(string.Empty, string.Empty, player); message = message.TrimStart(' '); message = message.StripExtraSpaces(); if (message.FirstChar() == '\'') { message = message.Remove(0, 1).Insert(0, "say ").StripExtraSpaces(); packet.known = true; } else { bool error = false; if (message.FirstWordIsSingleChar()) { char ch = message.FirstChar(); switch (ch) { case 'l': message = message.Remove(0, 1).Insert(0, "look"); packet.known = true; break; case 'i': message = message.Remove(0, 1).Insert(0, "inventory"); packet.known = true; break; case '?': message = message.Remove(0, 1).Insert(0, "help"); packet.known = true; break; default: packet.parameter = packet.verb; packet.verb = ch.ToString(); error = true; break; } } if (error) return packet; } packet.verb = message.FirstWord(); packet.parameter = message.StripFirstWord(); if (Commands.IsCommand(packet.verb)) { packet.known = true; } if (!packet.known) { string verb = packet.verb; packet = Function.ContainsExit(player.Room.Exits.ToArray(), packet); if (packet.verb != verb) { packet.known = true; } } return packet; }
void Players_OnPlayerRemoved(object myObject, Connection player, string message = "") { // throw new NotImplementedException("Player removed"); }
private void SendCommand(Connection player, string command) { Task HandleMessage = new Task(() => player.Commands(player, command)); HandleMessage.Start(); }
private void Players_OnPlayerRemoved(object myObject, Connection player, string message = "") { foreach (Connection Player in Players) { Player.Send(player.Name.Ansi(Style.white) + " goes to the " + message + ".".NewLine()); } }
private void Players_OnPlayerAdded(object myObject, Connection player, string message = "") { string name = player.Name; if (message == "") message = " just arrived."; foreach (Connection client in Players) { if (client != player) client.Send(player.Name.Ansi(Style.white) + message.Ansi(Style.white).NewLine()); else SendCommand(player, "look"); } }
public void RemovePlayer(Connection player, string message) { Players.Remove(player.Name, message); }
public void AddPlayer(Connection player) { Players.Add(player); player.Room = this; }
public void SwapLoginForPlayer(Connection connection) { connection.Room = TheVoid; Players.Add(connection); Logins.Remove(connection); if (!File.Exists(PlayersDirectory + "\\" + connection.Name + "test.xml")) { connection.Room = Common.Settings.TheVoid; return; } else { connection.LoadXml(PlayersDirectory + "\\" + connection.Name + "test.xml"); } connection.StartPlayer(); }
public PlayerDispatcher(Connection client) { Client = client; Commands = new Dispatch(Client); }
public Dispatch(Connection client) { Client = client; LoadCommands(); }
public static void Emote(Connection client, string emoting) { }