Example #1
0
 /// <summary>
 /// Sets the relationship of a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <param name="relation"></param>
 public static void SetRelationship(ulong guildid, TribeData tribe, Relationship relation)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID))
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Relation.txt", ((int)relation).ToString());
     }
 }
Example #2
0
 /// <summary>
 /// Renames a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <param name="newtribename"></param>
 public static void RenameTribe(ulong guildid, TribeData tribe, string newtribename)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID))
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Name.txt", newtribename);
     }
 }
Example #3
0
 /// <summary>
 /// Deletes a tribe, deletion from other sources(steamids, servers) is handled already
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 public static void DeleteTribe(ulong guildid, TribeData tribe)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID))
     {
         if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt"))
         {
             string[] servers = File.ReadAllLines(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt");
             foreach (string server in servers)
             {
                 string[] oldfile = File.ReadAllLines(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Servers\\" + server + "\\Tribes.txt");
                 string   newfile = "";
                 foreach (string s in oldfile)
                 {
                     if (s.CompareTo(tribe.ID.ToString()) != 0)
                     {
                         if (newfile != "")
                         {
                             newfile += "\n";
                         }
                         newfile += s;
                     }
                 }
                 if (newfile.Length != 0)
                 {
                     File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Servers\\" + server + "\\Tribes.txt", newfile);
                 }
                 else
                 {
                     Directory.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Servers\\" + server);
                 }
             }
         }
         Directory.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID, true);
     }
 }
Example #4
0
 /// <summary>
 /// Removes a tribe from a server
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="sData"></param>
 /// <param name="tribe"></param>
 public static void RemoveTribeFromServer(ulong guildid, ServerData sData, TribeData tribe)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name))
     {
         string oldstring = File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt");
         string newstring = "";
         foreach (string id in oldstring.Split('\n'))
         {
             if (id.CompareTo(tribe.ID.ToString()) != 0)
             {
                 if (newstring != "")
                 {
                     newstring += "\n";
                 }
                 newstring += id;
             }
         }
         if (newstring.Length != 0)
         {
             File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt", newstring);
         }
         else
         {
             File.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt");
             if (Directory.GetFiles(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name).Length == 0)
             {
                 Directory.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name);
             }
         }
         oldstring = File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt");
         newstring = "";
         foreach (string name in oldstring.Split('\n'))
         {
             if (name.CompareTo(sData.Name) != 0)
             {
                 if (newstring != "")
                 {
                     newstring += "\n";
                 }
                 newstring += name;
             }
         }
         if (newstring.Length != 0)
         {
             File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt", newstring);
         }
         else
         {
             File.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt");
         }
     }
 }
Example #5
0
        /// <summary>
        /// Returns all servers a tribe owns, this data does not return the data that is used for alert generation
        /// </summary>
        /// <returns></returns>
        public static List <ServerData> GetAllServers(ulong guildid, TribeData tribe)
        {
            List <ServerData> rg = new List <ServerData>();

            if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt"))
            {
                string[] servers = File.ReadAllLines(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt");
                foreach (string servername in servers)
                {
                    rg.Add(new ServerData(servername, File.ReadAllText(AppContext.BaseDirectory + "\\Servers\\" + servername + "\\Ip.txt"), int.Parse(File.ReadAllText(AppContext.BaseDirectory + "\\Servers\\" + servername + "\\MaxPlayers.txt")), true));
                }
            }
            return(rg);
        }
Example #6
0
        /// <summary>
        /// Gets all steamids of a tribe
        /// </summary>
        /// <param name="guildid"></param>
        /// <param name="tribe"></param>
        /// <returns></returns>
        public static List <SteamIDData> GetSteamIDs(ulong guildid, TribeData tribe)
        {
            List <SteamIDData> rg = new List <SteamIDData>();

            if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\"))
            {
                foreach (string steamiddir in Directory.GetDirectories(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\"))
                {
                    if (File.Exists(steamiddir + "\\Tribe.txt") && int.Parse(File.ReadAllText(steamiddir + "\\Tribe.txt")) == tribe.ID)
                    {
                        rg.Add(DataBase.GetSteamID(guildid, ulong.Parse(steamiddir.Split("\\/".ToCharArray())[steamiddir.Split("\\/".ToCharArray()).Length - 1])));
                    }
                }
            }
            return(rg);
        }
Example #7
0
 /// <summary>
 /// Assoziates a steamid with a tribe withhin a guild(discord server)
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="steamid"></param>
 /// <param name="tribe"></param>
 public static void SetTribe(ulong guildid, SteamIDData steamid, TribeData tribe)
 {
     if (!Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID))
     {
         Directory.CreateDirectory(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID);
     }
     if (tribe != null)
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID + "\\Tribe.txt", tribe.ID.ToString());
     }
     else
     {
         File.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID + "\\Tribe.txt");
         if (Directory.GetFiles(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID).Length == 0)
         {
             Directory.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID);
         }
     }
 }
