diff --git a/Campofinale/ConfigFile.cs b/Campofinale/ConfigFile.cs index 009bcfa..7ce75cc 100644 --- a/Campofinale/ConfigFile.cs +++ b/Campofinale/ConfigFile.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,61 +9,95 @@ namespace Campofinale { public class ConfigFile { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public MongoDatabaseSettings mongoDatabase = new(); + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public DispatchServerSettings dispatchServer = new(); + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public GameserverSettings gameServer = new(); + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public ServerOptions serverOptions = new(); + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public LogSettings logOptions = new(); } - public struct ServerOptions + public class ServerOptions { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int defaultSceneNumId = 98; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int maxPlayers = 20; - + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public CharactersOptions defaultCharacters = new(); public ServerOptions() { } + public class CharactersOptions + { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public int defaultLevel = 1; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public bool giveAllCharacters = true; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] + public List characters = new List() + { + "chr_0002_endminm", + "chr_0003_endminf", + "chr_0015_lifeng" + }; //used if giveAllCharacters is false + public CharactersOptions() { } + } /* public struct WelcomeMail { }*/ } - public struct LogSettings + public class LogSettings { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public bool packets; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public bool debugPrint=false; public LogSettings() { } } - public struct GameserverSettings + public class GameserverSettings { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string bindAddress = "127.0.0.1"; public int bindPort = 30000; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string accessAddress = "127.0.0.1"; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int accessPort = 30000; public GameserverSettings() { } } - public struct DispatchServerSettings + public class DispatchServerSettings { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string bindAddress = "127.0.0.1"; - + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int bindPort = 5000; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string accessAddress = "127.0.0.1"; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int accessPort = 5000; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string emailFormat = "@campofinale.ps"; public DispatchServerSettings() { } } - public struct MongoDatabaseSettings + public class MongoDatabaseSettings { + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string uri = "mongodb://localhost:27017"; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public string collection = "Campofinale"; public MongoDatabaseSettings() { diff --git a/Campofinale/Player.cs b/Campofinale/Player.cs index 0109fb4..42afcc3 100644 --- a/Campofinale/Player.cs +++ b/Campofinale/Player.cs @@ -198,10 +198,21 @@ namespace Campofinale } public void Initialize() { - foreach (var item in ResourceManager.characterTable) + if (Server.config.serverOptions.defaultCharacters.giveAllCharacters) { - chars.Add(new Character(roleId,item.Key,20)); + foreach (var item in ResourceManager.characterTable) + { + chars.Add(new Character(roleId, item.Key, Server.config.serverOptions.defaultCharacters.defaultLevel)); + } } + else + { + foreach (var item in Server.config.serverOptions.defaultCharacters.characters) + { + chars.Add(new Character(roleId, item.Key, Server.config.serverOptions.defaultCharacters.defaultLevel)); + } + } + foreach(var item in itemTable) { if(item.Value.maxStackCount == -1)