2017-02-26 14:51:11 -05:00
|
|
|
|
/*
|
2017-02-24 20:24:57 -05: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 18:36:09 -05:00
|
|
|
|
using System.Collections.Generic;
|
2017-02-02 09:47:23 -05:00
|
|
|
|
using System.Dynamic;
|
2017-01-08 18:36:09 -05: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; }
|
2017-02-15 19:46:33 -05:00
|
|
|
|
public long Codepoints { get; set; }
|
2017-01-08 18:36:09 -05:00
|
|
|
|
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 18:36:09 -05:00
|
|
|
|
public List<string> CurrentLegions { get; set; }
|
|
|
|
|
public int MajorVersion { get; set; }
|
|
|
|
|
public int MinorVersion { get; set; }
|
|
|
|
|
public int Revision { get; set; }
|
|
|
|
|
|
2017-03-06 12:01:16 -05:00
|
|
|
|
public bool IsPatreon { get; set; }
|
|
|
|
|
|
2017-01-08 18:36:09 -05:00
|
|
|
|
public string Password { get; set; }
|
2017-02-04 19:11:53 -05:00
|
|
|
|
public bool PasswordHashed { get; set; }
|
2017-01-08 18:36:09 -05:00
|
|
|
|
public string SystemName { get; set; }
|
|
|
|
|
|
2017-02-02 09:47:23 -05:00
|
|
|
|
private dynamic _settings = new SettingsObject();
|
2017-01-08 18:36:09 -05:00
|
|
|
|
|
2017-02-26 14:51:11 -05:00
|
|
|
|
public int ShiftnetSubscription { get; set; }
|
|
|
|
|
|
2017-02-12 18:35:15 -05:00
|
|
|
|
public Guid ID { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsMUDAdmin { get; set; }
|
|
|
|
|
|
2017-02-02 09:47:23 -05:00
|
|
|
|
public dynamic Settings
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _settings;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-08 18:36:09 -05:00
|
|
|
|
|
2017-03-05 14:36:12 -05:00
|
|
|
|
public int LastMonthPaid { get; set; }
|
|
|
|
|
|
2017-01-08 18:36:09 -05: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 18:36:09 -05:00
|
|
|
|
}
|