Esempio n. 1
0
        public override BaseCard CreateCopy()
        {
            SampleSpellCard result = new SampleSpellCard();

            this.CopyValuesTo(result);
            return(result);
        }
Esempio n. 2
0
        public bool CanPlaySpellCard(SampleSpellCard card, SamplePlayer player, int x, int y)
        {
            if (x < -1 || x >= PlayfieldWidth)
            {
                return(false);
            }
            if (y < 0 || y >= PlayfieldHeight)
            {
                return(false);
            }

            if (x == -1)
            {
                // Target is hero
                return(true);
            }

            int row = y;

            int numCardsOnPlayfield = GetNumberOfCards(row);

            if (x >= numCardsOnPlayfield)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets maximum amount of spell damage, that can be dealt in this round, with the current hand and remaining mana.
        /// </summary>
        /// <returns>The cards necessary to deal the damage</returns>
        /// <param name="totalDamage">Total damage. Will be negative values</param>
        private SampleSpellCard[] GetSpellDamage(out int totalDamage)
        {
            totalDamage = 0;
            int currentMana = CurrentMana;

            List <SampleSpellCard> cards = new List <SampleSpellCard>();

            for (int i = 0; i < Hand.Cards.Count; i++)
            {
                SampleBaseCard card = (SampleBaseCard)Hand.Cards[i];
                if (card.CardType == SampleCardType.Spell)
                {
                    SampleSpellCard spell = (SampleSpellCard)card;
                    if (spell.SpellPower < 0 && spell.Cost <= currentMana)
                    {
                        // It's a damage spell
                        totalDamage += -spell.SpellPower;
                        cards.Add(spell);
                        currentMana -= spell.Cost;
                    }
                }
            }

            return(cards.ToArray());
        }
Esempio n. 4
0
 private bool TryHealHero(SampleSpellCard spell)
 {
     if (CurrentHealth < MaxHealth)
     {
         Logger.Log("[AI] Casting heal " + spell + " on hero.");
         PlayCardFromHand(spell, -1, ActiveSampleMatch.GetRowForPlayer(this));
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
        public void InitCollection()
        {
            // Create minions with more attack than health
            for (int i = 0; i < 10; i++)
            {
                SampleMinionCard card = new SampleMinionCard();
                card.Attack           = (i + 1);
                card.MaxHealth        = (i + 2);
                card.Cost             = (i + 1);
                card.MaxMovesPerRound = 1;
                CardCollection.Add(card);
            }

            // Create minions with more health than attack
            for (int i = 0; i < 10; i++)
            {
                SampleMinionCard card = new SampleMinionCard();
                card.Attack           = (i + 2);
                card.MaxHealth        = (i + 1);
                card.Cost             = (i + 1);
                card.MaxMovesPerRound = 1;
                CardCollection.Add(card);
            }

            // Create damage spells
            for (int i = 0; i < 10; i++)
            {
                SampleSpellCard card = new SampleSpellCard();
                card.SpellPower = -(i + 1);
                card.Cost       = (i + 1);
                CardCollection.Add(card);
            }

            // Create heal spells
            for (int i = 0; i < 10; i++)
            {
                SampleSpellCard card = new SampleSpellCard();
                card.SpellPower = (i + 1);
                card.Cost       = (i + 1);
                CardCollection.Add(card);
            }

            Console.WriteLine("Card collection:");
            foreach (var card in CardCollection)
            {
                Console.WriteLine(card.ToString());
            }
        }
Esempio n. 6
0
 private bool TryHealMinions(SampleSpellCard spell)
 {
     SampleMinionCard[] damagedMinions = GetOwnDamagedMinions();
     for (int i = 0; i < damagedMinions.Length; i++)
     {
         int row   = 0;
         int index = 0;
         if (ActiveSampleMatch.GetPlayfieldPositionForCard(damagedMinions[i], out row, out index) == true)
         {
             Logger.Log("[AI] Casting heal " + spell + " on " + damagedMinions[i]);
             PlayCardFromHand(spell, index, row);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 7
0
        private SampleSpellCard[] GetHealingSpells()
        {
            List <SampleSpellCard> result = new List <SampleSpellCard>();

            for (int i = 0; i < Hand.Cards.Count; i++)
            {
                SampleBaseCard card = (SampleBaseCard)Hand.Cards[i];
                if (card.CardType == SampleCardType.Spell)
                {
                    SampleSpellCard spell = (SampleSpellCard)card;
                    if (spell.SpellPower > 0)
                    {
                        result.Add(spell);
                    }
                }
            }
            return(result.ToArray());
        }
Esempio n. 8
0
        private void AttackEnemyWithCards(SampleBaseCard[] cards, SampleMinionCard victimMinion)
        {
            int victimRow   = 0;
            int victimIndex = 0;

            if (victimMinion != null)
            {
                if (ActiveSampleMatch.GetPlayfieldPositionForCard(victimMinion, out victimRow, out victimIndex) == false)
                {
                    return;
                }
            }
            else
            {
                victimRow   = ActiveSampleMatch.GetRowForPlayer(ActiveSampleMatch.InactiveSamplePlayer);
                victimIndex = -1;
            }

            for (int i = 0; i < cards.Length; i++)
            {
                if (cards[i].CardType == SampleCardType.Minion)
                {
                    SampleMinionCard minion = (SampleMinionCard)cards[i];
                    int row   = 0;
                    int index = 0;
                    if (ActiveSampleMatch.GetPlayfieldPositionForCard(minion, out row, out index) == true)
                    {
                        Logger.Log("[AI] Attacking '" + (victimMinion != null ? victimMinion.ToString() : "enemy hero") + "' with minion '" + minion + "' at position " + index + ".");
                        ActiveSampleMatch.AttackWithCardUsingIndexes(row, index, victimRow, victimIndex);

                        return;
                    }
                }
                else if (cards[i].CardType == SampleCardType.Spell)
                {
                    SampleSpellCard spell = (SampleSpellCard)cards[i];
                    Logger.Log("[AI] Casting damage spell '" + spell + "' on victim '" + (victimMinion != null ? victimMinion.ToString() : "enemy hero") + "'.");
                    PlayCardFromHand(spell, victimIndex, victimRow);

                    return;
                }
            }
        }
Esempio n. 9
0
        public bool PlaySpellCard(SampleSpellCard card, SamplePlayer player, int x, int y)
        {
            if (CanPlaySpellCard(card, player, x, y) == false)
            {
                return(false);
            }

            if (x == -1)
            {
                if (card.ApplyPreActionEffect() == false)
                {
                    Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreAction trigger");
                    return(false);
                }

                // Target is hero
                SamplePlayer pl = playerList[y] as SamplePlayer;
                pl.ReceiveHealth(card.SpellPower);

                if (pl.CurrentHealth < 0)
                {
                    DeclareLoser(pl);
                }

                card.ApplyPostActionEffect();

                return(true);
            }

            SampleMinionCard targetCard = Playfield[x, y] as SampleMinionCard;

            if (targetCard == null)
            {
                return(false);
            }

            if (card.ApplyPreActionEffect() == false)
            {
                Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreAction trigger");
                return(false);
            }

            if (targetCard.ApplyPreTargetEffect(card) == false)
            {
                Logger.Log("PlaySpellCard of card '" + card + "' was aborted by PreTarget trigger of target card '" + targetCard + "'");
                return(false);
            }

            targetCard.CurrentHealth += card.SpellPower;

            targetCard.ApplyPostTargetEffect(card);

            if (targetCard.CurrentHealth <= 0)
            {
                targetCard.ApplyDeathEffect();

                RemoveCard(x, y);
            }
            if (targetCard.CurrentHealth > targetCard.MaxHealth)
            {
                targetCard.CurrentHealth = targetCard.MaxHealth;
            }

            card.ApplyPostActionEffect();

            return(true);
        }