Exemple #1
0
        /// <summary>
        /// Fügt einem Spieler eine Technologie hinzu
        /// </summary>
        /// <param name="user">Spieler</param>
        /// <param name="tech">Technologie</param>
        public void addTech(User user, Tech tech)
        {
            lock (techlist)
            {

                List<Tech> have = getTechs(user);

                if (!have.Contains(tech))
                {
                    techlist[user].Add(tech);

                }

            }
        }
Exemple #2
0
 /// <summary>
 /// Erstellt eine neue Forschung
 /// </summary>
 /// <param name="user">Der Benutzer dem die Foschung gehört</param>
 /// <param name="tech">Die Technologie die erforscht wird</param>
 /// <param name="started">Die Zeit wann Sie gestartet wurde</param>
 public Forschung(User user, Tech tech, int started)
 {
     this.user = user;
     this.tech = tech;
     this.started = started;
 }
Exemple #3
0
 /// <summary>
 /// Überprüft ob ein Spieler eine Technologie besitzt
 /// </summary>
 /// <param name="user">Spieler</param>
 /// <param name="tech">Zu Überprüfende Technologie</param>
 /// <returns>Besitzt ein Spieler eine Technologie</returns>
 public bool haveTech(User user, Tech tech)
 {
     return getTechs(user).Contains(tech);
 }
Exemple #4
0
        /// <summary>
        /// Entfert eine Technologie von einem Spieler
        /// </summary>
        /// <param name="user">Spieler</param>
        /// <param name="tech">Technologie</param>
        public void removeTech(User user, Tech tech)
        {
            lock (techlist)
            {

                List<Tech> have = getTechs(user);

                if (have.Contains(tech))
                {
                    techlist[user].Remove(tech);
                }

            }
        }
Exemple #5
0
        /// <summary>
        /// Erezeugt eine neue Technologie
        /// </summary>
        /// <param name="ID">ID</param>
        /// <param name="data">GameData</param>
        /// <returns>Tech</returns>
        public static Tech create(int ID, GameData data)
        {
            MySqlDataReader Reader = data.Query("SELECT * FROM `PX_tech` WHERE `ID` = '" + ID + "'");
            Reader.Read();

            string name = (string)Reader["Name"];
            string beschreibung = (string)Reader["beschreibung"];

            int water = (int)Reader["water"];
            int metal = (int)Reader["metal"];
            int food = (int)Reader["food"];
            int naquadah = (int)Reader["naquadah"];

            int time = (int)Reader["time"];

            string need_techS = (string)Reader["need"];
            string updateS = (string)Reader["update"];
            string raceS = (string)Reader["race"];

            int group = (int)Reader["group"];

            Tech tech = new Tech(ID, name, beschreibung);

            string costs = (string)Reader["costs"];
            string[] costs_A1 = costs.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string value in costs_A1)
            {
                try
                {
                    string[] costs_A2 = value.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);

                    ResType type = (ResType)Enum.Parse(typeof(ResType), costs_A2[0]);
                    double cost = double.Parse(costs_A2[1]);

                    tech.price[type] = cost;

                }
                catch
                {
                    // Unsinnige Mysql Daten
                }
            }

            tech.time = time;
            tech.need_tech_temp = need_techS;
            tech.update_temp = updateS;
            tech.race_temp = raceS;
            tech.group = group;

            Reader.Close();

            return tech;
        }