diff --git a/ShiftOS.Frontend/ShiftOS.cs b/ShiftOS.Frontend/ShiftOS.cs index 56ffc38..e2d3c4a 100644 --- a/ShiftOS.Frontend/ShiftOS.cs +++ b/ShiftOS.Frontend/ShiftOS.cs @@ -77,6 +77,9 @@ namespace ShiftOS.Frontend //Also initiate the desktop Engine.Desktop.Init(new Desktop.Desktop()); + //While we're having a damn initiation fuckfest, let's get the hacking engine running. + Hacking.Initiate(); + //Now we can initiate the Infobox subsystem Engine.Infobox.Init(new Infobox()); diff --git a/ShiftOS.Objects/ChatRoom.cs b/ShiftOS.Objects/ChatRoom.cs deleted file mode 100644 index e4c89ce..0000000 --- a/ShiftOS.Objects/ChatRoom.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects -{ - public class ChatRoom - { - public string Id { get; set; } - public string Name { get; set; } - - public List Messages { get; set; } - } -} diff --git a/ShiftOS.Objects/ClientSave.cs b/ShiftOS.Objects/ClientSave.cs deleted file mode 100644 index fbe1044..0000000 --- a/ShiftOS.Objects/ClientSave.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects -{ - public class ClientSave - { - public string Username { get; set; } - public string Password { get; set; } - public UserPermissions Permissions { get; set; } - } - - public enum UserPermissions - { - Root, - Admin, - User, - Guest - } -} diff --git a/ShiftOS.Objects/Hackable.cs b/ShiftOS.Objects/Hackable.cs new file mode 100644 index 0000000..cb05b0c --- /dev/null +++ b/ShiftOS.Objects/Hackable.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class Hackable + { + public string SystemName { get; set; } + public string FriendlyName { get; set; } + public string Password { get; set; } + public string PasswordHint { get; set; } + public string WelcomeMessage { get; set; } + + public int FirewallStrength { get; set; } + public int LootRarity { get; set; } + public int LootAmount { get; set; } + public int ConnectionTimeoutLevel { get; set; } + + public SystemType SystemType { get; set; } + + public string OnHackCompleteStoryEvent { get; set; } + + + public string Dependencies { get; set; } + + + public string ID + { + get + { + return SystemName.ToLower().Replace(" ", "_"); + } + } + } + + [Flags] + public enum SystemType + { + FileServer, + SSHServer, + EmailServer, + Database + } + + [Serializable] + public class ServerMessage + { + public string Name { get; set; } + public string GUID { get; set; } + public string Contents { get; set; } + } +} diff --git a/ShiftOS.Objects/Job.cs b/ShiftOS.Objects/Job.cs deleted file mode 100644 index d155322..0000000 --- a/ShiftOS.Objects/Job.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects - -{ - public class Job - { - public string Name { get; set; } - public string Description { get; set; } - public List Tasks { get; set; } - public string Author { get; set; } - } - - public abstract class JobTask - { - public string Name { get; set; } - public string Description { get; set; } - public int Reward { get; set; } - - public abstract bool IsComplete { get; } - } -} diff --git a/ShiftOS.Objects/Legion.cs b/ShiftOS.Objects/Legion.cs deleted file mode 100644 index c5e12f3..0000000 --- a/ShiftOS.Objects/Legion.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects -{ - public enum LegionRole - { - Admin, - Manager, - Committed, - Trainee, - AwaitingInvite - } - - public enum LegionPublicity - { - Public, //Will display on the 'Join Legion' page, anyone can join - PublicInviteOnly, //Will display on the 'Join Legion' page but you must be invited - Unlisted, //Won't display on 'Join Legion', but anyone can join - UnlistedInviteOnly //Won't display in 'Join Legion', and admin/manager invitation is required. - } - - public class Legion - { - public string Name { get; set; } - public LegionPublicity Publicity { get; set; } - public ConsoleColor BannerColor { get; set; } - public string Description { get; set; } - public string ShortName { get; set; } - - public Dictionary Roles { get; set; } - public Dictionary RoleNames { get; set; } - - public UserClass Class { get; set; } - public double RawReputation { get; set; } - - public Reputation Reputation - { - get - { - return (Reputation)((int)Math.Round(RawReputation)); - } - } - - } -} diff --git a/ShiftOS.Objects/Objects.cs b/ShiftOS.Objects/Objects.cs index c4cd67c..f26d835 100644 --- a/ShiftOS.Objects/Objects.cs +++ b/ShiftOS.Objects/Objects.cs @@ -30,114 +30,9 @@ using System.Threading.Tasks; namespace ShiftOS.Objects { - public class MUDMemo - { - public string UserFrom { get; set; } - public string UserTo { get; set; } - public MemoType Type { get; set; } - public string Body { get; set; } - public string Subject { get; set; } - } - - public enum MemoType - { - Regular, - Job, - LegionInvite, - } - - - public class PongHighscore - { - public string UserName { get; set; } - public int HighestLevel { get; set; } - public int HighestCodepoints { get; set; } - } - public class GUIDRequest { public string name { get; set; } public string guid { get; set; } } - - public class OnlineUser - { - public string Guid { get; set; } - public string Username { get; set; } - public string OnlineChat { get; set; } - } - - public class FriendlyNameAttribute : Attribute - { - public FriendlyNameAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } - - public class FriendlyDescriptionAttribute : Attribute - { - public FriendlyDescriptionAttribute(string desc) - { - Description = desc; - } - - public string Description { get; private set; } - } - - public class Channel - { - [FriendlyName("Chat name")] - [FriendlyDescription("The human-readable name of your chat. This should be something small, possibly a one or two word description of your chat.")] - public string Name { get; set; } - - //Don't describe this one. We want it to be hidden from the admin panel's chat editor. - public string ID { get; set; } - - [FriendlyName("Requires Patreon?")] - [FriendlyDescription("If checked, this chat will only be shown in the MUD Control Centre if the user's save is marked as a Patreon supporter.")] - public bool RequiresPatreon { get; set; } - - [FriendlyName("Chat topic")] - [FriendlyDescription("A more in-depth version of your chat name. Describe what your chat's about in a sentence.")] - public string Topic { get; set; } - - [FriendlyName("Is it a Discord relay?")] - [FriendlyDescription("If checked, this channel will use a Discord bot to relay messages between ShiftOS and a chosen Discord channel. Useful if you'd like to integrate your MUD with the rest of your community.")] - public bool IsDiscordProxy { get; set; } - - [FriendlyName("Discord bot token")] - [FriendlyDescription("If this is a discord relay chat, paste the token for your Discord bot here. Note: It MUST be a bot token, not a user token.")] - public string DiscordBotToken { get; set; } - - [FriendlyName("Discord channel ID")] - [FriendlyDescription("If this channel is a Discord relay, paste the ID of the channel you'd like the bot to listen to here. You can get the channel ID by enabling Developer Mode in your Discord settings, then right-clicking your channel name and clicking 'Copy ID', then paste it here.")] - public string DiscordChannelID { get; set; } - } - - public class ChatMessage - { - public ChatMessage(string uname, string sys, string message, string chan) - { - Username = uname; - SystemName = sys; - Message = message; - Channel = chan; - } - - public string Username { get; private set; } - public string SystemName { get; private set; } - public string Channel { get; private set; } - public string Message { get; private set; } - } - - [Serializable] - public class ServerMessage - { - public string Name { get; set; } - public string Contents { get; set; } - public string GUID { get; set; } - } } diff --git a/ShiftOS.Objects/Reputation.cs b/ShiftOS.Objects/Reputation.cs deleted file mode 100644 index 0ddea0a..0000000 --- a/ShiftOS.Objects/Reputation.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects -{ - public enum Reputation - { - Saint = 5, - Moral = 4, - Trustworthy = 3, - WellKnown = 2, - Respected = 1, - Neutral = 0, - Disrespected = -1, - Criminal = -2, - Untrustworthy = -3, - Immoral = -4, - Outcast = -5 - } - - public enum UserClass - { - /// - /// The user has no class. - /// - None = 0, - - /// - /// Skinners, otherwise known as "Shifters" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints. - /// - Skinner = 1, - - /// - /// Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target. - /// - Hacker = 2, - /// - /// Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations. - /// - Investigator = 3, - /// - /// Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent. - /// - Explorer = 4, - /// - /// Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe. - /// - SafetyActivist = 5, - /// - /// Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful. - /// - PenetrationTester = 6, - /// - /// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints. - /// - Collector = 7, - /// - /// Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions. - /// - Programmer = 8 - } -} diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index bc08880..a54fae9 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -38,25 +38,15 @@ namespace ShiftOS.Objects.ShiftFS public byte[] Data; public byte[] HeaderData; public bool ReadAccessToLowUsers; - public UserPermissions permissions; public System.IO.Stream GetStream() { - if ((int)CurrentUser <= (int)permissions) - { - return new System.IO.MemoryStream(Data); - } - else if (ReadAccessToLowUsers == true) - { - return new System.IO.MemoryStream(Data, false); - } - return null; + return new System.IO.MemoryStream(Data); } - public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm) + public File(string name, byte[] data, bool ReadAccess_to_low_users) { Name = name; Data = data; - permissions = perm; ReadAccessToLowUsers = ReadAccess_to_low_users; } } @@ -66,71 +56,49 @@ namespace ShiftOS.Objects.ShiftFS public List Files = new List(); public List Subdirectories = new List(); public bool ReadAccessToLowUsers; - public UserPermissions permissions; public void AddFile(File file) { - if ((int)CurrentUser <= (int)permissions) - { - Files.Add(file); - } + Files.Add(file); } + public void RemoveFile(string name) { - if ((int)CurrentUser <= (int)permissions) - { - Files.Remove(Files.Find(x => x.Name == name)); - } + Files.Remove(Files.Find(x => x.Name == name)); } + public void RemoveFile(File file) { - if ((int)CurrentUser <= (int)permissions) - { - Files.Remove(file); - } + Files.Remove(file); } + public File FindFileByName(string name) { - if ((int)CurrentUser <= (int)permissions) - { - return Files.Find(x => x.Name == name); - } - return null; + return Files.Find(x => x.Name == name); } + public void AddDirectory(Directory dir) { - if ((int)CurrentUser <= (int)permissions) - { - Subdirectories.Add(dir); - } + Subdirectories.Add(dir); } + public void RemoveDirectory(string name) { - if ((int)CurrentUser <= (int)permissions) - { - Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); - } + Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); } + public void RemoveDirectory(Directory dir) { - if ((int)CurrentUser <= (int)permissions) - { - Subdirectories.Remove(dir); - } + Subdirectories.Remove(dir); } + public Directory FindDirectoryByName(string name) { - if ((int)CurrentUser <= (int)permissions) - { - return Subdirectories.Find(x => x.Name == name); - } - return null; + return Subdirectories.Find(x => x.Name == name); } } public static class Utils { - public static UserPermissions CurrentUser { get; set; } - public static List Mounts { get; set; } static Utils() @@ -186,7 +154,7 @@ namespace ShiftOS.Objects.ShiftFS dir.AddDirectory(new Directory { Name = pathlist[pathlist.Length - 1], - permissions = CurrentUser, + }); DirectoryCreated?.Invoke(path); } @@ -225,7 +193,7 @@ namespace ShiftOS.Objects.ShiftFS { try { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false)); } catch { } } @@ -274,7 +242,7 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false)); } else { diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 4936c01..66027a8 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -46,21 +46,13 @@ - - - - + - - - - - diff --git a/ShiftOS.Objects/Shop.cs b/ShiftOS.Objects/Shop.cs deleted file mode 100644 index c603523..0000000 --- a/ShiftOS.Objects/Shop.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects -{ - public class Shop - { - public string Name { get; set; } - public string Description { get; set; } - public List Items { get; set; } - public string Owner { get; set; } - } - - public class ShopItem - { - public string Name { get; set; } - public string Description { get; set; } - public ulong Cost { get; set; } - public int FileType { get; set; } - public byte[] MUDFile { get; set; } - } -} diff --git a/ShiftOS.Objects/Unite/Download.cs b/ShiftOS.Objects/Unite/Download.cs deleted file mode 100644 index 089a98c..0000000 --- a/ShiftOS.Objects/Unite/Download.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects.Unite -{ - public class Download - { - public string Id { get; set; } - public string Name { get; set; } - public string Changelog { get; set; } - public string DownloadUrl { get; set; } - public bool Obsolete { get; set; } - public DateTime PostDate { get; set; } - public string ReleasedBy { get; set; } - public string DevUpdateId { get; set; } - public string ScreenshotUrl { get; set; } - public bool IsStable { get; set; } - } -} diff --git a/ShiftOS.Objects/Unite/ReleaseQuery.cs b/ShiftOS.Objects/Unite/ReleaseQuery.cs deleted file mode 100644 index 253ce57..0000000 --- a/ShiftOS.Objects/Unite/ReleaseQuery.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Objects.Unite -{ - public class ReleaseQuery - { - public bool ShowUnstable { get; set; } - public bool ShowObsolete { get; set; } - public DateTime CurrentBuildDate { get; set; } - } -} diff --git a/ShiftOS.Objects/UniteClient.cs b/ShiftOS.Objects/UniteClient.cs deleted file mode 100644 index 8843930..0000000 --- a/ShiftOS.Objects/UniteClient.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Objects; - -namespace ShiftOS.Unite -{ - public class UniteClient - { - /// - /// Gets a string represents the user token for this Unite Client. - /// - public string Token { get; private set; } - - /// - /// Gets the base URL used in all API calls. Retrieved from the user's servers.json file. - /// - public string BaseURL - { - get - { - return ""; - } - } - - /// - /// Get the display name of a user. - /// - /// The user ID to look at. - /// - public string GetDisplayNameId(string id) - { - return MakeCall("/API/GetDisplayName/" + id); - } - - /// - /// Get the Pong highscore stats for all users. - /// - /// - public PongHighscoreModel GetPongHighscores() - { - return JsonConvert.DeserializeObject(MakeCall("/API/GetPongHighscores")); - } - - /// - /// Create a new instance of the object. - /// - /// Unused. - /// The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens) - public UniteClient(string baseurl, string usertoken) - { - //Handled by the servers.json file - //BaseURL = baseurl; - Token = usertoken; - } - - /// - /// Make a call to the Unite API using the current user token and base URL. - /// - /// The path, relative to the base URL, to call. - /// The server's response. - internal string MakeCall(string url) - { - var webrequest = WebRequest.Create(BaseURL + url); - webrequest.Headers.Add("Authentication: Token " + Token); - using (var response = webrequest.GetResponse()) - { - using (var stream = response.GetResponseStream()) - { - using (var reader = new System.IO.StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } - } - - /// - /// Get the Pong codepoint highscore for the current user. - /// - /// The amount of Codepoints returned by the server - public ulong GetPongCP() - { - return Convert.ToUInt64(MakeCall("/API/GetPongCP")); - } - - /// - /// Get the pong highest level score for this user - /// - /// The highest level the user has reached. - public int GetPongLevel() - { - return Convert.ToInt32(MakeCall("/API/GetPongLevel")); - } - - /// - /// Set the user's highest level record for Pong. - /// - /// The level to set the record to. - public void SetPongLevel(int value) - { - MakeCall("/API/SetPongLevel/" + value.ToString()); - } - - /// - /// Set the pong Codepoints record for the user - /// - /// The amount of Codepoints to set the record to - public void SetPongCP(ulong value) - { - MakeCall("/API/SetPongCP/" + value.ToString()); - } - - /// - /// Get the user's email address. - /// - /// The user's email address. - public string GetEmail() - { - return MakeCall("/API/GetEmail"); - } - - /// - /// Get the user's system name. - /// - /// The user's system name. - public string GetSysName() - { - return MakeCall("/API/GetSysName"); - } - - /// - /// Set the user's system name. - /// - /// The system name to set the record to. - public void SetSysName(string value) - { - MakeCall("/API/SetSysName/" + value); - } - - /// - /// Get the user's display name. - /// - /// The user's display name. - public string GetDisplayName() - { - return MakeCall("/API/GetDisplayName"); - } - - /// - /// Set the user's display name. - /// - /// The display name to set the user's account to. - public void SetDisplayName(string value) - { - MakeCall("/API/SetDisplayName/" + value.ToString()); - } - - /// - /// Get the user's full name if they have set it in their profile. - /// - /// Empty string if the user hasn't set their fullname, else, a string representing their fullname. - public string GetFullName() - { - return MakeCall("/API/GetFullName"); - } - - /// - /// Set the user's fullname. - /// - /// The new fullname. - public void SetFullName(string value) - { - MakeCall("/API/SetFullName/" + value.ToString()); - } - - /// - /// Get the user's codepoints. - /// - /// The amount of codepoints stored on the server for this user. - public ulong GetCodepoints() - { - return Convert.ToUInt64(MakeCall("/API/GetCodepoints")); - } - - /// - /// Set the user's codepoints. - /// - /// The amount of codepoints to set the user's codepoints value to. - public void SetCodepoints(ulong value) - { - MakeCall("/API/SetCodepoints/" + value.ToString()); - } - } - - /// - /// API data model for Unite pong highscores. - /// - public class PongHighscoreModel - { - /// - /// Amount of pages in this list. - /// - public int Pages { get; set; } - - /// - /// An array representing the highscores found on the server. - /// - public PongHighscore[] Highscores { get; set; } - } - - /// - /// API data model for a single Pong highscore. - /// - public class PongHighscore - { - /// - /// The user ID linked to this highscore. - /// - public string UserId { get; set; } - - /// - /// The highscore's level record. - /// - public int Level { get; set; } - - /// - /// The highscore's codepoint cashout record. - /// - public long CodepointsCashout { get; set; } - } -} diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs new file mode 100644 index 0000000..db47f66 --- /dev/null +++ b/ShiftOS_TheReturn/Hacking.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public static class Hacking + { + private static List _activeConnections = new List(); + private static List Hackables = new List(); + + public static Objects.Hackable[] AvailableToHack + { + get + { + return Hackables.Where(x => Shiftorium.UpgradeInstalled(x.Dependencies) && !Shiftorium.UpgradeInstalled(x.ID)).ToArray(); + } + } + + + public static HackableSystem[] ActiveConnections + { + get + { + return _activeConnections.ToArray(); + } + } + + public static HackableSystem[] PwnedConnections + { + get + { + return _activeConnections.Where(x => x.IsPwn3d).ToArray(); + } + } + + public static HackableSystem[] TimedConnections + { + get + { + return _activeConnections.Where(x => x.Data.ConnectionTimeoutLevel > 0&&!x.IsPwn3d).ToArray(); + } + } + + public static void Initiate() + { + foreach(var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IHackableProvider)))) + { + var @interface = (IHackableProvider)Activator.CreateInstance(type, null); + Hackables.AddRange(@interface.GetHackables()); + + } + + var hackable = Hackables.FirstOrDefault(x => Hackables.Where(y => x.SystemName == y.SystemName).Count() > 1); + if(hackable != null) + { + throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more hackables were found with the same hostname \"" + hackable.SystemName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend."); + } + } + } + + public class DataConflictException : Exception + { + public DataConflictException(string message) : base(message) + { + + } + } + + public interface IHackableProvider + { + Objects.Hackable[] GetHackables(); + } + + public class HackableSystem + { + public Objects.Hackable Data { get; set; } + public List PortsToUnlock { get; set; } + public bool FirewallCracked { get; set; } + public Objects.ShiftFS.Directory Filesystem { get; set; } + public int MillisecondsCountdown { get; set; } + public bool IsPwn3d { get; set; } + } + + public class Port + { + public string Name { get; set; } + public int Value { get; set; } + public int Difficulty { get; set; } + public bool Cracked { get; set; } + } +} diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs index d326f2c..de30cf1 100644 --- a/ShiftOS_TheReturn/LoginManager.cs +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -35,7 +35,8 @@ namespace ShiftOS.Engine } } - public static event Action LoginComplete; + [Obsolete("Old code.")] + public static event Action LoginComplete; } /// @@ -57,7 +58,7 @@ namespace ShiftOS.Engine /// /// Occurs when the login is complete. /// - event Action LoginComplete; + event Action LoginComplete; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 292af41..99d1868 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -90,7 +90,6 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } diff --git a/ShiftOS_TheReturn/Server.cs b/ShiftOS_TheReturn/Server.cs index ddbd15b..6edef9e 100644 --- a/ShiftOS_TheReturn/Server.cs +++ b/ShiftOS_TheReturn/Server.cs @@ -7,15 +7,17 @@ using ShiftOS.Objects; namespace ShiftOS.Engine { + [Obsolete("Old code.")] public interface Server { /// /// Occurs when someone sends a message to the server. /// /// The message from the client. - void MessageReceived(ServerMessage msg); + void MessageReceived(dynamic msg); } + [Obsolete("Old code.")] [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] public class ServerAttribute : Attribute { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 02a5eeb..27d54cc 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -133,6 +133,7 @@ +