Exemplo n.º 1
0
 public Command(string command, string commandArgs, string descSmall, string descLarge, User.PermissionLevel permission)
 {
     this.command = command;
     this.command_args = commandArgs;
     this.description_small = descSmall;
     this.description_Long = descLarge;
     this.permission = permission;
 }
Exemplo n.º 2
0
 public User CreateUser(string name)
 {
     SaveVersions.Version_Current.User usrSave = new SaveVersions.Version_Current.User ();
     usrSave.name = name;
     User user = new User (usrSave);
     _users.Add (name, user);
     return user;
 }
 public CommandDescription(string _command, string _command_args, string _description_small, User.PermissionLevel permission, string _callback)
 {
     command = _command.ToLower();
     command_args = _command_args;
     description_small = _description_small;
     description_Long = string.Empty;
     this.permission = permission;
     callback = GetCallbackFromString(_command, _callback);
 }
 public CommandDescription(string _command, string _command_args, string _description_small, User.PermissionLevel permission, CommandExecuter.CommandFunction _callback)
 {
     command = _command.ToLower();
     command_args = _command_args;
     description_small = _description_small;
     description_Long = string.Empty;
     this.permission = permission;
     callback = _callback;
 }
Exemplo n.º 5
0
 public bool CreateAlliance(string name, User owner)
 {
     // see if can create alliance.
     if (!AllianceExist(name)) {
         Alliance all = new Alliance(name, owner);
         _alliances.Add(name, all);
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
 public void Load(AllianceSave save)
 {
     if (GameServer.Instance.Users.UserExists(save.owner)) {
         members.Clear();
         Name = save.name;
         Owner = GameServer.Instance.Users.GetUser(save.owner);
         for (int i = 0; i < save.members.Length; i++) {
             if (GameServer.Instance.Users.UserExists(save.members[i])) {
                 User user = GameServer.Instance.Users.GetUser(save.members[i]);
                 user.alliance = this;
                 members.Add(user.Name, new Member(user));
             }
         }
     }
 }
Exemplo n.º 7
0
 private object NetUsage_CMD(User caller, params string[] args)
 {
     _server.Net.DisplayDataRate ();
     return string.Empty;
 }
Exemplo n.º 8
0
 private object Mute_CMD(User caller, params string[] args)
 {
     if (caller.Permission == User.PermissionLevel.Moderator ||
         caller.Permission == User.PermissionLevel.Admin ||
         caller.Permission == User.PermissionLevel.Server) {
         // moderators must specify time arg.
     }
     return "Not implemented.";
 }
Exemplo n.º 9
0
 public Alliance(string name, User owner)
 {
     Name = name;
     Owner = owner;
     members = new Dictionary<string, Member>();
 }
Exemplo n.º 10
0
 public void AddUser(User user)
 {
     if (!UserExists (user.Name)) {
         _users.Add(user.Name, user);
     }
 }
Exemplo n.º 11
0
 private object Time_CMD(User caller, params string[] args)
 {
     return GameTimer.GetDateTime();
 }
Exemplo n.º 12
0
 // command functions
 private object Runtime_CMD(User caller, params string[] args)
 {
     if (_server.WorldLoaded)
         return _server.GameTime.GetRuntime();
     Logger.LogWarning ("World not loaded.");
     return string.Empty;
 }
Exemplo n.º 13
0
 private object NewUser_CMD(User caller, params string[] args)
 {
     if (args.Length == 5)
     {
         string username = args[1];
         string password = args[2];
         string permission = args[3];
         string email = args[4];
         return GameServer.Instance.CreatePlayer(username, password, permission, email);
     }
     else
         return "Requires 4 arguments.";
 }
Exemplo n.º 14
0
 private object Clear_CMD(User caller, params string[] args)
 {
     Logger.Clear ();
     return string.Empty;
 }
Exemplo n.º 15
0
        public Standing GetStandings(User usr)
        {
            if (usr.Permission == PermissionLevel.Admin || usr.Permission == PermissionLevel.Admin)
                return Standing.Own;
            if (usr.Name == Name)
                return Standing.Own;
            if (alliance != null && alliance.HasMember(usr))
                return Standing.Ally;
            if (alliance != null && usr.alliance != null && alliance.IsEnemy(usr.alliance.Name))
                return Standing.Enemy;

            return Standing.Nuetral;
        }
Exemplo n.º 16
0
 public bool HasMember(User user)
 {
     return members.ContainsKey(user.Name);
 }
Exemplo n.º 17
0
 public void AddMember(User user)
 {
     if (!HasMember(user)) {
         members.Add(user.Name, new Member(user));
     }
 }
Exemplo n.º 18
0
 private object NewAlliance_CMD(User caller, params string[] args)
 {
     if (caller.Permission == User.PermissionLevel.Server) {
         if (args.Length == 2) {
             GameServer.Instance.Alliances.CreateAlliance(args[0], args[1]);
             return "Alliance created";
         }
         else if (args.Length == 1) {
             GameServer.Instance.Alliances.CreateAlliance(args[0], "_server_");
             return "Alliance created";
         }
     }
     else if (caller.Permission == User.PermissionLevel.Admin) {
         if (args.Length == 2)
         {
             GameServer.Instance.Alliances.CreateAlliance(args[0], args[1]);
             return "Alliance created";
         }
         else if (args.Length == 1)
         {
             GameServer.Instance.Alliances.CreateAlliance(args[0], caller.Name);
             return "Alliance created";
         }
     }
     return "Alliance creation failed.";
 }
Exemplo n.º 19
0
 private object NewStructure_CMD(User caller, params string[] args)
 {
     if (caller.Permission == User.PermissionLevel.Admin || caller.Permission == User.PermissionLevel.Server)
     {
         if (args.Length == 3) {
             int x;
             int y;
             Structures.Structure.StructureType type;
             if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y) && Enum.TryParse(args[2], out type)) {
                 caller.CreateStructure(new Vector2Int(x, y), type, true);
                 return "Structure created.";
             }
         }
         else
             return "Error: command requires 3 arguements.";
     }
     return "Invalid permission level.";
 }
