Delete a LOT of obsolete code

This commit is contained in:
Michael 2017-07-13 21:30:04 -04:00
parent e92af1bc7f
commit e929a9f510
19 changed files with 180 additions and 743 deletions

View file

@ -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());

View file

@ -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<ChatMessage> Messages { get; set; }
}
}

View file

@ -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
}
}

View file

@ -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; }
}
}

View file

@ -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<JobTask> 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; }
}
}

View file

@ -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<string, LegionRole> Roles { get; set; }
public Dictionary<LegionRole, string> RoleNames { get; set; }
public UserClass Class { get; set; }
public double RawReputation { get; set; }
public Reputation Reputation
{
get
{
return (Reputation)((int)Math.Round(RawReputation));
}
}
}
}

View file

@ -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; }
}
}

View file

@ -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
{
/// <summary>
/// The user has no class.
/// </summary>
None = 0,
/// <summary>
/// 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.
/// </summary>
Skinner = 1,
/// <summary>
/// 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.
/// </summary>
Hacker = 2,
/// <summary>
/// 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.
/// </summary>
Investigator = 3,
/// <summary>
/// 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.
/// </summary>
Explorer = 4,
/// <summary>
/// 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.
/// </summary>
SafetyActivist = 5,
/// <summary>
/// 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.
/// </summary>
PenetrationTester = 6,
/// <summary>
/// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints.
/// </summary>
Collector = 7,
/// <summary>
/// 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.
/// </summary>
Programmer = 8
}
}

View file

@ -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<File> Files = new List<File>();
public List<Directory> Subdirectories = new List<Directory>();
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<Directory> 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
{

View file

@ -46,21 +46,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChatRoom.cs" />
<Compile Include="ClientSave.cs" />
<Compile Include="EngineShiftnetSubscription.cs" />
<Compile Include="Job.cs" />
<Compile Include="Legion.cs" />
<Compile Include="Hackable.cs" />
<Compile Include="MudAttributes.cs" />
<Compile Include="Objects.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reputation.cs" />
<Compile Include="Save.cs" />
<Compile Include="ShiftFS.cs" />
<Compile Include="Shop.cs" />
<Compile Include="UniteClient.cs" />
<Compile Include="Unite\Download.cs" />
<Compile Include="Unite\ReleaseQuery.cs" />
<Compile Include="UserConfig.cs" />
</ItemGroup>
<ItemGroup>

View file

@ -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<ShopItem> 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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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
{
/// <summary>
/// Gets a string represents the user token for this Unite Client.
/// </summary>
public string Token { get; private set; }
/// <summary>
/// Gets the base URL used in all API calls. Retrieved from the user's servers.json file.
/// </summary>
public string BaseURL
{
get
{
return "";
}
}
/// <summary>
/// Get the display name of a user.
/// </summary>
/// <param name="id">The user ID to look at.</param>
/// <returns></returns>
public string GetDisplayNameId(string id)
{
return MakeCall("/API/GetDisplayName/" + id);
}
/// <summary>
/// Get the Pong highscore stats for all users.
/// </summary>
/// <returns></returns>
public PongHighscoreModel GetPongHighscores()
{
return JsonConvert.DeserializeObject<PongHighscoreModel>(MakeCall("/API/GetPongHighscores"));
}
/// <summary>
/// Create a new instance of the <see cref="UniteClient"/> object.
/// </summary>
/// <param name="baseurl">Unused.</param>
/// <param name="usertoken">The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens)</param>
public UniteClient(string baseurl, string usertoken)
{
//Handled by the servers.json file
//BaseURL = baseurl;
Token = usertoken;
}
/// <summary>
/// Make a call to the Unite API using the current user token and base URL.
/// </summary>
/// <param name="url">The path, relative to the base URL, to call.</param>
/// <returns>The server's response.</returns>
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();
}
}
}
}
/// <summary>
/// Get the Pong codepoint highscore for the current user.
/// </summary>
/// <returns>The amount of Codepoints returned by the server</returns>
public ulong GetPongCP()
{
return Convert.ToUInt64(MakeCall("/API/GetPongCP"));
}
/// <summary>
/// Get the pong highest level score for this user
/// </summary>
/// <returns>The highest level the user has reached.</returns>
public int GetPongLevel()
{
return Convert.ToInt32(MakeCall("/API/GetPongLevel"));
}
/// <summary>
/// Set the user's highest level record for Pong.
/// </summary>
/// <param name="value">The level to set the record to.</param>
public void SetPongLevel(int value)
{
MakeCall("/API/SetPongLevel/" + value.ToString());
}
/// <summary>
/// Set the pong Codepoints record for the user
/// </summary>
/// <param name="value">The amount of Codepoints to set the record to</param>
public void SetPongCP(ulong value)
{
MakeCall("/API/SetPongCP/" + value.ToString());
}
/// <summary>
/// Get the user's email address.
/// </summary>
/// <returns>The user's email address.</returns>
public string GetEmail()
{
return MakeCall("/API/GetEmail");
}
/// <summary>
/// Get the user's system name.
/// </summary>
/// <returns>The user's system name.</returns>
public string GetSysName()
{
return MakeCall("/API/GetSysName");
}
/// <summary>
/// Set the user's system name.
/// </summary>
/// <param name="value">The system name to set the record to.</param>
public void SetSysName(string value)
{
MakeCall("/API/SetSysName/" + value);
}
/// <summary>
/// Get the user's display name.
/// </summary>
/// <returns>The user's display name.</returns>
public string GetDisplayName()
{
return MakeCall("/API/GetDisplayName");
}
/// <summary>
/// Set the user's display name.
/// </summary>
/// <param name="value">The display name to set the user's account to.</param>
public void SetDisplayName(string value)
{
MakeCall("/API/SetDisplayName/" + value.ToString());
}
/// <summary>
/// Get the user's full name if they have set it in their profile.
/// </summary>
/// <returns>Empty string if the user hasn't set their fullname, else, a string representing their fullname.</returns>
public string GetFullName()
{
return MakeCall("/API/GetFullName");
}
/// <summary>
/// Set the user's fullname.
/// </summary>
/// <param name="value">The new fullname.</param>
public void SetFullName(string value)
{
MakeCall("/API/SetFullName/" + value.ToString());
}
/// <summary>
/// Get the user's codepoints.
/// </summary>
/// <returns>The amount of codepoints stored on the server for this user.</returns>
public ulong GetCodepoints()
{
return Convert.ToUInt64(MakeCall("/API/GetCodepoints"));
}
/// <summary>
/// Set the user's codepoints.
/// </summary>
/// <param name="value">The amount of codepoints to set the user's codepoints value to.</param>
public void SetCodepoints(ulong value)
{
MakeCall("/API/SetCodepoints/" + value.ToString());
}
}
/// <summary>
/// API data model for Unite pong highscores.
/// </summary>
public class PongHighscoreModel
{
/// <summary>
/// Amount of pages in this list.
/// </summary>
public int Pages { get; set; }
/// <summary>
/// An array representing the highscores found on the server.
/// </summary>
public PongHighscore[] Highscores { get; set; }
}
/// <summary>
/// API data model for a single Pong highscore.
/// </summary>
public class PongHighscore
{
/// <summary>
/// The user ID linked to this highscore.
/// </summary>
public string UserId { get; set; }
/// <summary>
/// The highscore's level record.
/// </summary>
public int Level { get; set; }
/// <summary>
/// The highscore's codepoint cashout record.
/// </summary>
public long CodepointsCashout { get; set; }
}
}

