2017-01-08 15:36:09 -08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-02-02 09:47:23 -05:00
|
|
|
|
using System.Dynamic;
|
2017-01-08 15:36:09 -08: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
|
|
|
|
|
{
|
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
public int Codepoints { get; set; }
|
|
|
|
|
public Dictionary<string, bool> Upgrades { get; set; }
|
|
|
|
|
public int StoryPosition { get; set; }
|
|
|
|
|
public string Language { get; set; }
|
2017-01-17 17:08:27 -05:00
|
|
|
|
public string MyShop { get; set; }
|
2017-01-08 15:36:09 -08:00
|
|
|
|
public List<string> CurrentLegions { get; set; }
|
|
|
|
|
public int MajorVersion { get; set; }
|
|
|
|
|
public int MinorVersion { get; set; }
|
|
|
|
|
public int Revision { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Password { get; set; }
|
2017-02-04 19:11:53 -05:00
|
|
|
|
public bool PasswordHashed { get; set; }
|
2017-01-08 15:36:09 -08:00
|
|
|
|
public string SystemName { get; set; }
|
|
|
|
|
|
2017-02-02 09:47:23 -05:00
|
|
|
|
private dynamic _settings = new SettingsObject();
|
2017-01-08 15:36:09 -08:00
|
|
|
|
|
2017-02-02 09:47:23 -05:00
|
|
|
|
public dynamic Settings
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _settings;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-08 15:36:09 -08:00
|
|
|
|
|
|
|
|
|
public int CountUpgrades()
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (var upg in Upgrades)
|
|
|
|
|
{
|
|
|
|
|
if (upg.Value == true)
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-02 09:47:23 -05: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 18:01:13 -05:00
|
|
|
|
try
|
2017-02-02 09:47:23 -05:00
|
|
|
|
{
|
2017-02-08 18:01:13 -05:00
|
|
|
|
if (_settings.ContainsKey(binder.Name))
|
|
|
|
|
{
|
|
|
|
|
_settings[binder.Name] = value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_settings.Add(binder.Name, value);
|
|
|
|
|
}
|
2017-02-02 09:47:23 -05:00
|
|
|
|
}
|
2017-02-08 18:01:13 -05:00
|
|
|
|
catch
|
2017-02-02 09:47:23 -05:00
|
|
|
|
{
|
2017-02-08 18:01:13 -05:00
|
|
|
|
|
2017-02-02 09:47:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-08 15:36:09 -08:00
|
|
|
|
}
|