2017-02-26 19:51:11 +00:00
/ *
2017-02-25 01:24:57 +00:00
* MIT License
*
* Copyright ( c ) 2017 Michael VanOverbeek and ShiftOS devs
*
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the "Software" ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE .
* /
using System ;
2017-01-08 23:36:09 +00:00
using System.Collections.Generic ;
2017-02-02 14:47:23 +00:00
using System.Dynamic ;
2017-01-08 23:36:09 +00:00
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
namespace ShiftOS.Objects
{
//Better to store this stuff server-side so we can do some neat stuff with hacking...
public class Save
{
2017-05-01 19:23:46 +00:00
[Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")]
2017-01-08 23:36:09 +00:00
public string Username { get ; set ; }
2017-05-01 19:23:46 +00:00
2017-02-16 00:46:33 +00:00
public long Codepoints { get ; set ; }
2017-01-08 23:36:09 +00:00
public Dictionary < string , bool > Upgrades { get ; set ; }
public int StoryPosition { get ; set ; }
public string Language { get ; set ; }
2017-01-17 22:08:27 +00:00
public string MyShop { get ; set ; }
2017-01-08 23:36:09 +00:00
public List < string > CurrentLegions { get ; set ; }
public int MajorVersion { get ; set ; }
public int MinorVersion { get ; set ; }
public int Revision { get ; set ; }
2017-04-30 15:44:29 +00:00
public string UniteAuthToken { get ; set ; }
2017-03-06 17:01:16 +00:00
public bool IsPatreon { get ; set ; }
2017-04-09 14:00:16 +00:00
public UserClass Class { get ; set ; }
public double RawReputation { get ; set ; }
public Reputation Reputation
{
get
{
return ( Reputation ) ( ( int ) Math . Round ( RawReputation ) ) ;
}
}
2017-03-06 17:01:16 +00:00
2017-01-08 23:36:09 +00:00
public string Password { get ; set ; }
2017-02-05 00:11:53 +00:00
public bool PasswordHashed { get ; set ; }
2017-01-08 23:36:09 +00:00
public string SystemName { get ; set ; }
2017-02-02 14:47:23 +00:00
private dynamic _settings = new SettingsObject ( ) ;
2017-01-08 23:36:09 +00:00
2017-02-26 19:51:11 +00:00
public int ShiftnetSubscription { get ; set ; }
2017-02-12 23:35:15 +00:00
public Guid ID { get ; set ; }
public bool IsMUDAdmin { get ; set ; }
2017-02-02 14:47:23 +00:00
public dynamic Settings
{
get
{
return _settings ;
}
}
2017-01-08 23:36:09 +00:00
2017-03-05 19:36:12 +00:00
public int LastMonthPaid { get ; set ; }
2017-03-07 01:05:24 +00:00
public List < string > StoriesExperienced { get ; set ; }
2017-03-05 19:36:12 +00:00
2017-01-08 23:36:09 +00:00
public int CountUpgrades ( )
{
int count = 0 ;
foreach ( var upg in Upgrades )
{
if ( upg . Value = = true )
count + + ;
}
return count ;
}
2017-05-01 00:28:31 +00:00
public List < ClientSave > Users = new List < ClientSave > ( ) ;
2017-01-08 23:36:09 +00:00
}
2017-02-02 14:47:23 +00:00
public class SettingsObject : DynamicObject
{
private Dictionary < string , object > _settings = null ;
public SettingsObject ( )
{
_settings = new Dictionary < string , object > ( ) ;
}
public override IEnumerable < string > GetDynamicMemberNames ( )
{
return _settings . Keys . ToArray ( ) ;
}
public override bool TryGetMember ( GetMemberBinder binder , out object result )
{
if ( _settings . ContainsKey ( binder . Name ) )
{
result = _settings [ binder . Name ] ;
return true ;
}
else
{
result = null ;
return false ;
}
}
public override bool TrySetMember ( SetMemberBinder binder , object value )
{
2017-02-08 23:01:13 +00:00
try
2017-02-02 14:47:23 +00:00
{
2017-02-08 23:01:13 +00:00
if ( _settings . ContainsKey ( binder . Name ) )
{
_settings [ binder . Name ] = value ;
}
else
{
_settings . Add ( binder . Name , value ) ;
}
2017-02-02 14:47:23 +00:00
}
2017-02-08 23:01:13 +00:00
catch
2017-02-02 14:47:23 +00:00
{
2017-02-08 23:01:13 +00:00
2017-02-02 14:47:23 +00:00
}
return true ;
}
}
2017-01-08 23:36:09 +00:00
}