public void TakeDamage(GameState gameState, int amount, DamageType type, Permanent attacker)
        {
            if (type != DamageType.lightning && type != DamageType.acid)
            {
                amount -= stats.armor;
            }

            if (amount <= 0)
                return;

            if (stats.health > 0)
            {
                if (type == DamageType.fire)
                {
                    if (stats.hasKeyword(Keyword.fireproof))
                        return;

                    if (stats.hasKeyword(Keyword.fireform))
                    {
                        // fireform creatures are healed by fire
                        Heal(amount);
                        return;
                    }

                    if (stats.hasKeyword(Keyword.flammable))
                    {
                        permanentStats.burningNextTurn += amount;
                    }
                }

                if (type == DamageType.acid)
                {
                    stats.armor -= amount;
                    if (stats.armor < 0)
                    {
                        stats.health += stats.armor; // reduce health by the (negative) armor
                        stats.armor = 0;
                    }
                    permanentStats.armor = stats.armor;
                }
                else
                {
                    stats.health -= amount;
                }

                if (stats.health < 0)
                    stats.health = 0;
                permanentStats.health = stats.health;
                if (stats.health <= 0)
                {
                    gameState.Destroyed(position, attacker);
                }

                gameState.HandleTriggers(new TriggerEvent(TriggerType.onDamage, attacker, this));
            }
        }
        public void Attack(GameState gameState, Minion target, int bonusDamage, MinionAnimationBatch attackAnim, MinionAnimationBatch recoverAnim)
        {
            if (deleted)
                return;

            gameState.PayCost(mtype.attackCost);

            Vector2 basePos = drawPos;
            Vector2 targetPos = target.drawPos;
            targetPos = new Vector2(targetPos.X, targetPos.Y+target.type.texture.Height - type.texture.Height);
            Vector2 attackPos = basePos + (targetPos - basePos) * 0.5f;
            attackAnim.AddAnimation(this, basePos, attackPos);
            recoverAnim.AddAnimation(this, attackPos, basePos);

            DamageType damageType =
                stats.hasKeyword(Keyword.corrosive)? DamageType.acid:
                stats.hasKeyword(Keyword.fireform)? DamageType.fire:
                DamageType.attack;

            gameState.HandleTriggers(new TriggerEvent(TriggerType.onAttack, this, target));
            target.TakeDamage(gameState, stats.attack+bonusDamage, damageType, this);
        }