private static LoginFile Parse(string[] args) { LoginFile script = null; foreach(var arg in args) { if (arg.StartsWith("/login:"******":".ToCharArray(), 2).Last(); if (global::System.IO.File.Exists(name)) script = new LoginFile(name); else Console.Out.WriteLine("Script not found"); } else if (arg.StartsWith("/global:")) bool.TryParse(arg.Split(":".ToCharArray(), 2).Last(), out Global); else if (arg.StartsWith("/auth:")) { bool.TryParse(arg.Split(":".ToCharArray(), 2).Last(), out Access.IsFree); Access.IsFree = !Access.IsFree; } else if (arg.StartsWith("/owners:")) Access.Owners.AddRange(arg.Split(":".ToCharArray(), 2).Last().Split(",".ToCharArray())); else if (arg.StartsWith("/password:"******":".ToCharArray(), 2).Last(); else Console.Out.WriteLine("Unknown command"); } if(script == null) Environment.Exit(1); return script; }
private static void Setup(LoginFile script) { lsApi.Connected += (IEnumerable<Model.GameServer> gameServers) => { Model.GameServer gameServer = gameServers .Single(gs => gs.Id == script.GameServer); if (gameServer != null) lsApi.SelectGameServer(gameServer); else throw new KeyNotFoundException(); }; lsApi.ServerSelected += (byte[] loginKey, byte[] gameKey) => { string login = script.Account.Login; int protocol = script.LoginServer.Protocol; gsApi.Connect(lsApi.GameServer, login, loginKey, gameKey, protocol); }; gsApi.Connected += (IEnumerable<Model.Player> characters) => { int? number = null; foreach (var character in characters) if (character.Name == script.Character) number = character.Number; if (number.HasValue) gsApi.SelectCharacter(number.Value); else throw new KeyNotFoundException(); }; gsApi.ChatMessage += (Lineage.Channel channel, string message, string name, Model.Creature author) => { var me = gsApi.World.Me; if(Global || channel == Lineage.Channel.Tell) if (name != me.Name && Access.Allow(name) && message.Trim().StartsWith("/")) Command(message.Trim().Substring(1).ToLower(), name, author); }; gsApi.QuestionAsked += (Lineage.Question question, string name, string value) => { if (Access.Allow(name)) gsApi.QuestionReply(question, Lineage.Answer.Yes); }; gsApi.LoggedOut += () => { Environment.Exit(0); }; gsApi.EnterWorld += () => { ConsoleThread.Start(); }; lsApi.Connect(script.LoginServer, script.Account); }
private static LoginFile Parse(string[] args) { LoginFile script = null; foreach (var arg in args) { if (arg.StartsWith("/login:"******":".ToCharArray(), 2).Last(); if (global::System.IO.File.Exists(name)) { script = new LoginFile(name); } else { Console.Out.WriteLine("Script not found"); } } else if (arg.StartsWith("/global:")) { bool.TryParse(arg.Split(":".ToCharArray(), 2).Last(), out Global); } else if (arg.StartsWith("/auth:")) { bool.TryParse(arg.Split(":".ToCharArray(), 2).Last(), out Access.IsFree); Access.IsFree = !Access.IsFree; } else if (arg.StartsWith("/owners:")) { Access.Owners.AddRange(arg.Split(":".ToCharArray(), 2).Last().Split(",".ToCharArray())); } else if (arg.StartsWith("/password:"******":".ToCharArray(), 2).Last(); } else { Console.Out.WriteLine("Unknown command"); } } if (script == null) { Environment.Exit(1); } return(script); }
private static void Setup(LoginFile script) { lsApi.Connected += (IEnumerable <Model.GameServer> gameServers) => { Model.GameServer gameServer = gameServers .Single(gs => gs.Id == script.GameServer); if (gameServer != null) { lsApi.SelectGameServer(gameServer); } else { throw new KeyNotFoundException(); } }; lsApi.ServerSelected += (byte[] loginKey, byte[] gameKey) => { string login = script.Account.Login; int protocol = script.LoginServer.Protocol; gsApi.Connect(lsApi.GameServer, login, loginKey, gameKey, protocol); }; gsApi.Connected += (IEnumerable <Model.Player> characters) => { int?number = null; foreach (var character in characters) { if (character.Name == script.Character) { number = character.Number; } } if (number.HasValue) { gsApi.SelectCharacter(number.Value); } else { throw new KeyNotFoundException(); } }; gsApi.ChatMessage += (Lineage.Channel channel, string message, string name, Model.Creature author) => { var me = gsApi.World.Me; if (Global || channel == Lineage.Channel.Tell) { if (name != me.Name && Access.Allow(name) && message.Trim().StartsWith("/")) { Command(message.Trim().Substring(1).ToLower(), name, author); } } }; gsApi.QuestionAsked += (Lineage.Question question, string name, string value) => { if (Access.Allow(name)) { gsApi.QuestionReply(question, Lineage.Answer.Yes); } }; gsApi.LoggedOut += () => { Environment.Exit(0); }; gsApi.EnterWorld += () => { ConsoleThread.Start(); }; lsApi.Connect(script.LoginServer, script.Account); }