From 18079c6f43981f1bf9fc093b3c5b68873fe90348 Mon Sep 17 00:00:00 2001 From: william341 Date: Thu, 27 Jul 2017 16:34:27 -0700 Subject: hacking p1 --- ShiftOS.Frontend/Hacking/HackableProvider.cs | 39 +++++++++++++++++ ShiftOS.Frontend/Hacking/HackerTestCommands.cs | 59 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 ShiftOS.Frontend/Hacking/HackableProvider.cs create mode 100644 ShiftOS.Frontend/Hacking/HackerTestCommands.cs (limited to 'ShiftOS.Frontend/Hacking') diff --git a/ShiftOS.Frontend/Hacking/HackableProvider.cs b/ShiftOS.Frontend/Hacking/HackableProvider.cs new file mode 100644 index 0000000..6198b0c --- /dev/null +++ b/ShiftOS.Frontend/Hacking/HackableProvider.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; +using ShiftOS.Engine; +using Newtonsoft.Json; + +namespace ShiftOS.Frontend +{ + public class HackableProvider : IHackableProvider + { + public Hackable[] GetHackables() + { + return JsonConvert.DeserializeObject(Properties.Resources.Hackables); + } + + public Exploit[] GetExploits() + { + return JsonConvert.DeserializeObject(Properties.Resources.Exploits); + } + + public Payload[] GetPayloads() + { + return JsonConvert.DeserializeObject(Properties.Resources.Payloads); + } + + public byte[] GetLootFromResource(string resId) + { + return new byte[] { 0xDE, 0xAD, 0xBE, 0xEF }; //nyi + } + + public LootInfo[] GetLootInfo() + { + return JsonConvert.DeserializeObject(Properties.Resources.LootInfo); + } + } +} diff --git a/ShiftOS.Frontend/Hacking/HackerTestCommands.cs b/ShiftOS.Frontend/Hacking/HackerTestCommands.cs new file mode 100644 index 0000000..675356a --- /dev/null +++ b/ShiftOS.Frontend/Hacking/HackerTestCommands.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +#if DEBUG +namespace ShiftOS.Frontend +{ + public static class HackerTestCommands + { + [Command("lshackables")] + public static void ListAllHackables() + { + foreach(var hackable in Hacking.AvailableToHack) + { + Console.WriteLine(hackable.ID + ": " + hackable.FriendlyName); + } + } + + [Command("describebackable")] + [RequiresArgument("id")] + public static void DescribeHackable(Dictionary args) + { + string id = args["id"].ToString(); + var hackable = Hacking.AvailableToHack.FirstOrDefault(x => x.ID == id); + if(hackable == null) + { + Console.WriteLine("Hackable not found."); + return; + } + Console.WriteLine(hackable.FriendlyName); + Console.WriteLine("------------------------"); + Console.WriteLine(); + Console.WriteLine("System name: " + hackable.SystemName); + Console.WriteLine("Loot rarity: " + hackable.LootRarity); + Console.WriteLine("Loot amount: " + hackable.LootAmount); + Console.WriteLine("Connection timeout level: " + hackable.ConnectionTimeoutLevel); + Console.WriteLine(); + Console.WriteLine(hackable.WelcomeMessage); + } + + [Command("inithack")] + [RequiresArgument("id")] + public static void InitHack(Dictionary args) + { + string id = args["id"].ToString(); + var hackable = Hacking.AvailableToHack.FirstOrDefault(x => x.ID == id); + if (hackable == null) + { + Console.WriteLine("Hackable not found."); + return; + } + Hacking.InitHack(hackable); + } + } +} +#endif \ No newline at end of file -- cgit v1.2.3