Exemplo n.º 1
0
        /// <summary>
        /// Gives back a list with the knife cards attributes in the ai's hand.
        /// </summary>
        /// <param name="knifeCard"></param>
        /// <returns></returns>
        public List <int> GetKnifeCardAttributes(KnifeCard knifeCard)
        {
            List <int> DecideMaxKnife = new List <int>();

            DecideMaxKnife.Add(knifeCard.armorpen);
            DecideMaxKnife.Add(knifeCard.sharpness);
            return(DecideMaxKnife);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the card's attribute in string form, that the ai should choose.
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public string ReturnBestAttribute(Card card)
        {
            // In case of a knifecard, chooses armorpen or sharpness, depending on which is a higher number.
            string ChooseAttributeForKnife(KnifeCard card)
            {
                int CardArmorPen = ChooseCardToPlay().armorpen;

                KnifeCard knife         = (KnifeCard)ChooseCardToPlay();
                int       CardSharpness = knife.sharpness;

                if (CardArmorPen > CardSharpness)
                {
                    return("armorpen");
                }
                else if (CardArmorPen < CardSharpness)
                {
                    return("sharpness");
                }
                throw new Exception();
            }

            // In case of a weaponcard, chooses armorpen or firerate, depending on which is a higher number.
            string ChooseAttributeForWeapon(WeaponCard card)
            {
                int CardArmorPen = ChooseCardToPlay().armorpen;

                WeaponCard weapon       = (WeaponCard)ChooseCardToPlay();
                int        CardFireRate = weapon.fireRate;

                if (CardArmorPen > CardFireRate)
                {
                    return("armorpen");
                }
                else if (CardArmorPen < CardFireRate)
                {
                    return("firerate");
                }
                throw new Exception();
            }

            if (card is WeaponCard)
            {
                return(ChooseAttributeForWeapon((WeaponCard)card));
            }
            else if (card is KnifeCard)
            {
                return(ChooseAttributeForKnife((KnifeCard)card));
            }
            throw new Exception();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads out the cards from a given csv file, and puts them in the listOfCards field.
        /// </summary>
        /// <param name="path"></param>
        public void CsvHandler(string path)
        {
            var    weapons = new List <WeaponCard>();
            var    knieves = new List <KnifeCard>();
            string name;
            int    attribute1;
            int    attribute2;

            using (var rd = new StreamReader(path))
            {
                int linecounter = 0;

                while (!rd.EndOfStream)
                {
                    linecounter++;
                    var line = rd.ReadLine();

                    if (line.Contains("Knife"))
                    {
                        var values = line.Split(',');
                        name       = values[0];
                        attribute1 = Int32.Parse(values[1]);
                        attribute2 = Int32.Parse(values[2]);
                        var knieve = new KnifeCard(name, attribute1, attribute2);
                        knieves.Add(knieve);
                        listOfCards.Add(knieve);
                    }
                    else
                    {
                        var values = line.Split(',');
                        name       = values[0];
                        attribute1 = Int32.Parse(values[1]);
                        attribute2 = Int32.Parse(values[2]);
                        var weapon = new WeaponCard(name, attribute1, attribute2);
                        weapons.Add(weapon);
                        listOfCards.Add(weapon);
                    }
                }
            }
        }