public static Armor GetArmorByName(string name)
        {
            ArmorService _armorService = new ArmorService(EquipmentGlobals.ConnectionString);
            armor        tempArmor     = _armorService.GetArmorByName(name);

            return(MapThisToArmorObject(tempArmor));
        }
Esempio n. 2
0
File: FormAWP.cs Progetto: Wykh/ARM
        private static void DeleteRecordWithCtx(TournamentsContext ctx, string table, object deletedObj)
        {
            // Question1!!! Ужос, везде код дублируется. Alt+shift+> помогает
            switch (table) // Exlicipt casting to correct class type
            {
            case "knight":
            {
                knight delObj = (knight)deletedObj;
                ctx.knights.Attach(delObj);
                ctx.knights.Remove(delObj);
                break;
            }

            case "weapon":
            {
                weapon delObj = (weapon)deletedObj;
                ctx.weapons.Attach(delObj);
                ctx.weapons.Remove(delObj);
                break;
            }

            case "fight":
            {
                fight delObj = (fight)deletedObj;
                ctx.fights.Attach(delObj);
                ctx.fights.Remove(delObj);
                break;
            }

            case "armor":
            {
                armor delObj = (armor)deletedObj;
                ctx.armors.Attach(delObj);
                ctx.armors.Remove(delObj);
                break;
            }

            case "tournament":
            {
                tournament delObj = (tournament)deletedObj;
                ctx.tournaments.Attach(delObj);
                ctx.tournaments.Remove(delObj);
                break;
            }

            default:
                throw new Exception("ERROR\n in DeleteRecordWithCtx, wrong case ");
            }
        }
Esempio n. 3
0
File: FormAWP.cs Progetto: Wykh/ARM
        private void UpdateRecordWithCtx(TournamentsContext ctx, object updatedObj, string tableName)
        {
            // QUESTION как это исправить всё?
            switch (tableName) // Exlicipt casting to correct class type
            {
            case "knight":
            {
                knight updObj = (knight)updatedObj;                    // create updated knight
                var    oldObj = ctx.knights.SingleOrDefault(o => o.id_knight == updObj.id_knight);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj); // get entity's values and update the values
                break;
            }

            case "weapon":
            {
                weapon updObj = (weapon)updatedObj;
                var    oldObj = ctx.weapons.SingleOrDefault(o => o.id_weapon == updObj.id_weapon);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj);
                break;
            }

            case "fight":
            {
                fight updObj = (fight)updatedObj;
                var   oldObj = ctx.fights.SingleOrDefault(o => o.id_fight == updObj.id_fight);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj);
                break;
            }

            case "armor":
            {
                armor updObj = (armor)updatedObj;
                var   oldObj = ctx.armors.SingleOrDefault(o => o.id_armor == updObj.id_armor);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj);
                break;
            }

            case "tournament":
            {
                tournament updObj = (tournament)updatedObj;
                var        oldObj = ctx.tournaments.SingleOrDefault(o => o.id_tournament == updObj.id_tournament);
                ctx.Entry(oldObj).CurrentValues.SetValues(updatedObj);
                break;
            }

            default:
                throw new Exception("ERROR\n in UpdateRecordWithCtx, wrong case ");
            }
        }
