Esempio n. 1
0
        public User UpdateAccount(User user, string oldEmail, string newEmail, string oldPasswordHash, string newPassword)
        {
            User newUser      = null;
            int  rowsAffected = 0;

            string newPasswordHash = HashSha256(newPassword);

            // try to invoke the access method
            try
            {
                rowsAffected = PlayerAccessor.UpdateAccount(user.GameUserID, oldEmail, newEmail, oldPasswordHash, newPasswordHash);
                if (rowsAffected == 1)
                {
                    newUser = user;
                }
                else
                {
                    throw new ApplicationException("Update returned 0 rows affected.");
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Account update failed.", ex);
            }

            return(newUser);
        }
Esempio n. 2
0
        public User AuthenticateUser(string username, string password)
        {
            User user = null; // user token to build

            // we need to hash the password first
            var passwordHash = HashSha256(password);

            try
            {
                var validationResults = PlayerAccessor.VerifyUserNameAndPassword(username, passwordHash);

                if (validationResults == 1) // user is validated
                {
                    user = PlayerAccessor.RetrieveUserByUsername(username);
                }
                else // User was not validated
                {
                    // we can throw an exception here.
                    throw new ApplicationException("Login failed. Bad username or password");
                }
            }
            catch (ApplicationException) // rethrow the application exception?
            {
                throw;
            }
            catch (Exception ex) // wrap and throw other types of exceptions
            {
                throw new ApplicationException("There was a problem connecting to the server.", ex);
            }

            return(user);
        }
Esempio n. 3
0
 public FormulaUnitParamCalculator(FormulaController formula, ContextLogic context, BattleAccessor battle, UnitsAccessor units, PlayerAccessor player)
 {
     _formula = formula;
     _player  = player;
     _context = context;
     _units   = units;
     _battle  = battle;
 }
Esempio n. 4
0
 public UnitImpactExpExecutor(ImpactController logic, FormulaController formula, ContextLogic context, UnitsAccessor units, PlayerAccessor player, BattleAccessor battle)
 {
     _formula = formula;
     _logic   = logic;
     _units   = units;
     _context = context;
     _battle  = battle;
     _player  = player;
 }
 public void InitData(IPlayerStateClient client, PlayerAccessor accessor, ChangeStorage storage)
 {
     _storage  = storage;
     _accessor = accessor;
     client.Level.Subscribe(x => _Level = x).AddTo(_disposables);
     client.Exp.Subscribe(x => _Exp     = x).AddTo(_disposables);
     client.RegisterTime.Subscribe(x => _RegisterTime   = x).AddTo(_disposables);
     client.LastLoginTime.Subscribe(x => _LastLoginTime = x).AddTo(_disposables);
     client.SyncTime.Subscribe(x => _SyncTime           = x).AddTo(_disposables);
 }
 public void InitData(string root, ChangeStorage storage, PlayerAccessor accessor)
 {
     _accessor               = accessor;
     _storage                = storage;
     DataId                  = root;
     Interface_Level         = new ReactiveProperty <Int32>(_Level);
     Interface_Exp           = new ReactiveProperty <Int32>(_Exp);
     Interface_RegisterTime  = new ReactiveProperty <String>(_RegisterTime);
     Interface_LastLoginTime = new ReactiveProperty <String>(_LastLoginTime);
     Interface_SyncTime      = new ReactiveProperty <String>(_SyncTime);
 }
Esempio n. 7
0
        public int DeleteAccount(int gameUserID)
        {
            int results = 0;

            try
            {
                results = PlayerAccessor.DeleteAccount(gameUserID);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("There was a problem connecting to the server.", ex);
            }

            return(results);
        }
Esempio n. 8
0
        public int CreateAccount(string username, string email, string password)
        {
            int results = 0;

            var passwordHash = HashSha256(password);

            try
            {
                results = PlayerAccessor.CreateUser(username, passwordHash, email);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("There was a problem connecting to the server.", ex);
            }

            return(results);
        }
Esempio n. 9
0
 public InternalAccessors(LogicData LogicData, IStateFactory factory)
 {
     Factory             = factory;
     ConditionController = new ConditionController();
     FormulaController   = new FormulaController();
     AchievementAccessor = new AchievementAccessor();
     BattleAccessor      = new BattleAccessor();
     CutSceneAccessor    = new CutSceneAccessor();
     ExplorerAccessor    = new ExplorerAccessor();
     InventoryAccessor   = new InventoryAccessor();
     LogAccessor         = new LogAccessor();
     LogAccessor.Data    = LogicData;
     PlayerAccessor      = new PlayerAccessor();
     ScorersAccessor     = new ScorersAccessor();
     SettingsAccessor    = new SettingsAccessor();
     ShopAccessor        = new ShopAccessor();
     UnitsAccessor       = new UnitsAccessor();
 }
Esempio n. 10
0
 public static ImpactLogic CreateClient(ScorersAccessor _scorers, PlayerAccessor _player, InventoryAccessor _inventory, ExplorerAccessor _explorer, UnitsAccessor _units, BattleAccessor _battle, SettingsAccessor _settings, AchievementAccessor _achievement, BattleLogic _battleLogic, FormulaLogic _formulaLogic, ConditionController _condition, ApplyChangeLogic _applyChangeLogic, BuffLogic _buff, ScorersLogic _scorersLogic, ContextLogic _contextLogic, ImpactController _impactController, LogicData _data)
 {
     return(new ImpactLogic
     {
         _scorers = _scorers,
         _player = _player,
         _inventory = _inventory,
         _explorer = _explorer,
         _units = _units,
         _battle = _battle,
         _settings = _settings,
         _achievement = _achievement,
         _battleLogic = _battleLogic,
         _formulaLogic = _formulaLogic,
         _condition = _condition,
         _applyChangeLogic = _applyChangeLogic,
         _buff = _buff,
         _scorersLogic = _scorersLogic,
         _contextLogic = _contextLogic,
         _impactController = _impactController,
         _data = _data,
     }
            );
 }
Esempio n. 11
0
 public static ActivationModule CreateClient(FormulaController _formulaLogic, ImpactController _impactLogic, ExplorerAccessor _explorer, ScorersAccessor _scorers, PlayerAccessor Player, UnitsAccessor _units, ApplyChangeLogic _changeLogic)
 {
     return(new ActivationModule
     {
         _formulaLogic = _formulaLogic,
         _impactLogic = _impactLogic,
         _explorer = _explorer,
         _scorers = _scorers,
         Player = Player,
         _units = _units,
         _changeLogic = _changeLogic,
     }
            );
 }
Esempio n. 12
0
 public static UnitProgressModule CreateClient(UnitsAccessor _units, ScorersAccessor _scorers, BattleAccessor _battle, FormulaLogic _formuls, PlayerAccessor _player, ImpactController _impact)
 {
     return(new UnitProgressModule
     {
         _units = _units,
         _scorers = _scorers,
         _battle = _battle,
         _formuls = _formuls,
         _player = _player,
         _impact = _impact,
     }
            );
 }
 public ImpactPlayerExpExecutor(ImpactController logic, FormulaLogic formula, PlayerAccessor accessor)
 {
     _formula  = formula;
     _logic    = logic;
     _accessor = accessor;
 }
Esempio n. 14
0
 public static ConditionLogic CreateClient(InventoryAccessor _inventoryAccessor, ScorersAccessor _scorersAccessor, PlayerAccessor _profileAccessor, UnitsAccessor _unitAccessor, BattleAccessor _battleAccessor, ExplorerAccessor _explorerAccessor, SettingsAccessor _settingsAccessor, AchievementAccessor _achievementAccessor, FormulaLogic _formulaLogic, ContextLogic _contextLogic, ScorersLogic _scorerLogic, LogicData _data, ConditionController _controller)
 {
     return(new ConditionLogic
     {
         _inventoryAccessor = _inventoryAccessor,
         _scorersAccessor = _scorersAccessor,
         _profileAccessor = _profileAccessor,
         _unitAccessor = _unitAccessor,
         _battleAccessor = _battleAccessor,
         _explorerAccessor = _explorerAccessor,
         _settingsAccessor = _settingsAccessor,
         _achievementAccessor = _achievementAccessor,
         _formulaLogic = _formulaLogic,
         _contextLogic = _contextLogic,
         _scorerLogic = _scorerLogic,
         _data = _data,
         _controller = _controller,
     }
            );
 }
Esempio n. 15
0
 public static FormulaLogic CreateClient(ContextLogic _contextLogic, ScorersAccessor _scorers, UnitsAccessor _units, BattleAccessor _battle, ExplorerAccessor _explorer, LogicData _data, PlayerAccessor _player, SettingsAccessor _settings, ConditionController _controller, FormulaController _formula, ScorersLogic _scorerLogic)
 {
     return(new FormulaLogic
     {
         _contextLogic = _contextLogic,
         _scorers = _scorers,
         _units = _units,
         _battle = _battle,
         _explorer = _explorer,
         _data = _data,
         _player = _player,
         _settings = _settings,
         _controller = _controller,
         _formula = _formula,
         _scorerLogic = _scorerLogic,
     }
            );
 }
Esempio n. 16
0
 public ConditionPlayerLevelChecker(FormulaLogic logic, PlayerAccessor player)
 {
     _player = player;
     _logic  = logic;
 }