mission commands

This commit is contained in:
Michael 2017-06-24 20:26:14 -04:00
parent 4c7703c535
commit 4c63e5e41c
3 changed files with 94 additions and 2 deletions

View file

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

View file

@ -357,7 +357,7 @@
<Compile Include="MainMenu\MainMenu.Designer.cs">
<DependentUpon>MainMenu.cs</DependentUpon>
</Compile>
<Compile Include="MissionAttribute.cs" />
<Compile Include="MissionCommands.cs" />
<Compile Include="Oobe.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -81,7 +81,7 @@ namespace ShiftOS.WinForms.Stories
Story.Start("aiden_shiftnet2");
}
[Story("hacker101_breakingbonds_3")]
[Mission("hacker101_breakingbonds_3", "Breaking the Bonds", "It's time you've learned how to hack.", 500l, "hacker101")]
public static void BreakingTheBonds_Outro()
{
Story.Context.AutoComplete = false;
@ -172,7 +172,16 @@ namespace ShiftOS.WinForms.Stories
WriteLine("Oh yeah, one more thing... that virus scanner... you may want to scan any files that you transfer from other systems with it.");
WriteLine("You never know what sorts of digital filth is hidden within such innocent-looking files.");
WriteLine("ALWAYS scan before opening - because if you open a file containing malicious code, it'll get run. It's just how ShiftOS's kernel works.");
WriteLine("Oh yeah, one last thing. Things are going to start getting pretty open in the Digital Society..");
WriteLine("Multiple people are going to want you to help them out with multiple things.");
WriteLine("I've written a little command-line utility that'll help you keep track of these missions and see how far you've gotten.");
WriteLine("Use the missions command to list out all the available missions, then use the startmission command to start one.");
WriteLine("When you complete a mission, you'll earn Codepoints depending on the mission.");
WriteLine("Allow me to demonstrate...");
Console.WriteLine("User has disconnected.");
Story.Context.MarkComplete();
TerminalBackend.PrefixEnabled = true;
SaveSystem.SaveGame();