Ejemplo n.º 1
0
        static bool ChangeReason(string who, string reason, PlayerMetaList list)
        {
            who    = who.ToLower();
            reason = reason.Replace(" ", "%20");
            bool          found = false;
            StringBuilder sb    = new StringBuilder();

            foreach (string line in File.ReadAllLines(list.file))
            {
                string[] parts = line.SplitSpaces();
                if (parts.Length > 2 && parts[1] == who)
                {
                    found    = true;
                    parts[2] = reason;
                    sb.AppendLine(String.Join(" ", parts));
                }
                else
                {
                    sb.AppendLine(line);
                }
            }

            if (found)
            {
                File.WriteAllText(list.file, sb.ToString());
            }
            return(found);
        }
Ejemplo n.º 2
0
        static bool ChangeReason(string who, string reason, PlayerMetaList list)
        {
            who    = who.ToLower();
            reason = reason.Replace(" ", "%20");
            bool          success = false;
            StringBuilder sb      = new StringBuilder();

            foreach (string line in File.ReadAllLines(list.file))
            {
                string[] parts = line.Split(' ');
                if (parts.Length > 2 && parts[1] == who)
                {
                    parts[2] = CP437Writer.ConvertToUnicode(reason);
                    success  = true;
                    sb.AppendLine(String.Join(" ", parts));
                }
                else
                {
                    sb.AppendLine(line);
                }
            }

            if (success)
            {
                File.WriteAllText(list.file, sb.ToString());
            }
            return(success);
        }
Ejemplo n.º 3
0
        static bool DeleteInfo(string name, PlayerMetaList list)
        {
            name = name.ToLower();
            bool          found = false;
            StringBuilder sb    = new StringBuilder();

            foreach (string line in File.ReadAllLines(list.file))
            {
                string[] parts = line.SplitSpaces();
                if (parts.Length > 1 && parts[1] == name)
                {
                    found = true;
                }
                else
                {
                    sb.AppendLine(line);
                }
            }

            if (found)
            {
                File.WriteAllText(list.file, sb.ToString());
            }
            return(found);
        }
Ejemplo n.º 4
0
        static bool DeleteInfo(string name, PlayerMetaList list)
        {
            name = name.ToLower();
            bool          success = false;
            StringBuilder sb      = new StringBuilder();

            foreach (string line in File.ReadAllLines(list.file))
            {
                string[] parts = line.Split(' ');
                if (parts.Length <= 1 || parts[1] != name)
                {
                    sb.AppendLine(line);
                }
                else
                {
                    success = true;
                }
            }
            File.WriteAllText(list.file, sb.ToString());
            return(success);
        }