Exemple #1
0
        public void Load(FileInfo info, DirectoryInfo players)
        {
            if (info.DirectoryName != null && !Directory.Exists(info.DirectoryName) || !File.Exists(info.FullName))
            {
                LoadDefaults(info);
                return;
            }
            using (var fs = new FileStream(info.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (var sr = new StreamReader(fs))
                {
                    var json      = sr.ReadToEnd();
                    var jsonClass = JsonConvert.DeserializeObject <GameSettings>(json);
                    ApplyValues(jsonClass);
                }
            }

            if (AvailablePlayers.Count <= 0)
            {
                AvailablePlayers.AddRange(DefaultPlayers);
            }
            foreach (var player in AvailablePlayers.Where(p => p.Enabled))
            {
                Players.Add(player);
            }
        }
Exemple #2
0
        public override void Reload(GameCore core)
        {
            base.Reload(core);

            AvailablePlayers.Clear();

            if (IsLoaded)
            {
                AvailablePlayers.AddRange(this.core.GameState.DraftPool.AvailablePlayers);
            }

            if (SearchPlayerViewModel != null)
            {
                SearchPlayerViewModel.Reload(core);
            }
        }
Exemple #3
0
 public void LoadDefaults(FileInfo info)
 {
     if (info.DirectoryName != null)
     {
         Directory.CreateDirectory(info.DirectoryName);
     }
     FieldLines     = true;
     BorderLines    = true;
     WabeLines      = true;
     MaximumPlayers = 2;
     if (AvailablePlayers.Count <= 0)
     {
         AvailablePlayers.AddRange(DefaultPlayers);
     }
     Save(info);
 }