Exemplo n.º 20
0
 private object Create_CMD(User caller, params string[] args)
 {
     try {
         if (args.Length == 2){
             TaskQueue.QeueAsync("GeneralWorker", ()=> _server.Worlds.CreateWorld(args[1]));
         }
     }
     catch(Exception e){
         Logger.LogError("{0}\n{1}", e.Message, e.StackTrace);
     }
     return string.Empty;
 }
Exemplo n.º 21
0
        private object Preview_CMD(User caller, params string[] args)
        {
            int seed = 0;
            if (args.Length == 1)
                seed = AppSettings.TerrainSeed;
            else if (args.Length == 2 && args [1].Equals ("-r")) {
                seed = new Random (GameTimer.GetEpoch ()).Next (int.MinValue, int.MaxValue);
            } else if (args.Length == 2) {
                if (int.TryParse(args[1], out seed));
            }
            TaskQueue.QeueAsync("terrain preview", ()=>{
                try {
                    List<GradientPresets.GradientKeyData> keys = new List<GradientPresets.GradientKeyData>();
                    keys.Add(new GradientPresets.GradientKeyData(new Color(255, 0, 0, 128), 0));
                    keys.Add(new GradientPresets.GradientKeyData(new Color(255, 32, 64, 128), 0.4f));
                    keys.Add(new GradientPresets.GradientKeyData(new Color(255, 64, 96, 191), 0.48f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"sand.png"}, 0.5f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"trees1.png", "trees2.png" }, 0.52f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "trees2.png"}, 0.55f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png", "trees2.png"}, 0.60f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png"}, 0.90f));
                    keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png"}, 1f));
                    //GradientPresets.CreateGradient(keys);
                    GradiantPresetLoader.PresetSerializer saveObj = new GradiantPresetLoader.PresetSerializer(AppSettings.TerrainPreset, keys);
                    FileManager.SaveConfigFile(GameServer.Instance.AppDirectory + "GradientPresets" + GameServer.sepChar + AppSettings.TerrainPreset+".json", saveObj, false);
                    //return;
                    IModule module = new Perlin ();
                    ((Perlin)module).OctaveCount = 16;
                    ((Perlin)module).Seed = AppSettings.TerrainSeed;

                    TerrainBuilder builder = new TerrainBuilder(AppSettings.TerrainWidth, AppSettings.TerrainHeight, seed);
                    builder.Generate (module, AppSettings.TerrainPreset);
                    System.Drawing.Bitmap map = builder.GetBitmap();
                    /*System.Windows.Forms.Form imageForm = new System.Windows.Forms.Form();
                    imageForm.Text = "Seed preview: " + seed;
                    imageForm.Width = settings.TerrainWidth;
                    imageForm.Height = settings.TerrainHeight;
                    imageForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                    imageForm.Controls.Add (new System.Windows.Forms.PictureBox () {Image = map, Dock = System.Windows.Forms.DockStyle.Fill});
                    imageForm.ShowDialog();
                    Logger.Log("Preview closed.");
                    imageForm.Close();
                    imageForm.Dispose();*/
                }
                catch(Exception e){
                    Logger.LogError("{0}\n{1}", e.Message, e.StackTrace);
                }
            });
            return "Seed: " + seed;
        }