Example #8
0
 /// <summary>
 /// Adds a tribe to a server
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="sData"></param>
 /// <param name="tribe"></param>
 public static void AddTribeToServer(ulong guildid, ServerData sData, TribeData tribe)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name))
     {
         string newstring = File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt");
         bool   found     = false;
         foreach (string id in newstring.Split('\n'))
         {
             if (id.CompareTo(tribe.ID.ToString()) == 0)
             {
                 found = true;
             }
         }
         if (!found)
         {
             File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt", newstring + "\n" + tribe.ID.ToString());
         }
         else
         {
             return;
         }
     }
     else
     {
         Directory.CreateDirectory(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name);
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Server\\" + sData.Name + "\\Tribes.txt", tribe.ID.ToString());
     }
     if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt"))
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt", File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt") + "\n" + sData.Name);
     }
     else
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribe.ID + "\\Servers.txt", sData.Name);
     }
 }
Example #9
0
 /// <summary>
 /// Assoziates a steamid with a tribe withhin a guild(discord server)
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="steamid"></param>
 /// <param name="tribe"></param>
 public static void SetTribe(ulong guildid, SteamIDData steamid, TribeData tribe)
 {
 }
Example #10
0
 /// <summary>
 /// Gets all steamids of a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <returns></returns>
 public static List <SteamIDData> GetSteamIDs(ulong guildid, TribeData tribe)
 {
     return(new List <SteamIDData>());
 }
Example #11
0
 /// <summary>
 /// Sets the relationship of a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <param name="relation"></param>
 public static void SetRelationship(ulong guildid, TribeData tribe, Relationship relation)
 {
 }
Example #12
0
 /// <summary>
 /// Renames a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <param name="newtribename"></param>
 public static void RenameTribe(ulong guildid, TribeData tribe, string newtribename)
 {
 }
Example #13
0
 /// <summary>
 /// Removes a tribe from a server
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="sData"></param>
 /// <param name="tribe"></param>
 public static void RemoveTribeFromServer(ulong guildid, ServerData sData, TribeData tribe)
 {
 }
Example #14
0
 /// <summary>
 /// Adds a tribe to a server
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="sData"></param>
 /// <param name="tribe"></param>
 public static void AddTribeToServer(ulong guildid, ServerData sData, TribeData tribe)
 {
 }
Example #15
0
 /// <summary>
 /// Deletes a tribe, deletion from other sources(steamids, servers) is handled already
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 public static void DeleteTribe(ulong guildid, TribeData tribe)
 {
 }
Example #16
0
 /// <summary>
 /// Returns all servers a tribe owns, this data does not return the data that is used for alert generation
 /// </summary>
 /// <returns></returns>
 public static List <ServerData> GetAllServers(ulong guildid, TribeData tribe)
 {
     return(new List <ServerData>());
 }