Esempio n. 1
0
        public override Cast GetBestCast(Playfield p)
        {
            //DebugThings(p);
            Cast bc = null;

            Logger.Debug("Home = {Home}", p.home);

            #region Apollo Magic
            // Highest priority -> Can we kill the enemy with a spell
            BoardObj finisherTower = Decision.IsEnemyKillWithSpellPossible(p, out Handcard hc);
            if (finisherTower != null && (hc?.manacost > p.ownMana))
            {
                return(new Cast(hc.name, finisherTower.Position, hc));
            }
            // ------------------------------------------------------

            PlayfieldAnalyse.AnalyseLines(p);               // Danger- and Chancelevel
            currentSituation = GetCurrentFightState(p);     // Attack, Defense or UnderAttack (and where it is)
            hc = CardChoosing.GetOppositeCard(p, currentSituation) ?? CardChoosing.GetMobInPeace(p, currentSituation);
            //hc = CardChoosing.GetMobInPeace(p, currentSituation);

            if (hc == null)
            {
                Logger.Debug("Part: SpellApolloWay");
                Handcard hcApollo = SpellMagic(p, currentSituation, out VectorAI choosedPosition);

                if (hcApollo != null)
                {
                    hc = hcApollo;

                    if (choosedPosition != null && !(hc?.manacost > p.ownMana))
                    {
                        return(new Cast(hcApollo.name, choosedPosition, hcApollo));
                    }
                }
            }

            if (hc == null)
            {
                return(null);
            }

            Logger.Debug("Part: GetSpellPosition");

            VectorAI nextPosition = SpecialPositionHandling.GetPosition(p, hc);
            if (nextPosition == null)
            {
                nextPosition = PositionChoosing.GetNextSpellPosition(currentSituation, hc, p);
            }

            bc = new Cast(hc.name, nextPosition, hc);
            #endregion
            Logger.Debug("BestCast:" + bc.SpellName + " " + bc.Position.ToString());

            if (bc?.hc?.manacost > p.ownMana)
            {
                return(null);
            }
            return(bc);
        }