Exemplo n.º 22
0
 private object Exit_CMD(User caller, params string[] args)
 {
     if (_server.WorldLoaded)
         _server.Worlds.SaveCurrentWorld ();
     _server.Exit ();
     return "Good bye...";
 }
Exemplo n.º 23
0
 private object Save_CMD(User caller, params string[] args)
 {
     if (args.Length == 1)
         _server.Save ();
     else if (args.Length == 2)
         _server.Save (args [1]);
     return string.Empty;
 }
Exemplo n.º 24
0
        private object Help_CMD(User caller, params string[] args)
        {
            StringBuilder output = new StringBuilder ();
            if (args.Length == 1) {
                output.AppendLine(string.Format("Commands ({0}):", _cmdTable.Count.ToString()));
                foreach (string key in _cmdTable.Keys) {
                    if (caller.CanCallCommand(key))
                        output.AppendLine (string.Format ("  {0} : {1}", key.PadRight(padAmount, ' '), _cmdDescription [key].description_small));
                }
            } else if (args.Length == 2) {
                if (_cmdTable.ContainsKey (args [1])) {
                    if (caller.CanCallCommand(args[1])) {
                        output.AppendLine(string.Format(" - Command: {0} {1}", _cmdDescription[args[1]].command, _cmdDescription[args[1]].command_args));
                        output.AppendLine(string.Format(" - Short description: {0}", _cmdDescription[args[1]].description_small));
                        if (!string.IsNullOrEmpty(_cmdDescription[args[1]].description_Long))
                            output.AppendLine(string.Format(" - Long description: {0}", _cmdDescription[args[1]].description_Long));
                    }
                    else
                        return string.Format("error: {0} permissions required.", _cmdDescription[args[1]].permission.ToString());
                } else
                    return "Command not found: " + args[1];

            } else {
                return "To many arguments.";
            }
            return output.ToString();
        }
Exemplo n.º 25
0
 public void AddConnectedUser(string key, User usr)
 {
     _connectedUsers [key] = usr;
 }
Exemplo n.º 26
0
 private object Load_CMD(User caller, params string[] args)
 {
     try {
         if (args.Length == 2){
             _server.Worlds.LoadWorld(args[1]);
         }
     }
     catch(Exception e){
         Logger.LogError("{0}: {1}\n{2}", e.GetType().ToString(), e.Message, e.StackTrace);
     }
     return string.Empty;
 }
Exemplo n.º 27
0
        private object Kick_CMD(User caller, params string[] args)
        {
            if (caller.Permission == User.PermissionLevel.Moderator ||
                caller.Permission == User.PermissionLevel.Admin ||
                caller.Permission == User.PermissionLevel.Server) {

            }
            return "Not implemented.";
        }
Exemplo n.º 28
0
 public Member(User user)
 {
     this.user = user;
 }