View file

@ -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<HackableSystem> _activeConnections = new List<HackableSystem>();
private static List<Objects.Hackable> Hackables = new List<Objects.Hackable>();
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<Port> 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; }
}
}

View file

@ -35,7 +35,8 @@ namespace ShiftOS.Engine
}
}
public static event Action<ClientSave> LoginComplete;
[Obsolete("Old code.")]
public static event Action<dynamic> LoginComplete;
}
/// <summary>
@ -57,7 +58,7 @@ namespace ShiftOS.Engine
/// <summary>
/// Occurs when the login is complete.
/// </summary>
event Action<ClientSave> LoginComplete;
event Action<dynamic> LoginComplete;

View file

@ -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));
}

View file

@ -7,15 +7,17 @@ using ShiftOS.Objects;
namespace ShiftOS.Engine
{
[Obsolete("Old code.")]
public interface Server
{
/// <summary>
/// Occurs when someone sends a message to the server.
/// </summary>
/// <param name="msg">The message from the client.</param>
void MessageReceived(ServerMessage msg);
void MessageReceived(dynamic msg);
}
[Obsolete("Old code.")]
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
public class ServerAttribute : Attribute
{

View file

@ -133,6 +133,7 @@
</Compile>
<Compile Include="Desktop.cs" />
<Compile Include="FileSkimmerBackend.cs" />
<Compile Include="Hacking.cs" />
<Compile Include="IFileHandler.cs" />
<Compile Include="Infobox.cs" />
<Compile Include="IShiftOSWindow.cs" />