Esempio n. 4
0
 public bool HasShield()
 {
     foreach (KeyValuePair <IEquipment, int> kvp in _armor)
     {
         IEquipment hold      = kvp.Key;
         armor      armorTemp = hold as armor;
         if (armorTemp != null)
         {
             if (armorTemp.category == "shield")
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 5
0
 public base_personnage(string _name,int _ID,santé _Santé, mana _Mana, energie _Energie, poudre _Poudre, vitess _Vitess, armor _Armor, encaissement _Encaissement, speed _Speed, tenacity _Tenacity, range _Range, damage _Damage, power _Power, life_steal _Life_Steal, vampirisme _Vampirisme, List<tool> _LT)
 {
     name = _name;
     ID = _ID;
     Santé = _Santé;
     Mana = _Mana;
     Energie = _Energie;
     Poudre = _Poudre;
     Vitess = _Vitess;
     Armor = _Armor;
     encaissement = _Encaissement;
     Speed = _Speed;
     Tenacity = _Tenacity;
     Range = _Range;
     Damage = _Damage;
     Power = _Power;
     Life_Steal = _Life_Steal;
     Vampirisme = _Vampirisme;
     List_tool = new List<tool>();
     List_tool = _LT;
 }
Esempio n. 6
0
    //load all equipment from a text file
    bool LoadEquipment(string fileName)
    {
        try
        {
            string line;

            StreamReader reader = new StreamReader(fileName, Encoding.Default);

            using (reader)
            {
                do
                {
                    line = reader.ReadLine();

                    if (line != null)
                    {
                        //skip comments
                        if (line[0] == 'c')
                        {
                            continue;
                        }
                        //split content lines
                        string[] entries = line.Split(',');
                        if (entries[0][0] == 'w')
                        {
                            weapon temp = new weapon();
                            temp.name     = entries[1];
                            temp.desc     = entries[2];
                            temp.str      = Int32.Parse(entries[3]);
                            temp.end      = Int32.Parse(entries[4]);
                            temp.agi      = Int32.Parse(entries[5]);
                            temp.mag      = Int32.Parse(entries[6]);
                            temp.luck     = Int32.Parse(entries[7]);
                            temp.rangeMin = Int32.Parse(entries[8]);
                            temp.rangeMax = Int32.Parse(entries[9]);
                            temp.recipe   = new List <string>();
                            for (int i = 10; i < entries.Length; i++)
                            {
                                temp.recipe.Add(entries[i]);
                            }
                            allWeapons.Add(temp);
                        }
                        if (entries[0][0] == 'a')
                        {
                            armor temp = new armor();
                            temp.name   = entries[1];
                            temp.desc   = entries[2];
                            temp.str    = Int32.Parse(entries[3]);
                            temp.end    = Int32.Parse(entries[4]);
                            temp.agi    = Int32.Parse(entries[5]);
                            temp.mag    = Int32.Parse(entries[6]);
                            temp.luck   = Int32.Parse(entries[7]);
                            temp.recipe = new List <string>();
                            for (int i = 8; i < entries.Length; i++)
                            {
                                temp.recipe.Add(entries[i]);
                            }
                            allArmor.Add(temp);
                        }
                    }
                }while (line != null);

                reader.Close();
                //Debug.Log(allArmor.Count);
                return(true);
            }
        }
        catch (IOException e) {
            Debug.Log(e.Message);
            return(false);
        }
    }
Esempio n. 7
0
    //load all equipment from a text file
    bool LoadEquipment(string fileName)
    {
        try
        {
            string line;

            StreamReader reader = new StreamReader(fileName, Encoding.Default);

            using (reader)
            {
                do
                {
                    line = reader.ReadLine();

                    if (line != null)
                    {
                        //skip comments
                        if(line[0] == 'c'){	continue; }
                        //split content lines
                        string[] entries = line.Split(',');
                        if(entries[0][0] == 'w'){
                            weapon temp = new weapon();
                            temp.name = entries[1];
                            temp.desc = entries[2];
                            temp.str = Int32.Parse(entries[3]);
                            temp.end = Int32.Parse(entries[4]);
                            temp.agi = Int32.Parse(entries[5]);
                            temp.mag = Int32.Parse(entries[6]);
                            temp.luck = Int32.Parse(entries[7]);
                            temp.rangeMin = Int32.Parse(entries[8]);
                            temp.rangeMax = Int32.Parse(entries[9]);
                            temp.recipe = new List<string>();
                            for(int i=10;i<entries.Length;i++){

                                temp.recipe.Add(entries[i]);
                            }
                            allWeapons.Add(temp);
                        }
                        if(entries[0][0] == 'a'){
                            armor temp = new armor();
                            temp.name = entries[1];
                            temp.desc = entries[2];
                            temp.str = Int32.Parse(entries[3]);
                            temp.end = Int32.Parse(entries[4]);
                            temp.agi = Int32.Parse(entries[5]);
                            temp.mag = Int32.Parse(entries[6]);
                            temp.luck = Int32.Parse(entries[7]);
                            temp.recipe = new List<string>();
                            for(int i=8;i<entries.Length;i++){
                                temp.recipe.Add(entries[i]);
                            }
                            allArmor.Add(temp);
                        }

                    }
                }
                while (line != null);

                reader.Close();
                //Debug.Log(allArmor.Count);
                return true;
            }
        }
        catch(IOException e){
            Debug.Log (e.Message);
            return false;
        }
    }
Esempio n. 8
0
    public override Pickup Clone()
    {
        armor armorClone = Instantiate <GameObject>(this.gameObject).GetComponent <armor>();

        return(armorClone);
    }
Esempio n. 9
0
File: FormAWP.cs Progetto: Wykh/ARM
        private object GetCorrectObj(DataGridView dgv, int row, string dataBase) // return correct class instance
        {
            var curRowCells     = dgv.Rows[row].Cells;
            var idFromFirstCell = curRowCells[0].Value == null ? 0 : (int)curRowCells[0].Value; // Cell can be null......

            switch (dataBase)
            {
            case "knight":
            {
                var obj = new knight
                {
                    id_knight  = idFromFirstCell,
                    name       = (string)curRowCells[1].Value,
                    birth_date = (DateTime)curRowCells[2].Value,
                    honor      = (int)curRowCells[3].Value,
                    id_squire  = (int)curRowCells[4].Value
                };
                return(obj);
            }

            case "weapon":
            {
                var obj = new weapon
                {
                    id_weapon = idFromFirstCell,
                    name      = (string)curRowCells[1].Value,
                    quality   = (int)curRowCells[2].Value,
                    id_type   = (int)curRowCells[3].Value,
                    id_master = (int)curRowCells[4].Value
                };
                return(obj);
            }

            case "fight":
            {
                var obj = new fight
                {
                    id_fight          = idFromFirstCell,
                    id_fight_type     = (int)curRowCells[1].Value,
                    fight_result      = (int)curRowCells[2].Value,
                    id_knight1        = (int)curRowCells[3].Value,
                    id_weapon_knight1 = (int)curRowCells[4].Value,
                    id_armor_knight1  = (int)curRowCells[5].Value,
                    id_knight2        = (int)curRowCells[6].Value,
                    id_weapon_knight2 = (int)curRowCells[7].Value,
                    id_armor_knight2  = (int)curRowCells[8].Value,
                    id_tournament     = (int)curRowCells[9].Value
                };
                return(obj);
            }

            case "armor":
            {
                var obj = new armor
                {
                    id_armor  = idFromFirstCell,
                    name      = (string)curRowCells[1].Value,
                    quality   = (int)curRowCells[2].Value,
                    id_type   = (int)curRowCells[3].Value,
                    id_master = (int)curRowCells[4].Value
                };
                return(obj);
            }

            case "tournament":
            {
                var obj = new tournament
                {
                    id_tournament = idFromFirstCell,
                    id_kingdom    = (int)curRowCells[1].Value,
                    name          = (string)curRowCells[2].Value,
                    prize         = (int)curRowCells[3].Value
                };
                return(obj);
            }

            default:
                return(null);
            }
        }
Esempio n. 10
0
 public base_personnage(santé _Santé, mana _Mana, energie _Energie, poudre _Poudre, vitess _Vitess, armor _Armor, encaissement _Encaissement, speed _Speed, tenacity _Tenacity, range _Range, damage _Damage, power _Power, life_steal _Life_Steal, vampirisme _Vampirisme)
 {
 }
 private static Armor MapThisToArmorObject(armor Armor)
 {
     return(Mapper.Map <armor, Armor>(Armor));
 }
Esempio n. 12
0
    public void LoadEquipment()
    {
        XmlDocument xmlDoc = new XmlDocument();

        string path = Application.dataPath + @"/Resources/XML/EquipmentList.xml";

        if (File.Exists(path))
        {
            xmlDoc.Load(path);

            //load weapons
            XmlNodeList weapons = xmlDoc.GetElementsByTagName("Weapon");

            foreach (XmlNode wep in weapons)
            {
                weapon temp = new weapon();
                temp.recipe = new List <string>();
                foreach (XmlAttribute val in wep.Attributes)
                {
                    //Store values
                    if (val.Name == "name")
                    {
                        temp.name = val.InnerText;
                    }
                    else if (val.Name == "str")
                    {
                        temp.str = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "end")
                    {
                        temp.end = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "agi")
                    {
                        temp.agi = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "mag")
                    {
                        temp.mag = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "luck")
                    {
                        temp.luck = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "rangemin")
                    {
                        temp.rangeMin = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "rangemax")
                    {
                        temp.rangeMax = int.Parse(val.InnerText);
                    }
                    else if (val.Name.Contains("recipe"))
                    {
                        temp.recipe.Add(val.InnerText);
                    }
                }
                allWeapons.Add(temp);
            }

            //load armor
            XmlNodeList armors = xmlDoc.GetElementsByTagName("Armor");

            foreach (XmlNode arm in armors)
            {
                armor temp2 = new armor();
                temp2.recipe = new List <string>();
                foreach (XmlAttribute val in arm.Attributes)
                {
                    //Store values
                    if (val.Name == "name")
                    {
                        temp2.name = val.InnerText;
                    }
                    else if (val.Name == "str")
                    {
                        temp2.str = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "end")
                    {
                        temp2.end = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "agi")
                    {
                        temp2.agi = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "mag")
                    {
                        temp2.mag = int.Parse(val.InnerText);
                    }
                    else if (val.Name == "luck")
                    {
                        temp2.luck = int.Parse(val.InnerText);
                    }
                    else if (val.Name.Contains("recipe"))
                    {
                        temp2.recipe.Add(val.InnerText);
                    }
                }
                allArmor.Add(temp2);
            }
        }
    }
Esempio n. 13
0
    public void LoadEquipment()
    {
        XmlDocument xmlDoc = new XmlDocument();

        string path = Application.dataPath + @"/Resources/XML/EquipmentList.xml";

        if (File.Exists(path))
        {
            xmlDoc.Load(path);

            //load weapons
            XmlNodeList weapons = xmlDoc.GetElementsByTagName("Weapon");

            foreach(XmlNode wep in weapons){
                weapon temp = new weapon();
                temp.recipe = new List<string>();
                foreach (XmlAttribute val in wep.Attributes)
                {
                    //Store values
                    if (val.Name == "name")
                        temp.name = val.InnerText;
                    else if (val.Name == "str")
                        temp.str = int.Parse(val.InnerText);
                    else if (val.Name == "end")
                        temp.end = int.Parse(val.InnerText);
                    else if (val.Name == "agi")
                        temp.agi = int.Parse(val.InnerText);
                    else if (val.Name == "mag")
                        temp.mag = int.Parse(val.InnerText);
                    else if (val.Name == "luck")
                        temp.luck = int.Parse(val.InnerText);
                    else if (val.Name == "rangemin")
                        temp.rangeMin = int.Parse(val.InnerText);
                    else if (val.Name == "rangemax")
                        temp.rangeMax = int.Parse(val.InnerText);
                    else if (val.Name.Contains("recipe"))
                        temp.recipe.Add(val.InnerText);
                }
                allWeapons.Add(temp);
            }

            //load armor
            XmlNodeList armors = xmlDoc.GetElementsByTagName("Armor");

            foreach(XmlNode arm in armors){
                armor temp2 = new armor();
                temp2.recipe = new List<string>();
                foreach (XmlAttribute val in arm.Attributes)
                {

                    //Store values
                    if (val.Name == "name")
                        temp2.name = val.InnerText;
                    else if (val.Name == "str")
                        temp2.str = int.Parse(val.InnerText);
                    else if (val.Name == "end")
                        temp2.end = int.Parse(val.InnerText);
                    else if (val.Name == "agi")
                        temp2.agi = int.Parse(val.InnerText);
                    else if (val.Name == "mag")
                        temp2.mag = int.Parse(val.InnerText);
                    else if (val.Name == "luck")
                        temp2.luck = int.Parse(val.InnerText);
                    else if (val.Name.Contains("recipe")){
                        temp2.recipe.Add(val.InnerText);
                    }
                }
                allArmor.Add(temp2);
            }
        }
    }