Exemplo n.º 1
0
    public void ProcessCard(Card card, EnemyController enemy)
    {
        if (WhichTurn == Turn.Enemies)
        {
            return;
        }

        // Self
        Debug.Log("Player playing card: " + card);
        this.cardsPlayedThisTurn++;

        this.pierce = false;
        foreach (var cardEffect in card.effects.Where((effect) => effect.target == Target.Self))
        {
            switch (cardEffect.effect.name)
            {
            case "Heal":
                this.playerHP.Value += cardEffect.amount;
                if (this.playerHP.Value > this.maxPlayerHP.Value)
                {
                    this.playerHP.Value = this.maxPlayerHP.Value;
                }
                break;

            case "Pierce":
                this.pierce = true;
                break;

            case "Focused":
                //this.playerIsFocused = true;
                break;

            case "Guard":
                this.playerGuard.Value = cardEffect.amount;
                this.activeEffects.Add(new ActiveEffect {
                    effect = cardEffect.effect, amount = cardEffect.amount, timer = cardEffect.time - 1
                });
                break;

            case "Reboot":
                this.activeEffects.Clear();
                this.playerInventory.deck.Clear();
                break;

            default:
                int  amount    = cardEffect.amount;
                bool hasTrojan = this.playerModules.modules.Any((module) => module.name == "Trojan");
                if (hasTrojan)
                {
                    amount++;
                }
                this.activeEffects.Add(new ActiveEffect {
                    effect = cardEffect.effect, amount = amount, timer = cardEffect.time
                });
                break;
            }
        }

        // Enemy

        if (enemy == null)
        {
            enemy = FindObjectOfType <EnemyController>();
        }
        enemy.AddEffects(card.effects.Where((effect) => effect.target == Target.Enemy));

        int  totalDamage  = card.physicalDamage + this.playerDamageMod.Value;
        bool hasHalfAdder = this.playerModules.modules.Any((module) => module.name == "Half Adder");

        if (hasHalfAdder)
        {
            totalDamage++;
        }

        if (card.physicalDamage != 0)
        {
            enemy.TakeDamage(totalDamage, this.pierce);
        }

        if (this.cardsPlayedThisTurn == 1)
        {
            bool hasFloppyDrive = this.playerModules.modules.Any((module) => module.name == "Floppy Drive");
            if (hasFloppyDrive)
            {
                return;
            }
        }

        SwitchToTurn(Turn.Enemies);
    }