Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- Ponerland.cs ----
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using Discord;
- namespace DiscordBot.Commands
- {
- class PonerLand
- {
- //PonerName Food Cleanliness Mood Level
- public static void Tick()
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- List<string> names = new List<string>();
- while(!sr.EndOfStream)
- {
- names.Add(sr.ReadLine().Split()[0]);
- }
- sr.Close();
- foreach (string name in names)
- {
- AddStat(name, 1, -1);
- AddStat(name, 2, -1);
- AddStat(name, 3, 6);
- AddStat(name, 4, 1);
- }
- }
- public static void AddStat(string poner, int stat, int value)
- {
- SetStat(poner, stat, GetStat(poner, stat) + value);
- }
- public static void SetStat(string poner, int stat, int value)
- {
- bool ded = false;
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- list.Add(sr.ReadLine());
- }
- sr.Close();
- StreamWriter sw = new StreamWriter("PonerLand.txt");
- foreach(string token in list)
- {
- if(token.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- string[] ponerString = token.Split();
- int[] ponerStats = new int[ponerString.Length - 1];
- for(int i = 1; i < ponerString.Length; i++)
- {
- ponerStats[i - 1] = int.Parse(ponerString[i]);
- }
- ponerStats[stat - 1] = value;
- if (ponerStats[stat - 1] > 100) ponerStats[stat - 1] = 100;
- if (ponerStats[stat - 1] <= 0) ded = true;
- sw.WriteLine("{0} {1}", poner, string.Join(" ", ponerStats));
- }
- else
- {
- sw.WriteLine(token);
- }
- }
- sw.Close();
- if (ded) Kill(poner);
- }
- public static bool IsPoner(string poner)
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- while (!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if (line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return true;
- }
- }
- sr.Close();
- return false;
- }
- public static bool IsDedPoner(string poner)
- {
- StreamReader sr = new StreamReader("PonerGraveyard.txt");
- while (!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if (line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return true;
- }
- }
- sr.Close();
- return false;
- }
- public static string Boop(string poner, string user)
- {
- if (IsPoner(poner))
- {
- bool ded = (GetStat(poner, 3) - 2 <= 0);
- AddStat(poner, 3, -2);
- if (ded)
- {
- return string.Format("Congratulations. You booped {0} to death. Are you proud of yourself?", poner);
- }
- else
- {
- return string.Format("{0}: [scrunch]", poner);
- }
- }
- else
- {
- if(IsDedPoner(poner))
- {
- return string.Format("You can't boop the dead, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static string Brushie(string poner, string user)
- {
- if (IsPoner(poner))
- {
- if (GetStat(poner, 2) > 80)
- {
- if (GetStat(poner, 2) > 95)
- {
- AddStat(poner, 2, 2);
- bool ded = (GetStat(poner, 3) - 5 <= 0);
- AddStat(poner, 3, -5);
- if (ded)
- {
- return string.Format("You brushed {0} to death. Are you happy?", poner);
- }
- return string.Format("{0}: \"Stop brushing me!\"", poner);
- }
- Random r = new Random();
- if (r.Next(2) < 1)
- {
- AddStat(poner, 2, 5);
- return string.Format("[pleased {0} noises]", poner);
- }
- else
- {
- AddStat(poner, 2, 2);
- bool ded = (GetStat(poner, 3) - 3 <= 0);
- AddStat(poner, 3, -3);
- if (ded)
- {
- return string.Format("You brushed {0} to death. Are you happy?", poner);
- }
- return string.Format("{0}: \"I'm clean enough, stop brushing me.\"", poner);
- }
- }
- else {
- AddStat(poner, 2, 10);
- return string.Format("[pleased {0} noises]", poner);
- }
- }
- else
- {
- if (IsDedPoner(poner))
- {
- return string.Format("You can't brush the dead, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static string Feed(string poner, string user)
- {
- if (IsPoner(poner))
- {
- if (GetStat(poner, 1) > 80)
- {
- if (GetStat(poner, 1) > 95)
- {
- AddStat(poner, 1, 5);
- bool ded = (GetStat(poner, 3) - 5 <= 0);
- AddStat(poner, 3, -5);
- if (ded)
- {
- return string.Format("You fed {0} to death.", poner);
- }
- return string.Format("{0}: \"I don't want your food!\"", poner);
- }
- Random r = new Random();
- if (r.Next(2) < 1)
- {
- AddStat(poner, 1, 10);
- return string.Format("[pleased {0} noises]", poner);
- }
- else
- {
- return string.Format("{0}: \"I'm full. I don't need your food.\"", poner);
- }
- }
- else {
- AddStat(poner, 1, 15);
- return string.Format("[pleased {0} noises]", poner);
- }
- }
- else
- {
- if (IsDedPoner(poner))
- {
- return string.Format("You can't feed corpses, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static int GetStat(string poner, int stat)
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if(line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return int.Parse(line.Split()[stat]);
- }
- }
- sr.Close();
- return 0;
- }
- public static int GetCount()
- {
- return 0;
- }
- public static string[] GetPoners()
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- string[] ponerData = sr.ReadLine().Split();
- list.Add(string.Format("[{0}] {2}% Full, {1}% Clean, {3}% Happy, Level {4}.", ponerData[0], ponerData[2], ponerData[1], ponerData[3], ponerData[4]));
- }
- sr.Close();
- return list.ToArray();
- }
- public static void NewPoner(string poner, Message message)
- {
- if(IsPoner(poner))
- {
- message.Channel.SendMessage(poner + " already exists!");
- return;
- }
- if (IsDedPoner(poner))
- {
- message.Channel.SendMessage(poner + " is dead. Just accept it.");
- return;
- }
- StreamWriter sw = new StreamWriter("PonerLand.txt", true);
- sw.WriteLine(poner + " 80 80 80 0");
- sw.Close();
- message.Channel.SendMessage(poner + " has been brought to Ponyland!");
- }
- public static string GetCleanliness(int clean)
- {
- if (clean < 5)
- return "Extremely filthy";
- else if (clean < 25)
- return "Filthy";
- else if (clean < 50)
- return "Dirty";
- else if (clean < 75)
- return "Rough";
- else if (clean < 95)
- return "Clean";
- else return "Spotless";
- }
- public static string GetHunger(int food)
- {
- if (food < 5)
- return "Famished";
- else if (food < 25)
- return "Starving";
- else if (food < 50)
- return "Hungry";
- else if (food < 75)
- return "Satistfied";
- else if (food < 95)
- return "Full";
- else return "Stuffed";
- }
- public static string GetHappiness(int happy)
- {
- if (happy < 5)
- return "Flaming";
- else if (happy < 15)
- return "Raging";
- else if (happy < 30)
- return "Angry";
- else if (happy < 45)
- return "Perturbed";
- else if (happy < 75)
- return "Calm";
- else return "Happy";
- }
- public static void Kill(string poner)
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while (!sr.EndOfStream)
- {
- list.Add(sr.ReadLine());
- }
- sr.Close();
- StreamWriter sw = new StreamWriter("PonerLand.txt");
- foreach (string token in list)
- {
- if (!token.Contains(poner))
- {
- sw.WriteLine(token);
- }
- }
- StreamWriter graveyard = new StreamWriter("PonerGraveyard.txt", true);
- graveyard.WriteLine("\n" + poner);
- sw.Close();
- graveyard.Close();
- }
- public static string[] GetDed()
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerGraveyard.txt");
- while (!sr.EndOfStream)
- {
- list.Add(string.Format("[{0}]", sr.ReadLine()));
- }
- sr.Close();
- return list.ToArray();
- }
- }
- }
- ---- The code that goes in the command switch statement in Program.cs ----
- ---- Ponerland.cs -------- Ponerland.cs ----
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using Discord;
- namespace DiscordBot.Commands
- {
- class PonerLand
- {
- //PonerName Food Cleanliness Mood Level
- public static void Tick()
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- List<string> names = new List<string>();
- while(!sr.EndOfStream)
- {
- names.Add(sr.ReadLine().Split()[0]);
- }
- sr.Close();
- foreach (string name in names)
- {
- AddStat(name, 1, -1);
- AddStat(name, 2, -1);
- AddStat(name, 3, 6);
- AddStat(name, 4, 1);
- }
- }
- public static void AddStat(string poner, int stat, int value)
- {
- SetStat(poner, stat, GetStat(poner, stat) + value);
- }
- public static void SetStat(string poner, int stat, int value)
- {
- bool ded = false;
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- list.Add(sr.ReadLine());
- }
- sr.Close();
- StreamWriter sw = new StreamWriter("PonerLand.txt");
- foreach(string token in list)
- {
- if(token.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- string[] ponerString = token.Split();
- int[] ponerStats = new int[ponerString.Length - 1];
- for(int i = 1; i < ponerString.Length; i++)
- {
- ponerStats[i - 1] = int.Parse(ponerString[i]);
- }
- ponerStats[stat - 1] = value;
- if (ponerStats[stat - 1] > 100) ponerStats[stat - 1] = 100;
- if (ponerStats[stat - 1] <= 0) ded = true;
- sw.WriteLine("{0} {1}", poner, string.Join(" ", ponerStats));
- }
- else
- {
- sw.WriteLine(token);
- }
- }
- sw.Close();
- if (ded) Kill(poner);
- }
- public static bool IsPoner(string poner)
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- while (!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if (line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return true;
- }
- }
- sr.Close();
- return false;
- }
- public static bool IsDedPoner(string poner)
- {
- StreamReader sr = new StreamReader("PonerGraveyard.txt");
- while (!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if (line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return true;
- }
- }
- sr.Close();
- return false;
- }
- public static string Boop(string poner, string user)
- {
- if (IsPoner(poner))
- {
- bool ded = (GetStat(poner, 3) - 2 <= 0);
- AddStat(poner, 3, -2);
- if (ded)
- {
- return string.Format("Congratulations. You booped {0} to death. Are you proud of yourself?", poner);
- }
- else
- {
- return string.Format("{0}: [scrunch]", poner);
- }
- }
- else
- {
- if(IsDedPoner(poner))
- {
- return string.Format("You can't boop the dead, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static string Brushie(string poner, string user)
- {
- if (IsPoner(poner))
- {
- if (GetStat(poner, 2) > 80)
- {
- if (GetStat(poner, 2) > 95)
- {
- AddStat(poner, 2, 2);
- bool ded = (GetStat(poner, 3) - 5 <= 0);
- AddStat(poner, 3, -5);
- if (ded)
- {
- return string.Format("You brushed {0} to death. Are you happy?", poner);
- }
- return string.Format("{0}: \"Stop brushing me!\"", poner);
- }
- Random r = new Random();
- if (r.Next(2) < 1)
- {
- AddStat(poner, 2, 5);
- return string.Format("[pleased {0} noises]", poner);
- }
- else
- {
- AddStat(poner, 2, 2);
- bool ded = (GetStat(poner, 3) - 3 <= 0);
- AddStat(poner, 3, -3);
- if (ded)
- {
- return string.Format("You brushed {0} to death. Are you happy?", poner);
- }
- return string.Format("{0}: \"I'm clean enough, stop brushing me.\"", poner);
- }
- }
- else {
- AddStat(poner, 2, 10);
- return string.Format("[pleased {0} noises]", poner);
- }
- }
- else
- {
- if (IsDedPoner(poner))
- {
- return string.Format("You can't brush the dead, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static string Feed(string poner, string user)
- {
- if (IsPoner(poner))
- {
- if (GetStat(poner, 1) > 80)
- {
- if (GetStat(poner, 1) > 95)
- {
- AddStat(poner, 1, 5);
- bool ded = (GetStat(poner, 3) - 5 <= 0);
- AddStat(poner, 3, -5);
- if (ded)
- {
- return string.Format("You fed {0} to death.", poner);
- }
- return string.Format("{0}: \"I don't want your food!\"", poner);
- }
- Random r = new Random();
- if (r.Next(2) < 1)
- {
- AddStat(poner, 1, 10);
- return string.Format("[pleased {0} noises]", poner);
- }
- else
- {
- return string.Format("{0}: \"I'm full. I don't need your food.\"", poner);
- }
- }
- else {
- AddStat(poner, 1, 15);
- return string.Format("[pleased {0} noises]", poner);
- }
- }
- else
- {
- if (IsDedPoner(poner))
- {
- return string.Format("You can't feed corpses, {0}.", user);
- }
- else
- {
- return poner + " does not exists in Ponyland.";
- }
- }
- }
- public static int GetStat(string poner, int stat)
- {
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- string line = sr.ReadLine();
- if(line.StartsWith(poner, true, System.Globalization.CultureInfo.CurrentCulture))
- {
- sr.Close();
- return int.Parse(line.Split()[stat]);
- }
- }
- sr.Close();
- return 0;
- }
- public static int GetCount()
- {
- return 0;
- }
- public static string[] GetPoners()
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while(!sr.EndOfStream)
- {
- string[] ponerData = sr.ReadLine().Split();
- list.Add(string.Format("[{0}] {2}% Full, {1}% Clean, {3}% Happy, Level {4}.", ponerData[0], ponerData[2], ponerData[1], ponerData[3], ponerData[4]));
- }
- sr.Close();
- return list.ToArray();
- }
- public static void NewPoner(string poner, Message message)
- {
- if(IsPoner(poner))
- {
- message.Channel.SendMessage(poner + " already exists!");
- return;
- }
- if (IsDedPoner(poner))
- {
- message.Channel.SendMessage(poner + " is dead. Just accept it.");
- return;
- }
- StreamWriter sw = new StreamWriter("PonerLand.txt", true);
- sw.WriteLine(poner + " 80 80 80 0");
- sw.Close();
- message.Channel.SendMessage(poner + " has been brought to Ponyland!");
- }
- public static string GetCleanliness(int clean)
- {
- if (clean < 5)
- return "Extremely filthy";
- else if (clean < 25)
- return "Filthy";
- else if (clean < 50)
- return "Dirty";
- else if (clean < 75)
- return "Rough";
- else if (clean < 95)
- return "Clean";
- else return "Spotless";
- }
- public static string GetHunger(int food)
- {
- if (food < 5)
- return "Famished";
- else if (food < 25)
- return "Starving";
- else if (food < 50)
- return "Hungry";
- else if (food < 75)
- return "Satistfied";
- else if (food < 95)
- return "Full";
- else return "Stuffed";
- }
- public static string GetHappiness(int happy)
- {
- if (happy < 5)
- return "Flaming";
- else if (happy < 15)
- return "Raging";
- else if (happy < 30)
- return "Angry";
- else if (happy < 45)
- return "Perturbed";
- else if (happy < 75)
- return "Calm";
- else return "Happy";
- }
- public static void Kill(string poner)
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerLand.txt");
- while (!sr.EndOfStream)
- {
- list.Add(sr.ReadLine());
- }
- sr.Close();
- StreamWriter sw = new StreamWriter("PonerLand.txt");
- foreach (string token in list)
- {
- if (!token.Contains(poner))
- {
- sw.WriteLine(token);
- }
- }
- StreamWriter graveyard = new StreamWriter("PonerGraveyard.txt", true);
- graveyard.WriteLine("\n" + poner);
- sw.Close();
- graveyard.Close();
- }
- public static string[] GetDed()
- {
- List<string> list = new List<string>();
- StreamReader sr = new StreamReader("PonerGraveyard.txt");
- while (!sr.EndOfStream)
- {
- list.Add(string.Format("[{0}]", sr.ReadLine()));
- }
- sr.Close();
- return list.ToArray();
- }
- }
- }
- ----- The code that goes in the command switch statement in Program.cs ----
- case "boop":
- case "newspaper":
- if (command.Length > 1)
- {
- if(command[1] != "")
- {
- if(command[1].ToLower() == "dicey")
- {
- e.Channel.SendMessage("[scrunch]");
- }
- e.Channel.SendMessage(PonerLand.Boop(command[1].ToLower(), e.Message.User.Nickname));
- }
- }
- else
- {
- e.Channel.SendMessage("[scrunch]");
- }
- break;
- case "brushie":
- if (command.Length > 1)
- {
- if (command[1] != "")
- {
- if (command[1].ToLower() == "dicey")
- {
- e.Channel.SendMessage("[pleased dicey noises]");
- }
- e.Channel.SendMessage(PonerLand.Brushie(command[1].ToLower(), e.Message.User.Nickname));
- }
- }
- else
- {
- e.Channel.SendMessage("[pleased dicey noises]");
- }
- break;
- case "feed":
- if (command.Length > 1)
- {
- if (command[1] != "")
- {
- if (command[1].ToLower() == "dicey")
- {
- e.Channel.SendMessage("");
- }
- e.Channel.SendMessage(PonerLand.Feed(command[1].ToLower(), e.Message.User.Nickname));
- }
- }
- else
- {
- e.Channel.SendMessage("[pleased dicey noises]");
- }
- break;
- case "ponies":
- case "poners":
- e.Channel.SendMessage("```" + string.Join("\n", PonerLand.GetPoners()) + "```");
- break;
- case "new":
- if (command.Length > 1)
- {
- PonerLand.NewPoner(command[1], e.Message);
- }
- break;
- case "ded":
- case "dead":
- e.Channel.SendMessage("```" + string.Join(", ", PonerLand.GetDed()) + "```");
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement