Examples of CardList


Examples of csa.jportal.card.CardList

        String baseKey=E.match.getPlayerBaseKey(E.player);
        String cardKey = baseKey + "CARD_VECTOR";
        Vector cardsPlayed = (Vector) aiPlayer.getObjectData(cardKey);
        if (cardsPlayed == null) cardsPlayed = new Vector();
        CardList cardsPlayedList = new CardList();

        for (int t = 0; t <cardsPlayed.size(); t++)
        {
            Card cc = (Card) cardsPlayed.elementAt(t);
            cardsPlayedList.addCard(cc);
        }
        CardList hand = E.match.getHand(E.player);
        CardList instants = hand.getSubListByType("Instant");

        // don`t play the same aura buf twice
        for (int i=0; i<cardsPlayed.size(); i++)
        {
            Card c = (Card) cardsPlayed.elementAt(i);
            int id = c.getIntId();
            if (AIHelper.hasHint(c, "EFFECT_TEMP_AURA"))
            {
                instants = instants.removeCardById(id);
            }
        }

        E.D.addLog("EAI: Enter Stack handle" ,debugLevel);
        E.D.addLog("EAI: Match StackSize: " +E.match.getStackSize(),debugLevel);


        if (instants.size()==0)
        {
            E.D.addLog("EAI: I have no instants, so what can I do? - Nothing!",debugLevel);
            return true;
        }
        E.D.addLog("EAI: there are "+instants.size()+" instants on my hand... hm...",debugLevel);

        int phase = E.match.getPhase();
        E.D.addLog("EAI: We are in Phase: "+phase +"("+Match.PHASE_MAIN1+")",debugLevel);

        // only two types of instant cards known so far
        // for main phase
        if ((phase == Match.PHASE_MAIN1|| (phase == Match.PHASE_MAIN2))
        {
            E.D.addLog("EAI: We are in main phase now!",debugLevel);
            CardList possibleInstant = AIHelper.getInstantsForMain(instants);

            possibleInstant = AIHelper.onlyEnoughMana(possibleInstant, E.match.getLand(E.player));

            if (possibleInstant.size()==0)
            {
                E.D.addLog("EAI: I have no instants I can use this phase,  so what can I do? - Nothing!",debugLevel);
                return true;
            }

            if (E.match.getStackSize()==0)
            {
                E.D.addLog("EAI: Stack is zero, I don´t think I´ll cast anything right now.",debugLevel);
                return true;
            }

              // todo decide if stack 0 card can be handled by an instant we have!
              Card stackCard = E.match.getStackCard(E.match.getStackSize()-1);

              if (stackCard.isCreature())
              {
                    possibleInstant = AIHelper.onlyWithHint(possibleInstant,"INSTANT_WHEN_OPPONENT_CREATURE_PLAYED" );
              }
              else
              if ((stackCard.isSorcery()) || (stackCard.isInstant()))
              {
                  possibleInstant = AIHelper.onlyWithHint(possibleInstant, "INSTANT_WHEN_OPPONENT_SORCERY_PLAYED");

                  // dont negate own spells!
                  MatchPlayable ow = E.match.getOwner(stackCard);
                  int owNo = E.match.getMyNumber(ow);
                  int myNo = E.match.getMyNumber(E.player);
                  if (owNo == myNo)
                  {
                        possibleInstant =  AIHelper.removeWithHint(possibleInstant, "INSTANT_NEGATES_INSTANT_NEGATES_SORCERY");
                  }
              }
            if (possibleInstant.size()==0)
            {
                E.D.addLog("EAI: I have no instants I can use this phase,  so what can I do? - Nothing! (2)",debugLevel);
                return true;
            }
            playCardInstant(possibleInstant.getCard(0), cardsPlayed, cardKey, aiPlayer);

            return true;
        }

        // only two types of instant cards known so far
        // for opponents attack phase phase
        else if ((phase == Match.PHASE_COMBAT_DECLARE_ATTACKERS))
        {
            if (E.match.getStackSize()!=0)
            {
                // while attacking in stack?
                E.D.addLog("EAI: In stack > 1 while attacking? Don´t know yet what todo!",debugLevel);
                return true;
            }

            if (E.match.isMyTurn(E.player))
            {
                E.D.addLog("EAI: I know of no instants to play in my own turn!",debugLevel);
                return true;
            }

            E.D.addLog("EAI: We are in opponents attackers phase!",debugLevel);
            CardList possibleInstant = AIHelper.getInstantsForAttackers(instants);
            possibleInstant = AIHelper.onlyEnoughMana(possibleInstant, E.match.getLand(E.player));
            CardList goodInstants = new CardList();
            E.D.addLog("EAI: Possbile instants(1): "+possibleInstant,debugLevel);

            for (int i=0; i < possibleInstant.size();i++)
            {
                Card card = possibleInstant.getCard(i);
                if (AIHelper.sorceryHintMakesSenseNow(E.player, E.match, card))
                {
                    goodInstants.addCard(card);
                }
            }
            E.D.addLog("EAI: goodInstants (2): "+goodInstants,debugLevel);
            goodInstants = goodInstants.removeList(AIHelper.getUnUseableHandCard(goodInstants, E.match, E.player));
            E.D.addLog("EAI: goodInstants (3): "+goodInstants,debugLevel);
            goodInstants = AIHelper.adjustListWithCardNeeds(goodInstants, true, "STACK",E.match, E.player);
            E.D.addLog("EAI: goodInstants (4): "+goodInstants,debugLevel);

            if (goodInstants.size() == 0)
            {
                E.D.addLog("EAI: I have no instants I can use this phase,  so what can I do? - Nothing!",debugLevel);
                return true;
            }

            while (goodInstants.size()>0)
            {
                Card instant = goodInstants.getCard(0);     // todo chose one!

                CardList attackers = E.match.getAttackerList();
                AICardHints hints = new AICardHints(instant);

                AIHint hint = hints.getHintbyVarname("EFFECT_PLAYER_CREATURE_UNTAP");
                E.D.addLog("EAI: Hint: " +hint,debugLevel);
                if (hint != null)
                    E.D.addLog("EAI: Hint.EFFECT_PLAYER_CREATURE_UNTAP: " +hint.getBoolean(),debugLevel);
                if (((hint != null) && (hint.getBoolean())))
                {
                    CardList ownCreatures = E.match.getBattlefield(E.player);
                    CardList tapped = ownCreatures.getSubListTapState(true);

                    if (tapped.size() == 0)
                    {
                        goodInstants.removeCard(instant);
                        continue;
                    }
                }
View Full Code Here

Examples of csa.jportal.card.CardList

        String baseKey=E.match.getPlayerBaseKey(E.player);
        String cardKey = baseKey + "CARD_VECTOR";

        Vector cardsPlayed = (Vector) E.aiPlayer.getObjectData(cardKey);
        if (cardsPlayed == null) cardsPlayed = new Vector();
        CardList cardsPlayedList = new CardList();

        for (int t = 0; t <cardsPlayed.size(); t++)
        {
            Card cc = (Card) cardsPlayed.elementAt(t);
            cardsPlayedList.addCard(cc);
        }
        //#import "scripts\Allround\AIHelperScript.java"

        AIHelper.checkMoodChange(E.match, E.player);

        // bRet indicates Phase done - if not set to true at some stage
        // computer will sit in an endless loop and
        // repeatedly load and run Script!

        String landKey="TMP_KEY_"+E.match.getRound()+"landPlayed";

        E.D.addLog("EAI: Computer entered main script.",debugLevel);

        CombatFormation sorceryAction = (CombatFormation) E.aiPlayer.getObjectData(baseKey+"SORCERY_COMBO");
        E.D.addLog("EAI: Enter Main: sorceryAction: "+sorceryAction,debugLevel);
        E.aiPlayer.removeObjectData(baseKey+"SORCERY_TARGET");
        if (sorceryAction != null)
        {
            E.D.addLog("EAI: Continue sorcery combo",debugLevel);
            Card spell = handleSorcery(sorceryAction, baseKey);
            E.D.addLog("EAI: Spell: "+spell, debugLevel);
            if (spell != null ) //?
            {
                return playCard(spell,cardsPlayed, cardKey, E.aiPlayer);
            }
            else
            {
                return true;
            }

        }

        // try playing a land - if available
        if( (E.match.getPhase() == Match.PHASE_MAIN1) || (E.match.getPhase() == Match.PHASE_MAIN2))
        {
            E.D.addLog("EAI: Entering Main",debugLevel);

            // first thing we do
            boolean landPlayed = E.aiPlayer.getBoolData(landKey);
            E.D.addLog("EAI: (Boolean) landPlayed = "+landPlayed,debugLevel);
            if (!landPlayed)
            {
                E.D.addLog("EAI: Entering land not played yet",debugLevel);
                // to show we "tried" playing a land, not that we actually played one
                E.aiPlayer.setBoolData(landKey, true);
                CardList hand = E.match.getHand(E.player);
                hand = hand.removeList(cardsPlayedList);

                CardList handLands = hand.getSubListByType("Land");
                E.D.addLog("EAI: Lands in hand: " +handLands.size(),debugLevel);
                if (handLands.size()>0)
                {
                    int intelligence  = E.aiPlayer.mStrategie.getIntelligence();
                    int landPlayMood = E.match.getLand(E.player).size()-2+(intelligence/2);

                    if (landPlayMood>10)
                    {
                        int prob = 12 - (landPlayMood);
                        if (prob < 0) prob = 0;
                        int randy =  csa.Global.getRand().nextInt(10);
                        E.D.addLog("EAI: Check landplay: randy = "+randy+" prob = "+prob,debugLevel);

                        if (randy>=prob )
                        {
                            boolean skip = false;
                            // todo check if enough lands of EVERY usefull color are present (2? at least?)
                            int manaBlack = E.match.getLand(E.player).getSubListBySubType("Swamp").size();
                            int manaRed = E.match.getLand(E.player).getSubListBySubType("Mountain").size();
                            int manaWhite = E.match.getLand(E.player).getSubListBySubType("Plains").size();
                            int manaBlue = E.match.getLand(E.player).getSubListBySubType("Island").size();
                            int manaGreen = E.match.getLand(E.player).getSubListBySubType("Forest").size();

                            if ((manaBlack < 3) && (handLands.getSubListBySubType("Swamp").size()>0) ) skip = true;
                            if ((manaRed < 3) && (handLands.getSubListBySubType("Mountain").size()>0) ) skip = true;
                            if ((manaWhite < 3) && (handLands.getSubListBySubType("Plains").size()>0) ) skip = true;
                            if ((manaBlue < 3) && (handLands.getSubListBySubType("Island").size()>0) ) skip = true;
                            if ((manaGreen < 3) && (handLands.getSubListBySubType("Forest").size()>0) ) skip = true;


                          if (AIHelper.enoughLands(E.match.getLand(E.player).size(), hand ))
                            if (!skip)
                              landPlayed=true;
                        }
                    }

                    if (!landPlayed)
                    {
                        // simple AI - play first land!

                        String color = AIHelper.getColorOfLessFrequence(E.match.getLand(E.player), handLands);
                        CardList handlands = handLands.getSubListByColor(color);
                        Card aLand;
                        if (handlands.size() > 0)
                            aLand = handlands.getCard(0);
                        else
                            aLand = handLands.getCard(csa.Global.getRand().nextInt(handLands.size()));

                        return playCard(aLand,cardsPlayed, cardKey, E.aiPlayer);
                    }
                    else
                    {
                        E.D.addLog("EAI: Lands saved! " +handLands.size(),debugLevel);
                    }
                }
                // indicate we are finished for now and
                // that we want to be called again, when land was playout out by E.match
                // which is done after we "returned
            }
            else
            {
                E.D.addLog("EAI: Entering land played already",debugLevel);
            }


            // here
            E.D.addLog("EAI: Checking what to play in Main",debugLevel);

            // try playing a creature
            // if that means communication - I don´t know what will happen
            // lets come to us one at a time...
            CardList lands = E.match.getLand(E.player);
            CardList hand = E.match.getHand(E.player);
            hand = hand.removeList(cardsPlayedList);
            CardList creatureHand = hand.getSubListByType("Creature");
            CardList sorceriesHand = hand.getSubListByType("Sorcery");
            CardList possibleCreatures = AIHelper.onlyEnoughMana(creatureHand, lands);
            CardList possibleSorceries = AIHelper.onlyEnoughMana(sorceriesHand, lands);
            CardList goodSorceries = new CardList();
            CardList goodCreatures = new CardList();
            for (int i=0; i < possibleSorceries.size();i++)
            {
                Card card = possibleSorceries.getCard(i);
                if (AIHelper.sorceryHintMakesSenseNow(E.player, E.match, card))
                {
                    goodSorceries.addCard(card);
                }
            }

            for (int i=0; i < possibleCreatures.size();i++)
            {
                Card card = possibleCreatures.getCard(i);
                if (AIHelper.sorceryHintMakesSenseNow(E.player, E.match, card))
                {
                    goodCreatures.addCard(card);
                }
            }
            if(E.match.getPhase() == Match.PHASE_MAIN2)
                E.aiPlayer.removeObjectData(E.match.getPlayerBaseKey(E.player, false)+"ATTACKER_CHECK");

            // no buffs in second phase - what good should they be after attacking is done?
            CardList newGood = new CardList();
            if (E.match.getPhase() == Match.PHASE_MAIN2)
            {
                for (int i=0; i < goodSorceries.size();i++)
                {
                    Card card = goodSorceries.getCard(i);
                    if (!AIHelper.isBufCard(card))
                    {
                        newGood.addCard(card);
                    }
                }
                goodSorceries = newGood;
            }


            // these are cards for land/ color needs which are not in any deck right now
            goodSorceries = goodSorceries.removeList(AIHelper.getUnUseableHandCard(goodSorceries,Match.match, E.player));

            goodSorceries = AIHelper.adjustListWithCardNeeds(goodSorceries, true, "MAIN", E.match, E.player);
            goodCreatures = AIHelper.adjustListWithCardNeeds(goodCreatures, true, "MAIN", E.match, E.player);

            goodSorceries.sortListByManaCost();
            E.D.addLog("EAI: Good sorceries: "+ goodSorceries,1);
            possibleCreatures.sortListByManaCost();
            E.D.addLog("EAI: Good creatures: "+ goodCreatures,1);

       //     CardList opponentCreatures = E.match.getBattlefieldOpponent(E.player);
       //     CardList myCreatures = E.match.getBattlefield(E.player);

            CardList joinList = new CardList();
            joinList.addList(goodSorceries);
            joinList.addList(goodCreatures);


            AIHelper.sorceryAction = null;
            AIHelper.isCastSeeking = true;
            Card selectedCard = AIHelper.selectGoodCard(joinList, true, null, true, false, E.match, E.player);
View Full Code Here

Examples of csa.jportal.card.CardList

        }
        if (simList == null) return;
        jLabel30.setText(""+simList.size());
        final CardSimList simList2=simList;

        CardList list=new CardList();
        for (int i=0; i<simList.size(); i++)
        {
            list.addCard(simList.getCard(i).getCard());
        }

        final CardListPanel listDisplay = new csa.jportal.match.display.CardListPanel();

        listDisplay.addPlayerEventListener(new DisplayEventListener()
View Full Code Here

Examples of csa.jportal.card.CardList

        {
            // todo
        }
        if (simList == null) return;
        jLabel31.setText(""+simList.size());
        CardList list=new CardList();
        for (int i=0; i<simList.size(); i++)
        {
            list.addCard(simList.getCard(i).getCard());
        }


        final CardListPanel listDisplay = new csa.jportal.match.display.CardListPanel();
        final CardSimList simList2=simList;
View Full Code Here

Examples of csa.jportal.card.CardList

    }

    Card shouldPlayLand(VirtualMatch vMatch)
    {
        boolean skip = false;
        CardList hand = E.match.getHand(E.player);
        CardList handLands = hand.getSubListByType("Land");
        if (handLands.size() == 0) return null;

        int intelligence  = E.aiPlayer.mStrategie.getIntelligence();
        int landPlayMood = E.match.getLand(E.player).size()+3;

        if (landPlayMood>10)
        {
            int prob = 12 - (landPlayMood);
            if (prob < 0) prob = 0;
            int randy =  csa.Global.getRand().nextInt(10);

            if (randy>=prob )
            {
                // todo check if enough lands of EVERY usefull color are present (2? at least?)
                int manaBlack = vMatch.getLand(E.pNumber).getSubListBySubType("Swamp").size();
                int manaRed = vMatch.getLand(E.pNumber).getSubListBySubType("Mountain").size();
                int manaWhite = vMatch.getLand(E.pNumber).getSubListBySubType("Plains").size();
                int manaBlue = vMatch.getLand(E.pNumber).getSubListBySubType("Island").size();
                int manaGreen = vMatch.getLand(E.pNumber).getSubListBySubType("Forest").size();

                if ((manaBlack < 3) && (handLands.getSubListBySubType("Swamp").size()>0) ) skip = true;
                if ((manaRed < 3) && (handLands.getSubListBySubType("Mountain").size()>0) ) skip = true;
                if ((manaWhite < 3) && (handLands.getSubListBySubType("Plains").size()>0) ) skip = true;
                if ((manaBlue < 3) && (handLands.getSubListBySubType("Island").size()>0) ) skip = true;
                if ((manaGreen < 3) && (handLands.getSubListBySubType("Forest").size()>0) ) skip = true;


              if (enoughLands(vMatch.getLand(E.pNumber).size(), hand ))
                skip = true;
            }
        }
        if (skip) return null;

        String color = getColorOfLessFrequence(vMatch.getLand(E.pNumber), handLands);
        CardList handlands = handLands.getSubListByColor(color);
        Card aLand;

        if (handlands.size() == 1)
            aLand = handlands.getCard(0);
        else
            aLand = handLands.getCard(csa.Global.getRand().nextInt(handLands.size()));

        return aLand;
    }
View Full Code Here

Examples of csa.jportal.card.CardList

     * @param lands
     * @return list of lands which are playable
     */
    public static CardList onlyEnoughMana(CardList list, ManaCollection mana)
    {
        CardList ret = new CardList();
        for (int i=0; i < list.size();i++)
        {
            if (hasEnoughMana(list.getCard(i), mana))
            {
                ret.addCard(list.getCard(i));
            }
        }
        return ret;
    }
View Full Code Here

Examples of csa.jportal.card.CardList

     * @param lands
     * @return true if the landlist provides enough mana for the land to be played
     */
    public static CardList onlyEnoughManaActivate(CardList list, ManaCollection mana)
    {
        CardList ret = new CardList();
        for (int i=0; i < list.size();i++)
        {
            if (hasEnoughManaActivate(list.getCard(i), mana))
            {
                ret.addCard(list.getCard(i));
            }
        }
        return ret;
    }
View Full Code Here

Examples of csa.jportal.card.CardList

    public static Card getMostDamaging(CardList list)
    {
        if (list==null) return null;
        if (list.size()==0) return null;

        CardList subList = list.sortListByPower();
        subList = subList.getSubPowerEqual(subList.getCard(subList.size()-1).getNowPower());
        subList = subList.sortListByManaCost();
        return subList.getCard(subList.size()-1);
    }
View Full Code Here

Examples of csa.jportal.card.CardList

     * <BR><b>No Hint required</b><BR>
     *
     , toughness NOW not of card base */
    public static Card getKillCreature(CardList list, int damage)
    {
        CardList orderedList = list.sortListByToughness();
        for (int i=orderedList.size()-1; i>=0; i--)
        {
            if (orderedList.getCard(i).getNowToughness()==damage)
            {
                return orderedList.getCard(i);
            }
        }
        return orderedList.getCard(0);
    }
View Full Code Here

Examples of csa.jportal.card.CardList

     , toughness NOW not of card base
     (Same as getMostTough())
     */
    public static Card getDontKillCreature(CardList list, int damage)
    {
        CardList orderedList = list.sortListByToughness();
        return orderedList.getCard(orderedList.size()-1);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.