aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Server/Program.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-01-14 10:28:57 -0500
committerMichael <[email protected]>2017-01-14 10:29:03 -0500
commitca7062c3e6527054d805dede838d951333f0cea7 (patch)
tree6a4a5e72472109faaa8926d3f45f237fbb5b1eaa /ShiftOS.Server/Program.cs
parent9aab77b2f1bd4231e0d4d97efc178a9ec702d96d (diff)
downloadshiftos_thereturn-ca7062c3e6527054d805dede838d951333f0cea7.tar.gz
shiftos_thereturn-ca7062c3e6527054d805dede838d951333f0cea7.tar.bz2
shiftos_thereturn-ca7062c3e6527054d805dede838d951333f0cea7.zip
#5 - Users can be given CP over the MUD
Currently not usable in the UI, but will be used to power shops.
Diffstat (limited to 'ShiftOS.Server/Program.cs')
-rw-r--r--ShiftOS.Server/Program.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs
index fde1655..3c2c604 100644
--- a/ShiftOS.Server/Program.cs
+++ b/ShiftOS.Server/Program.cs
@@ -281,6 +281,36 @@ Contents:
switch (msg.Name)
{
+ case "usr_givecp":
+ if (args["username"] != null && args["amount"] != null)
+ {
+ string userName = args["username"] as string;
+ int amount = (int)args["amount"];
+
+ if (Directory.Exists("saves"))
+ {
+ foreach(var saveFile in Directory.GetFiles("saves"))
+ {
+ var saveFileContents = JsonConvert.DeserializeObject<Save>(File.ReadAllText(saveFile));
+ if(saveFileContents.Username == userName)
+ {
+ saveFileContents.Codepoints += amount;
+ File.WriteAllText(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
+ server.DispatchAll(new NetObject("pikachu_use_thunderbolt_oh_yeah_and_if_you_happen_to_be_doing_backend_and_see_this_post_a_picture_of_ash_ketchum_from_the_unova_series_in_the_discord_dev_room_holy_crap_this_is_a_long_snake_case_thing_about_ash_ketchum_and_pikachu", new ServerMessage
+ {
+ Name = "update_your_cp",
+ GUID = "server",
+ Contents = $@"{{
+ username: ""{userName}"",
+ amount: {amount}
+}}"
+ }));
+ return;
+ }
+ }
+ }
+ }
+ break;
case "mud_login":
if (args["username"] != null && args["password"] != null)
{