Example #1
0
        public void CreateDefaultFaction(string name, string password)
        {
            Entity factionEntity = DefaultStartFactory.DefaultHumans(_game, name);

            AuthProcessor.StorePasswordAsHash(_game, factionEntity, password);
            SetFaction(factionEntity);
        }
Example #2
0
        public bool TrySetFaction(Guid entityGuid, string password)
        {
            Entity factionEntity = _game.GlobalManager.GetLocalEntityByGuid(entityGuid);

            if (AuthProcessor.Validate(factionEntity, password))
            {
                SetFaction(factionEntity);
                return(true);
            }
            return(false);
        }
Example #3
0
        //TODO: should I out a message here?
        public bool TrySetFaction(string factionName, string password)
        {
            Entity factionEntity;

            if (NameLookup.TryGetFirstEntityWithName(_game.GlobalManager, factionName, out factionEntity))
            {
                if (AuthProcessor.Validate(factionEntity, password))
                {
                    SetFaction(factionEntity);
                    return(true);
                }
            }
            return(false);
        }
Example #4
0
        internal 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;
            SetFactionData();
            var auth = new AuthDB();

            CurrentFaction.SetDataBlob(auth);
            AuthProcessor.StorePasswordAsHash(Game, CurrentFaction, options.FactionPassword);

            StatusText = "Game Created.";

            StarSystemSelectionViewModel = new StarSystemSelectionVM(this, Game, CurrentFaction);
            StarSystemSelectionViewModel.Initialise();
        }