diff options
| author | Michael <[email protected]> | 2017-06-24 20:26:14 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-06-24 20:26:14 -0400 |
| commit | 4c63e5e41c55d41c0bcaa09f125299d4b1892ef6 (patch) | |
| tree | bf5da5cf46136de99b79fb2cd0f43283a711a62d /ShiftOS.WinForms/MissionCommands.cs | |
| parent | 4c7703c535eacb58375c872ea5cf9e733c9cf5d5 (diff) | |
| download | shiftos_thereturn-4c63e5e41c55d41c0bcaa09f125299d4b1892ef6.tar.gz shiftos_thereturn-4c63e5e41c55d41c0bcaa09f125299d4b1892ef6.tar.bz2 shiftos_thereturn-4c63e5e41c55d41c0bcaa09f125299d4b1892ef6.zip | |
mission commands
Diffstat (limited to 'ShiftOS.WinForms/MissionCommands.cs')
| -rw-r--r-- | ShiftOS.WinForms/MissionCommands.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/MissionCommands.cs b/ShiftOS.WinForms/MissionCommands.cs new file mode 100644 index 0000000..375c490 --- /dev/null +++ b/ShiftOS.WinForms/MissionCommands.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + [RequiresUpgrade("hacker101_breakingbonds_3")] + public static class MissionCommands + { + public static List<MissionAttribute> GetMissionsList() + { + var missions = new List<MissionAttribute>(); + foreach (var type in ReflectMan.Types) + { + foreach (var method in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) + { + var attrib = method.GetCustomAttributes(false).FirstOrDefault(x => x is MissionAttribute) as MissionAttribute; + if (attrib != null) + { + if (!Shiftorium.UpgradeInstalled(attrib.StoryID)) + { + missions.Add(attrib); + } + } + } + } + return missions; + } + + [Command("missions", description = "Lists all available missions.")] + public static void ShowAll() + { + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + ConsoleEx.Bold = true; + Console.WriteLine(" - Missions - "); + + var missions = GetMissionsList(); + + ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.Bold = false; + if(missions.Count == 0) + { + Console.WriteLine("No missions available. Check back later!"); + } + else + { + foreach(var mission in missions) + { + Console.WriteLine(); + Console.WriteLine(mission.Name); + Console.WriteLine("--------------------------"); + Console.WriteLine(); + Console.WriteLine(mission.Description); + Console.WriteLine(); + Console.WriteLine("assigner: " + mission.Assigner); + Console.WriteLine("reward: " + mission.CodepointAward + " Codepoints"); + Console.WriteLine("To start this mission, run:"); + ConsoleEx.Bold = true; + Console.WriteLine("startmission --id " + missions.IndexOf(mission)); + } + } + } + + [Command("startmission", description = "Starts the specified mission.")] + [RequiresArgument("id")] + public static void StartMission(Dictionary<string, object> args) + { + var id = Convert.ToInt32(args["id"].ToString()); + var missions = GetMissionsList(); + if (id < 0 || id >= missions.Count) + Console.WriteLine("Error: Mission ID not found."); + else + { + var mission = missions[id]; + Story.Start(mission.StoryID); + } + } + + } +} |
