private bool PowerMonsterSelection(ITargetable target)
    {
        int highestAtk = 0;
        int atkIndex   = -1;

        // finds the highest avg stat and HP creature spawns among the playable hand
        for (int i = 0; i < _playableHand.Count; i++)
        {
            SpawnPlayEffect spawn = Hand.GetCard(_playableHand[i]).PlayEffect as SpawnPlayEffect;
            if (spawn != null)
            {
                if (spawn.Creature.AttackDamage >= highestAtk)
                {
                    highestAtk = spawn.Creature.AttackDamage;
                    atkIndex   = _playableHand[i];
                }
            }
        }

        if (atkIndex != -1)
        {
            _invoker.ExecuteCommand(new AbilityCommand(this, target, atkIndex));
            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public bool UseCard(AbilityCard card)
    {
        SpawnPlayEffect spawnEffect = card.PlayEffect as SpawnPlayEffect;

        if (spawnEffect != null)
        {
            if (Creature)
            {
                return(false);
            }

            // this is hard to debug because card.Play()'s use of the play effect depends on CurrentTarget
            TargetController.CurrentTarget = GetComponent <ITargetable>();
            card.Play();
            return(true);
        }
        else
        {
            if (!Creature)
            {
                return(false);
            }
            TargetController.CurrentTarget = Creature.gameObject.GetComponent <ITargetable>();
            card.Play();
            return(true);
        }
    }
    private bool WeightedMonsterSelection(ITargetable target) // needs a target parameter?
    {
        // roll weight for full random first
        if (RollChance(0.15f))
        {
            int index = UnityEngine.Random.Range(0, _playableHand.Count - 1);
            _invoker.ExecuteCommand(new AbilityCommand(this, target, _playableHand[index]));
            return(true);
        }

        float highestAvg = 0;
        int   avgIndex   = -1;
        int   highestHP  = 0;
        int   hpIndex    = -1;

        // finds the highest avg stat and HP creature spawns among the playable hand
        for (int i = 0; i < _playableHand.Count; i++)
        {
            // only searches through playable cards within current cost count
            SpawnPlayEffect spawn = Hand.GetCard(_playableHand[i]).PlayEffect as SpawnPlayEffect;
            if (spawn != null)
            {
                float creatureAvg = (spawn.Creature.BaseHealth + spawn.Creature.AttackDamage) / 2;
                if (creatureAvg >= highestAvg)
                {
                    highestAvg = creatureAvg;
                    avgIndex   = _playableHand[i];
                }

                if (spawn.Creature.BaseHealth >= highestHP)
                {
                    highestHP = spawn.Creature.BaseHealth;
                    hpIndex   = _playableHand[i];
                }
            }
        }

        if (RollChance(0.6f) || hpIndex == -1)
        {
            _invoker.ExecuteCommand(new AbilityCommand(this, target, avgIndex));
            return(true);
        }
        else if (hpIndex != -1)
        {
            _invoker.ExecuteCommand(new AbilityCommand(this, target, hpIndex));
            return(true);
        }

        return(false);
    }