Ejemplo n.º 1
0
        public void ReadFromFile(String path =@".\cartas.csv")
        {
            this.cards = new List<Card>();

            HelperCsv fichero = new HelperCsv(path);
            Card card;

            for (int i = 0; i < fichero.Count; i++)
            {
                card = new Card();

                //Id;Name;Rarity;Fuse;Level;Attack;Defense;Delay;Faction1;Faction2;Faction3;Skill1;Skill2;Skill3;Skill4;Skill5
                card.Id = Convert.ToInt32(fichero[i, "Id"]);
                card.Name = fichero[i, "Name"];
                card.Rarity = fichero[i, "Rarity"];
                card.Fuse = fichero[i, "Fuse"];
                card.Delay = Convert.ToInt32(fichero[i, "Delay"]);
                card.Level = Convert.ToInt32(fichero[i, "Level"]);
                card.Attack = Convert.ToInt32(fichero[i, "Attack"]);
                card.Defense = Convert.ToInt32(fichero[i, "Defense"]);

                if (!String.IsNullOrWhiteSpace(fichero[i, "Faction1"])) card.Factions.Add(fichero[i, "Faction1"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Faction2"])) card.Factions.Add(fichero[i, "Faction2"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Faction3"])) card.Factions.Add(fichero[i, "Faction3"]);

                if (!String.IsNullOrWhiteSpace(fichero[i, "Skill1"])) card.AddSkillFromText(fichero[i, "Skill1"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Skill2"])) card.AddSkillFromText(fichero[i, "Skill2"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Skill3"])) card.AddSkillFromText(fichero[i, "Skill3"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Skill4"])) card.AddSkillFromText(fichero[i, "Skill4"]);
                if (!String.IsNullOrWhiteSpace(fichero[i, "Skill5"])) card.AddSkillFromText(fichero[i, "Skill5"]);

                this.cards.Add(card);
            }
        }
Ejemplo n.º 2
0
        public List<Card> CardsForSkill(Player player, Skill skill, Card fromCard)
        {
            bool targetAttacker = Attacker.Id == player.Id;

            string name = skill.Name.ToLower();

            bool targetShelf = name == "barrier"
                                || name == "empower" || name == "heal"
                                || name == "legion" || name == "fervor";

            targetAttacker = targetAttacker ? targetShelf : !targetShelf;

            return targetAttacker ? Attacker.CardsForSkill(skill, fromCard) : Defender.CardsForSkill(skill, fromCard);
        }
Ejemplo n.º 3
0
        public TestEngine()
        {
            //Set initial Decks
            baseDeck = new List<Card>();
            Card card;
            card = new Card() { Attack = 1, Defense = 10, Delay = 0 }; baseDeck.Add(card);
            card = new Card() { Attack = 2, Defense = 5, Delay = 1 }; baseDeck.Add(card);
            card = new Card() { Attack = 3, Defense = 2, Delay = 2 }; baseDeck.Add(card);

            game = new Game();

            Player player;
            player = new Player() { HitPoints = 10, Name = "A", Id = 1 };
            game.PlayerA = player;
            player = new Player() { HitPoints = 10, Name = "B", Id = 2 };
            game.PlayerB = player;
        }
Ejemplo n.º 4
0
Archivo: Card.cs Proyecto: Amarinal/S3
        public void TakeAttack(Card fromCard)
        {
            int attackValue = fromCard.AttackModified;
            int pierceValue = 0;
            int armorValue = 0;

            if (attackValue == 0) return;

            foreach (Skill skill in fromCard.Skills.Where(x => x.Name.ToLower() == "pierce"))
            {
                pierceValue += skill.Value;
            }

            foreach (Skill skill in this.Skills.Where(x => x.Name.ToLower() == "armor"))
            {
                armorValue += skill.Value;
            }

            if (this.Barrier > 0)
            {
                for (int i = 0; i < Barrier; i++)
                {
                    if (attackValue == 0) break;
                    if (pierceValue == 0)
                    {
                        attackValue--;
                    }
                    else
                    {
                        pierceValue--;
                    }
                    Barrier--;
                }
            }

            //Armor
            if (attackValue > 0)
            {
                for(int j = 0; j < armorValue; j++)
                {
                    if (attackValue == 0) break;
                    if (pierceValue == 0)
                    {
                        attackValue--;
                    }
                    else
                    {
                        pierceValue--;
                    }
                    armorValue--;
                }
            }

            if (attackValue > 0)
            {
                this.defense -= attackValue + Hex;

                //Attacker´s Siphon
                foreach (Skill skill in fromCard.Skills.Where(x => x.Name.ToLower() == "siphon"))
                {
                    fromCard.defense += (attackValue > skill.Value) ? attackValue : skill.Value;
                }
            }

            //Vengance
            foreach (Skill skill in this.Skills.Where(x => x.Name.ToLower() == "vengance"))
            {
                fromCard.defense -= skill.Value;
            }

            if (fromCard.defense < 1) return;

            //Scorch
            if (fromCard.Skills.Where(x => x.Name.ToLower() == "scorch").Count() > 0)
            {
                Scorched = true;
                Scorch += fromCard.Skills.Where(x => x.Name.ToLower() == "scorch").Sum(s => s.Value);
            }

            //Poison
            if (attackValue > 0 && fromCard.Skills.Where(x => x.Name.ToLower() == "poison").Count() > 0)
            {
                Poison = fromCard.Skills.Where(x => x.Name.ToLower() == "poison").Max(s => s.Value);
            }
        }
