Exemple #1
0
        public void CreateGame(NewGameOptionsVM options)
        {
            StatusText = "Creating Game...";

            // TODO: Databind the GameSettings object in the NewGameOptionsVM
            var gameSettings = new NewGameSettings
            {
                GameName              = "Test Game",
                MaxSystems            = options.NumberOfSystems,
                SMPassword            = options.GmPassword,
                DataSets              = options.SelectedModList.Select(dvi => dvi.Directory),
                CreatePlayerFaction   = options.CreatePlayerFaction,
                DefaultFactionName    = options.FactionName,
                DefaultPlayerPassword = options.FactionPassword,
                DefaultSolStart       = options.DefaultStart,
            };

            Game = new Game(gameSettings);

            // TODO: Select default player more reliably
            CurrentPlayer    = Game.Players[0];
            CurrentAuthToken = new AuthenticationToken(CurrentPlayer, options.FactionPassword);

            ReadOnlyDictionary <Entity, AccessRole> roles = CurrentPlayer.GetAccessRoles(CurrentAuthToken);

            CurrentFaction = roles.FirstOrDefault(role => (role.Value & AccessRole.Owner) != 0).Key;


            StatusText = "Game Created.";

            StarSystemViewModel = new SystemView.StarSystemVM(this, Game, CurrentFaction);
            StarSystemViewModel.Initialise();
        }
        public static NewGameOptionsVM Create(GameVM gameVM)
        {
            NewGameOptionsVM optionsVM = new NewGameOptionsVM();

            optionsVM._gameVM = gameVM;

            return(optionsVM);
        }