예제 #1
0
 private void processLine(string line)
 {
     //left in as a joke.
     //line = line.Replace("food", "potato").Replace("vegetables","potatoes").Replace("meat","potatoes").Replace("sandwich","potato");
     if (line.StartsWith("PESTER") || line.StartsWith("TROLL"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 4)
         {
             appendOutput("FORMAT ERROR NEED 3 ARGUMENTS\n", Color.Red); return;
         }
         Chum chum1 = PesterchumAccMgr.findChum(args[1]);
         Chum chum2 = PesterchumAccMgr.findChum(args[2]);
         if (chum1 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         if (chum2 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[2] + "\n", Color.Red); return;
         }
         appendOutput("-- ");
         chum1.printWholeName();
         appendOutput("began " + args[0].ToLower() + "ing ");
         chum2.printWholeName();
         appendOutput("at " + args[3] + " --\n");
         return;
     }
     if (line.StartsWith("ENDPESTER") || line.StartsWith("ENDTROLL"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 3)
         {
             appendOutput("FORMAT ERROR NEED 2 ARGUMENTS\n", Color.Red); return;
         }
         Chum chum1 = PesterchumAccMgr.findChum(args[1]);
         Chum chum2 = PesterchumAccMgr.findChum(args[2]);
         if (chum1 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         if (chum2 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[2] + "\n", Color.Red); return;
         }
         appendOutput("-- ");
         chum1.printWholeName();
         appendOutput("ceased " + args[0].Substring(3).ToLower() + "ing ");
         chum2.printWholeName();
         appendOutput("--\n");
         return;
     }
     if (line.StartsWith("IDLE"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 2)
         {
             appendOutput("FORMAT ERROR NEED 1 ARGUMENT\n", Color.Red); return;
         }
         Chum chum = PesterchumAccMgr.findChum(args[1]);
         if (chum == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         appendOutput("-- ");
         chum.printWholeName();
         appendOutput("is now an idle " + (line.StartsWith("IDLETROLL")?"troll":"chum") + "! --\n");
         return;
     }
     if (line.StartsWith("MEMO"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count < 3)
         {
             appendOutput("FORMAT ERROR NEED 4 ARGUMENTS\n", Color.Red); return;
         }
         args[2] = line.Substring(line.IndexOf(' ', line.IndexOf(' ') + 1) + 1);
         if (args[2].IndexOf(';') == -1)
         {
             appendOutput("ARGUMENT 3 and 4 NEED ; IN THE MIDDLE\n", Color.Red); return;
         }
         Chum chum = PesterchumAccMgr.findChum(args[1]);
         if (chum == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         chum.printWholeName();
         appendOutput(args[2].Substring(0, args[2].IndexOf(';')));
         appendOutput(" opened memo on board ");
         appendOutput(args[2].Substring(args[2].IndexOf(';') + 1));
         appendOutput(".\n");
         return;
     }
     if (line.StartsWith("RESPOND"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count < 3)
         {
             appendOutput("FORMAT ERROR NEED 2 ARGUMENTS\n", Color.Red); return;
         }
         Chum chum = PesterchumAccMgr.findChum(args[1]);
         if (chum == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         chum.printWholeName();
         appendOutput(line.Substring(line.IndexOf(' ', line.IndexOf(' ') + 1) + 1) + " responded to memo.\n");
         return;
     }
     if (line.StartsWith("BAN") || line.StartsWith("UNBAN"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 3)
         {
             appendOutput("FORMAT ERROR NEED 2 ARGUMENTS\n", Color.Red); return;
         }
         Chum chum1 = PesterchumAccMgr.findChum(args[1]);
         Chum chum2 = PesterchumAccMgr.findChum(args[2]);
         if (chum1 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         if (chum2 == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[2] + "\n", Color.Red); return;
         }
         chum1.printShortName();
         appendOutput(" " + args[0].ToLower() + "ned ");
         chum2.printShortName();
         appendOutput(" from replying to memo.\n");
         return;
     }
     if (line.StartsWith("ENDRESPOND"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 2)
         {
             appendOutput("FORMAT ERROR NEED 1 ARGUMENT\n", Color.Red); return;
         }
         Chum chum = PesterchumAccMgr.findChum(args[1]);
         if (chum == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         chum.printShortName();
         appendOutput(" ceased responding to memo.\n");
         return;
     }
     if (line.StartsWith("ENDMEMO"))
     {
         List <string> args = new List <string>(from str in line.Split(' ') where str != "" select str);
         if (args.Count != 2)
         {
             appendOutput("FORMAT ERROR NEED 1 ARGUMENT\n", Color.Red); return;
         }
         Chum chum = PesterchumAccMgr.findChum(args[1]);
         if (chum == null)
         {
             appendOutput("CHUM NOT FOUND ERROR:" + args[1] + "\n", Color.Red); return;
         }
         chum.printShortName();
         appendOutput(" closed memo.\n");
         return;
     }
     if (line.IndexOf(':') != -1)
     {
         Chum c = PesterchumAccMgr.findChum(line.Substring(0, line.IndexOf(':')));
         if (c != null)
         {
             c.Say(line);
             return;
         }
     }
     if (line.StartsWith("="))
     {
         int arrowLoc = line.IndexOf(">");
         if (arrowLoc != -1)
         {
             if (!(from c in line.Substring(0, arrowLoc) where c != '=' select c).Any())
             {
                 appendOutput(line + "\n", Color.Blue, commandFont);
             }
             return;
         }
     }
     //left in as a joke.
     //if (line == "potato") appendOutput("PS: F**K NO.", PesterchumAccMgr.findChum("PS").color);else
     appendOutput(line + "\n");
 }
예제 #2
0
        private Chum _findChum(string identifier)
        {
            if (identifier.Length == 3 || (identifier.Length == 4 && char.IsDigit(identifier[3]))) //memo user with time shenanigans
            {
                Chum retval = _findChum(identifier.Substring(1, 2));
                if (retval == null)
                {
                    return(null);
                }
                retval = retval.getClone();
                switch (identifier[0])
                {
                case 'F':
                case 'f':
                    retval.memoState = Chum.MemoState.FUTURE;
                    break;

                case 'C':
                case 'c':
                    retval.memoState = Chum.MemoState.CURRENT;
                    break;

                case 'P':
                case 'p':
                    retval.memoState = Chum.MemoState.PAST;
                    break;

                default:
                    retval.memoState = Chum.MemoState.UNKNOWN;
                    break;
                }
                if (identifier.Length == 4)
                {
                    retval.memoUserCnt = int.Parse(identifier.Substring(3));
                }
                return(retval);
            }
            if (identifier.Length == 2) //short name is given
            {
                identifier = identifier.ToUpper();
                foreach (Chum c in list)
                {
                    if (c.shortName == identifier)
                    {
                        return(c);
                    }
                }
                return(null);
            }
            string tryShortName = Chum.generateShortName(identifier);

            if (tryShortName != "??") //good long name is given
            {
                foreach (Chum c in list)
                {
                    if (c.shortName == tryShortName)
                    {
                        return(c);
                    }
                }
                return(null);
            }
            return(null); //flip the fvck out because idk what to do
        }