Ejemplo n.º 5
0
Archivo: Card.cs Proyecto: Amarinal/S3
        public Card Clone()
        {
            Card carta = new Card();

            carta.Attack = this.Attack;
            carta.Defense = this.Defense;
            carta.Name = this.Name;
            carta.Id = this.Id;
            carta.Level = this.Level;
            carta.Fuse = this.Fuse;
            carta.Rarity = this.Rarity;
            carta.Delay = this.Delay;

            Skill nueva;
            foreach (Skill skill in Skills)
            {
                nueva = new Skill();
                nueva.Name = skill.Name;
                nueva.Value = skill.Value;
                nueva.Category = skill.Category;
                nueva.Aux = skill.Aux;

                foreach (string mod in skill.Modifiers)
                {
                    nueva.Modifiers.Add(mod);
                }

                carta.Skills.Add(nueva);
            }

            foreach (String faction in this.Factions)
            {
                carta.Factions.Add(faction);
            }

            return carta;
        }
Ejemplo n.º 6
0
        public void TakeAttack(Card fromCard)
        {
            this.hitPoints -= fromCard.AttackModified;

            if (this.hitPoints < 1)
            {
                throw new DeadPlayerExeption(this);
            }

            //Vengance
            foreach (Skill skill in this.Skills.Where(x => x.Name.ToLower() == "vengance"))
            {
                fromCard.Defense -= skill.Value;
            }
        }
Ejemplo n.º 7
0
        public List<Card> CardsForSkill(Skill skill, Card fromCard=null)
        {
            int targetDelay = 0;
            int fromCardIndex = -1;
            string skillname = skill.Name.ToLower();
            List<Card> activeList = new List<Card>();
            List<Card> factionList = new List<Card>();
            List<Card> list = new List<Card>();

            switch (skillname)
            {
                case "armor":
                    targetDelay = -1;
                    break;
                case "freeze":
                    targetDelay = 1;
                    if (skill.Aux < skill.Value)
                    {
                        skill.Aux++;
                        return list;
                    }
                    break;
                case "dualstrike":
                    if (skill.Aux < skill.Value)
                    {
                        skill.Aux++;
                    }
                    return list;
                case "weaken":
                    targetDelay = 1;
                    break;
                case "hex":
                case "bolt":
                case "barrier":
                    targetDelay = 5;
                    break;
                case "enhance":
                case "legion":
                case "empowerment":
                case "heal":
                default:
                    targetDelay = 0;
                    break;
            }

            if (skillname == "fervor" || skillname == "legion")
            {

                if (!skill.Modifiers.Select(x => x.ToLower()).Contains("all")) skill.Modifiers.Add("all");

                for (int i = 0; i < hand.Count; i++)
                {
                    if (fromCard != null && hand[i] == fromCard)
                    {
                        fromCardIndex = i;
                        if (i > 0)
                        {
                            activeList.Add(hand[i - 1]);
                            factionList.Add(hand[i - 1]);
                        }

                        if (i < hand.Count - 1)
                        {
                            activeList.Add(hand[i + 1]);
                            factionList.Add(hand[i + 1]);
                        }

                        break;
                    }
                }
            }
            else
            {
                for (int i = 0; i < hand.Count; i++)
                {

                    if (hand[i].Defense > 0 && hand[i].Delay <= targetDelay)
                    {

                        activeList.Add(hand[i]);
                        factionList.Add(hand[i]);
                    }
                }
            }

            foreach (String modifier in skill.Modifiers)
            {
                if (modifier.ToLower() == "all") continue;

                foreach (Card card in activeList)
                {
                    if (!card.Factions.Select(x => x.ToLower()).Contains(modifier.ToLower()))
                    {
                        factionList.Remove(card);
                    }
                }
            }

            //Heal can only target damaged cards
            if (skillname == "Heal") factionList = factionList.Where(x => x.Defense < x.DefenseMax).ToList();

            //Weaken can only target cards with attack>0
            if (skillname == "weaken") factionList = factionList.Where(x => x.AttackModified > 0).ToList();

            //legion only affect active cards
            if (skillname == "legion")
            {
                foreach (Card card in activeList)
                {
                    if (card.Delay > 0 || card.Defense < 1) factionList.Remove(card);
                }
            }

            //fervor only affect my card
            if (skillname == "fervor")
            {
                skill.Aux = factionList.Count;
                factionList = new List<Card>();
                factionList.Add(fromCard);
            }

            if (skill.Modifiers.Select(x => x.ToLower()).Contains("all"))
            {
                list = factionList;
            }
            else
            {
                if (factionList.Count > 0)
                {
                    Random random = new Random();
                    list.Add(factionList[random.Next(factionList.Count)]);
                }
            }

            return list;
        }