mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-23 02:12:14 +00:00
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
This commit is contained in:
commit
b06801028a
16 changed files with 355 additions and 39 deletions
|
@ -98,7 +98,7 @@ namespace ShiftOS.Objects
|
|||
return count;
|
||||
}
|
||||
|
||||
public List<ClientSave> Users = new List<ClientSave>();
|
||||
public List<ClientSave> Users { get; set; }
|
||||
}
|
||||
|
||||
public class SettingsObject : DynamicObject
|
||||
|
|
|
@ -230,7 +230,11 @@ namespace ShiftOS.Objects.ShiftFS
|
|||
|
||||
if (!FileExists(path))
|
||||
{
|
||||
dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All));
|
||||
try
|
||||
{
|
||||
dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -285,6 +285,16 @@ namespace ShiftOS.WinForms.Applications
|
|||
{
|
||||
secondsleft = 60;
|
||||
level = level + 1;
|
||||
if (SaveSystem.CurrentSave.UniteAuthToken != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
|
||||
if (unite.GetPongLevel() < level)
|
||||
unite.SetPongLevel(level);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
generatenextlevel();
|
||||
pnlgamestats.Show();
|
||||
pnlgamestats.BringToFront();
|
||||
|
@ -544,6 +554,14 @@ namespace ShiftOS.WinForms.Applications
|
|||
lblfinalcomputerreward.Text = beatairewardtotal.ToString();
|
||||
lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}");
|
||||
SaveSystem.TransferCodepointsFrom("pong", totalreward);
|
||||
if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken))
|
||||
{
|
||||
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
|
||||
if (unite.GetPongCP() < totalreward)
|
||||
{
|
||||
unite.SetPongCP(totalreward);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void newgame()
|
||||
|
|
95
ShiftOS.WinForms/Applications/TriWrite.Designer.cs
generated
95
ShiftOS.WinForms/Applications/TriWrite.Designer.cs
generated
|
@ -28,7 +28,7 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddressBook));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TriWrite));
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -36,8 +36,15 @@
|
|||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.txtbody = new System.Windows.Forms.Label();
|
||||
this.lbtitle = new System.Windows.Forms.Label();
|
||||
this.txtcontents = new System.Windows.Forms.TextBox();
|
||||
this.menuStrip2 = new System.Windows.Forms.MenuStrip();
|
||||
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip3 = new System.Windows.Forms.MenuStrip();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.menuStrip2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
|
@ -51,6 +58,16 @@
|
|||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// addContactToolStripMenuItem
|
||||
//
|
||||
this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem";
|
||||
this.addContactToolStripMenuItem.Size = new System.Drawing.Size(32, 19);
|
||||
//
|
||||
// removeToolStripMenuItem
|
||||
//
|
||||
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
|
||||
this.removeToolStripMenuItem.Size = new System.Drawing.Size(32, 19);
|
||||
//
|
||||
// tvcontacts
|
||||
//
|
||||
this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
|
@ -71,8 +88,8 @@
|
|||
//
|
||||
// txtbody
|
||||
//
|
||||
this.txtbody.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.txtbody.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtbody.Location = new System.Drawing.Point(7, 54);
|
||||
this.txtbody.Name = "txtbody";
|
||||
|
@ -85,10 +102,74 @@
|
|||
this.lbtitle.AutoSize = true;
|
||||
this.lbtitle.Location = new System.Drawing.Point(7, 4);
|
||||
this.lbtitle.Name = "lbtitle";
|
||||
this.lbtitle.Size = new System.Drawing.Size(73, 13);
|
||||
this.lbtitle.Size = new System.Drawing.Size(44, 13);
|
||||
this.lbtitle.TabIndex = 0;
|
||||
this.lbtitle.Tag = "header1";
|
||||
this.lbtitle.Text = "TriWrite";
|
||||
//
|
||||
// txtcontents
|
||||
//
|
||||
this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtcontents.Location = new System.Drawing.Point(0, 53);
|
||||
this.txtcontents.Multiline = true;
|
||||
this.txtcontents.Name = "txtcontents";
|
||||
this.txtcontents.Size = new System.Drawing.Size(527, 460);
|
||||
this.txtcontents.TabIndex = 1;
|
||||
this.txtcontents.TabStop = false;
|
||||
//
|
||||
// menuStrip2
|
||||
//
|
||||
this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.newToolStripMenuItem,
|
||||
this.openToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.menuStrip2.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip2.Name = "menuStrip2";
|
||||
this.menuStrip2.Size = new System.Drawing.Size(527, 24);
|
||||
this.menuStrip2.TabIndex = 2;
|
||||
this.menuStrip2.Text = "menuStrip2";
|
||||
//
|
||||
// newToolStripMenuItem
|
||||
//
|
||||
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
|
||||
this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20);
|
||||
this.newToolStripMenuItem.Text = "New";
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20);
|
||||
this.saveToolStripMenuItem.Text = "Save";
|
||||
//
|
||||
// menuStrip3
|
||||
//
|
||||
this.menuStrip3.Location = new System.Drawing.Point(0, 30);
|
||||
this.menuStrip3.Name = "menuStrip3";
|
||||
this.menuStrip3.Size = new System.Drawing.Size(527, 24);
|
||||
this.menuStrip3.TabIndex = 3;
|
||||
this.menuStrip3.Text = "menuStrip3";
|
||||
//
|
||||
// TriWrite
|
||||
//
|
||||
this.Controls.Add(this.txtcontents);
|
||||
this.Controls.Add(this.menuStrip3);
|
||||
this.Controls.Add(this.menuStrip2);
|
||||
this.Name = "TriWrite";
|
||||
this.Size = new System.Drawing.Size(527, 513);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.menuStrip2.ResumeLayout(false);
|
||||
this.menuStrip2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
@ -101,5 +182,11 @@
|
|||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Label txtbody;
|
||||
private System.Windows.Forms.Label lbtitle;
|
||||
private System.Windows.Forms.TextBox txtcontents;
|
||||
private System.Windows.Forms.MenuStrip menuStrip2;
|
||||
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.MenuStrip menuStrip3;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
using System;
|
||||
using ShiftOS.Objects.ShiftFS;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ShiftOS.Engine;
|
||||
using static ShiftOS.Objects.ShiftFS.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ShiftOS.WinForms.Applications
|
||||
{
|
||||
|
@ -20,9 +19,44 @@ namespace ShiftOS.WinForms.Applications
|
|||
public partial class TriWrite : UserControl, IShiftOSWindow
|
||||
{
|
||||
|
||||
public TriWrite()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void newToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
txtcontents.Text = "";
|
||||
}
|
||||
|
||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var txt = new List<string>();
|
||||
txt.Add(".txt");
|
||||
|
||||
AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Open, new Action<string>((file) => this.LoadFile(file))));
|
||||
}
|
||||
|
||||
public void LoadFile(string file)
|
||||
{
|
||||
txtcontents.Text = Utils.ReadAllText(file);
|
||||
}
|
||||
|
||||
public void SaveFile(string file)
|
||||
{
|
||||
Utils.WriteAllText(file, txtcontents.Text);
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var txt = new List<string>();
|
||||
txt.Add(".txt");
|
||||
|
||||
AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Save, new Action<string>((file) => this.SaveFile(file))));
|
||||
}
|
||||
|
||||
public void OnLoad()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnSkinLoad()
|
||||
|
|
|
@ -127,4 +127,10 @@ On the left, we have made a list of all your contacts. You can click on one to v
|
|||
|
||||
To add a contact, simply click "Add Contact", and to remove one, click "Remove". Some contacts may not be removed as they are integral to the progression of your adventures within the digital society.</value>
|
||||
</data>
|
||||
<metadata name="menuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>132, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>247, 17</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -111,7 +111,7 @@ namespace ShiftOS.WinForms
|
|||
ConsoleEx.Bold = false;
|
||||
ConsoleEx.BackgroundColor = ConsoleColor.Black;
|
||||
Console.Write("Formatting: [");
|
||||
int formatProgress = 0;
|
||||
int formatProgress = 3;
|
||||
while (formatProgress <= 100)
|
||||
{
|
||||
if (formatProgress % 3 == 0)
|
||||
|
|
|
@ -154,6 +154,7 @@ namespace ShiftOS.WinForms.Tools
|
|||
|
||||
try
|
||||
{
|
||||
if(ctrl.Tag != null)
|
||||
tag = ctrl.Tag.ToString();
|
||||
}
|
||||
catch { }
|
||||
|
|
|
@ -44,14 +44,7 @@ namespace ShiftOS.WinForms
|
|||
{
|
||||
try
|
||||
{
|
||||
switch (SaveSystem.CurrentSave.Language)
|
||||
{
|
||||
case "deutsch":
|
||||
return Properties.Resources.strings_de;
|
||||
default:
|
||||
return getDefault();
|
||||
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
|
|
|
@ -66,41 +66,54 @@ namespace ShiftOS.Engine
|
|||
|
||||
public static bool IsSafe(Type type)
|
||||
{
|
||||
if (InKernelMode == true)
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
|
||||
foreach (var attrib in type.GetCustomAttributes(false))
|
||||
{
|
||||
if (attrib is KernelModeAttribute)
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsSafe(MethodInfo type)
|
||||
{
|
||||
if (InKernelMode == true)
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
|
||||
foreach (var attrib in type.GetCustomAttributes(false))
|
||||
{
|
||||
if (attrib is KernelModeAttribute)
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static string regularUsername = "";
|
||||
|
||||
|
||||
public static void EnterKernelMode()
|
||||
{
|
||||
InKernelMode = true;
|
||||
Console.WriteLine("<kernel> Watchdog deactivated, system-level access granted.");
|
||||
regularUsername = SaveSystem.CurrentUser.Username;
|
||||
SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == "root");
|
||||
|
||||
}
|
||||
|
||||
public static void LeaveKernelMode()
|
||||
{
|
||||
InKernelMode = false;
|
||||
Console.WriteLine("<kernel> Kernel mode disabled.");
|
||||
var user = SaveSystem.Users.FirstOrDefault(x => x.Username == regularUsername);
|
||||
if (user == null)
|
||||
throw new Exception("User not in root mode.");
|
||||
SaveSystem.CurrentUser = user;
|
||||
}
|
||||
|
||||
internal static bool CanRunOffline(Type method)
|
||||
|
|
|
@ -198,7 +198,10 @@ namespace ShiftOS.Engine
|
|||
Thread.Sleep(50);
|
||||
Console.WriteLine("{SYSTEM_INITIATED}");
|
||||
|
||||
|
||||
|
||||
if (CurrentSave.Users == null)
|
||||
CurrentSave.Users = new List<ClientSave>();
|
||||
|
||||
|
||||
if(CurrentSave.Users.Count == 0)
|
||||
{
|
||||
|
@ -294,8 +297,10 @@ namespace ShiftOS.Engine
|
|||
|
||||
public static List<ClientSave> Users
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
get
|
||||
{
|
||||
return CurrentSave.Users;
|
||||
}
|
||||
}
|
||||
|
||||
public static event EmptyEventHandler GameReady;
|
||||
|
|
|
@ -133,6 +133,7 @@
|
|||
<Compile Include="TutorialManager.cs" />
|
||||
<Compile Include="UniteClient.cs" />
|
||||
<Compile Include="UniteTestCommands.cs" />
|
||||
<Compile Include="UserManagementCommands.cs" />
|
||||
<Compile Include="VirusEngine.cs" />
|
||||
<Compile Include="WinOpenAttribute.cs" />
|
||||
<EmbeddedResource Include="Infobox.resx">
|
||||
|
|
|
@ -323,6 +323,23 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin)
|
||||
{
|
||||
Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) =>
|
||||
{
|
||||
if (pass == SaveSystem.CurrentUser.Password)
|
||||
{
|
||||
KernelWatchdog.EnterKernelMode();
|
||||
RunClient(text, args, isRemote);
|
||||
KernelWatchdog.LeaveKernelMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Infobox.Show("Access denied.", "You did not type in the correct password.");
|
||||
}
|
||||
}, true);
|
||||
return true;
|
||||
}
|
||||
Console.Write("<");
|
||||
ConsoleEx.Bold = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkRed;
|
||||
|
@ -332,25 +349,27 @@ namespace ShiftOS.Engine
|
|||
Console.Write(">");
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine(" You cannot run this command.");
|
||||
Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported.");
|
||||
KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(text + " cannot be ran in a remote session");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Console.WriteLine(text + " cannot be ran in a remote session");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
Console.Write("<");
|
||||
|
@ -366,10 +385,27 @@ namespace ShiftOS.Engine
|
|||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin)
|
||||
{
|
||||
Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) =>
|
||||
{
|
||||
if (pass == SaveSystem.CurrentUser.Password)
|
||||
{
|
||||
KernelWatchdog.EnterKernelMode();
|
||||
RunClient(text, args, isRemote);
|
||||
KernelWatchdog.LeaveKernelMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
Infobox.Show("Access denied.", "You did not type in the correct password.");
|
||||
}
|
||||
}, true);
|
||||
return true;
|
||||
}
|
||||
Console.Write("<");
|
||||
ConsoleEx.Bold = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkRed;
|
||||
|
@ -379,7 +415,7 @@ namespace ShiftOS.Engine
|
|||
Console.Write(">");
|
||||
ConsoleEx.Italic = true;
|
||||
ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine(" You cannot run this command.");
|
||||
Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported.");
|
||||
KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,26 @@ namespace ShiftOS.Unite
|
|||
}
|
||||
}
|
||||
|
||||
public int GetPongCP()
|
||||
{
|
||||
return Convert.ToInt32(MakeCall("/API/GetPongCP"));
|
||||
}
|
||||
|
||||
public int GetPongLevel()
|
||||
{
|
||||
return Convert.ToInt32(MakeCall("/API/GetPongLevel"));
|
||||
}
|
||||
|
||||
public void SetPongLevel(int value)
|
||||
{
|
||||
MakeCall("/API/SetPongLevel/" + value.ToString());
|
||||
}
|
||||
|
||||
public void SetPongCP(int value)
|
||||
{
|
||||
MakeCall("/API/SetPongCP/" + value.ToString());
|
||||
}
|
||||
|
||||
public string GetEmail()
|
||||
{
|
||||
return MakeCall("/API/GetEmail");
|
||||
|
|
|
@ -10,6 +10,16 @@ namespace ShiftOS.Engine
|
|||
[Namespace("unite")]
|
||||
public static class UniteTestCommands
|
||||
{
|
||||
[Command("setdisplayname")]
|
||||
[RequiresArgument("name")]
|
||||
public static bool SetDisplayName(Dictionary<string, object> args)
|
||||
{
|
||||
string dname = args["name"].ToString();
|
||||
var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken);
|
||||
unite.SetDisplayName(dname);
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("login")]
|
||||
[RequiresArgument("username")]
|
||||
[RequiresArgument("password")]
|
||||
|
|
88
ShiftOS_TheReturn/UserManagementCommands.cs
Normal file
88
ShiftOS_TheReturn/UserManagementCommands.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ShiftOS.Objects;
|
||||
|
||||
namespace ShiftOS.Engine
|
||||
{
|
||||
[Namespace("admin")]
|
||||
[KernelMode]
|
||||
[RequiresUpgrade("mud_fundamentals")]
|
||||
public static class AdminUserManagementCommands
|
||||
{
|
||||
[Command("add", description = "Add a user to the system.", usage ="name:")]
|
||||
[RequiresArgument("name")]
|
||||
public static bool AddUser(Dictionary<string, object> args)
|
||||
{
|
||||
string name = args["name"].ToString();
|
||||
if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==name) != null)
|
||||
{
|
||||
Console.WriteLine("Error: User already exists.");
|
||||
return true;
|
||||
}
|
||||
|
||||
var user = new ClientSave
|
||||
{
|
||||
Username = name,
|
||||
Password = "",
|
||||
Permissions = UserPermissions.User
|
||||
};
|
||||
SaveSystem.CurrentSave.Users.Add(user);
|
||||
Console.WriteLine($"Creating new user \"{name}\" with no password and User permissions.");
|
||||
SaveSystem.SaveGame();
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("remove", description = "Remove a user from the system.", usage = "name:")]
|
||||
[RequiresArgument("name")]
|
||||
public static bool RemoveUser(Dictionary<string, object> args)
|
||||
{
|
||||
string name = args["name"].ToString();
|
||||
if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) == null)
|
||||
{
|
||||
Console.WriteLine("Error: User doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name);
|
||||
SaveSystem.CurrentSave.Users.Remove(user);
|
||||
Console.WriteLine($"Removing user \"{name}\" from system...");
|
||||
SaveSystem.SaveGame();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Namespace("user")]
|
||||
[RequiresUpgrade("mud_fundamentals")]
|
||||
public static class UserManagementCommands
|
||||
{
|
||||
|
||||
|
||||
[Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")]
|
||||
[RequiresArgument("old")]
|
||||
[RequiresArgument("new")]
|
||||
public static bool SetPassword(Dictionary<string, object> args)
|
||||
{
|
||||
string old = args["old"].ToString();
|
||||
string newpass = args["new"].ToString();
|
||||
|
||||
if(old == SaveSystem.CurrentUser.Password)
|
||||
{
|
||||
SaveSystem.CurrentUser.Password = newpass;
|
||||
SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == SaveSystem.CurrentUser.Username).Password = newpass;
|
||||
Console.WriteLine("Password set successfully.");
|
||||
SaveSystem.SaveGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Passwords do not match.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue