예제 #1
0
        public bool AttackWithCardUsingIndexes(int attackerRow, int attackerIndex, int victimRow, int victimIndex)
        {
            if (attackerIndex == -1)
            {
                // Hero attack is not supported
                return(false);
            }

            SampleMinionCard minion = Playfield[attackerIndex, attackerRow] as SampleMinionCard;

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

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

                // Target is hero
                SamplePlayer pl = playerList[victimRow] as SamplePlayer;
                pl.ReceiveHealth(-minion.Attack);

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

                minion.ApplyPostActionEffect();

                return(true);
            }

            SampleMinionCard targetMinion = Playfield[victimIndex, victimRow] as SampleMinionCard;

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

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

            if (targetMinion.ApplyPreAttackedEffect(minion) == false)
            {
                Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAttack trigger of target card '" + targetMinion + "'");
                return(false);
            }
            if (minion.ApplyPreAttackedEffect(targetMinion) == false)
            {
                Logger.Log("AttackWithCardUsingIndexes of card '" + minion + "' was aborted by PreAttack trigger of source card '" + minion + "'");
                return(false);
            }

            targetMinion.CurrentHealth -= minion.Attack;
            minion.CurrentHealth       -= targetMinion.Attack;

            targetMinion.ApplyPostAttackedEffect(minion);
            minion.ApplyPostAttackedEffect(targetMinion);

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

                RemoveCard(attackerIndex, attackerRow);
            }
            if (targetMinion.CurrentHealth <= 0)
            {
                targetMinion.ApplyDeathEffect();

                RemoveCard(victimIndex, victimRow);
            }

            minion.ApplyPostActionEffect();

            return(true);
        }
예제 #2
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);
        }