Examples of AICardHints


Examples of csa.jportal.ai.standardAI.hints.AICardHints

     * @param varName name of the hint
     * @return 0 if no hint was found, value of hint otherwise (which might also be 0)
     */
    public static int getHintInt(Card card, String varName)
    {
        AICardHints hints = new AICardHints(card);
        AIHint hint = hints.getHintbyVarname(varName);
        if (hint == null) return 0;
        Integer i = hint.getInteger();
        if (i==null) i=0;
        return i;
    }
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

     * @param varName name of the hint
     * @return "" (empty string) if no hint was found, value of hint otherwise
     */
    public static String getHintString(Card card, String varName)
    {
        AICardHints hints = new AICardHints(card);
        AIHint hint = hints.getHintbyVarname(varName);
        if (hint == null) return "";
        String s = hint.getString();
        if (s==null) s="";
        return s;
    }
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

     * @param varName names of hints to be tested of the hint
     * @return false if no hint of provided name-list was found, true if at least one was found
     */
    public static boolean hasHints(Card card, String[] varName)
    {
        AICardHints hints = new AICardHints(card);
        boolean ret = false;
        for (int i = 0; i < varName.length; i++)
        {
            AIHint hint = hints.getHintbyVarname(varName[i]);
            ret = (hint != null);
            if (ret) break;
        }
        return ret;
    }
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

     * @param varName names of hints to be tested of the hint
     * @return false if no hint of provided name-list was found (testing only boolean hints), true if at least one was found
     */
    public static boolean hasBoolHints(Card card, String[] varName)
    {
        AICardHints hints = new AICardHints(card);
        boolean ret = false;
        for (int i = 0; i < varName.length; i++)
        {
            AIHint hint = hints.getHintbyVarname(varName[i]);
            ret = ((hint != null) && (hint.getBoolean()));
            if (ret) break;
        }
        return ret;
    }
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

        Logable D = Configuration.getConfiguration().getDebugEntity();
        int debugLevel = 3;
        MatchComputerPlayer player = (MatchComputerPlayer)p;

        boolean ret = true;
        AICardHints hints = new AICardHints(card);
        AIHint hint = hints.getHintbyVarname("HINT_TARGET");
        if (hint != null)
        {
            if (!(hint.getString().equals("TAP"))) return true;
        }

        CardList grave = match.getGraveyard(p);
        CardList creature = match.getBattlefield(p).getSubListByType("Creature");
        CardList land = match.getLand(p);
        CardList hand = match.getHand(p);
        CardList attacker = match.getAttackerList();
        CardList opponentCreature = match.getBattlefieldOpponent(p).getSubListByType("Creature");
        CardList opponentLand = match.getLandOpponent(p);
        CardList opponentHand = match.getHandOpponent(p);

        Vector ands = new Vector ();

        // NEED are and booleans!
        hint = hints.getHintbyVarname("PLAYER_CREATURE_GRAVE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(grave.getSubListByType("Creature"), hints));

        hint = hints.getHintbyVarname("PLAYER_GRAVE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(grave.size()>0);


        hint = hints.getHintbyVarname("PLAYER_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
            ands.add(checkList(creature, hints));
            if (!(AIHelper.hasBoolHint(card, "MAINPHASE2_NEEDED")))
                ands.add(checkListCreaturesCombatEnabled(creature));
        }

        hint = hints.getHintbyVarname("PLAYER_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(land, hints));

        hint = hints.getHintbyVarname("PLAYER_HAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(hand, hints));

        hint = hints.getHintbyVarname("PLAYER_HAND_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(hand, hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_HAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
            boolean helper = checkList(hand.getSubListByType("Creature"), hints);
            ands.add(helper);
            hint = hints.getHintbyVarname("CARD_SELF_OK");
            if (((hint != null) && (!hint.getBoolean())))
            {
                ands.add(hand.getSubListByType("Creature").size() != 1);
            }
        }

        hint = hints.getHintbyVarname("OPPONENT_ATTACKER_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(attacker, hints));

        hint = hints.getHintbyVarname("OPPONENT_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature, hints));

        hint = hints.getHintbyVarname("OPPONENT_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentLand, hints));

        hint = hints.getHintbyVarname("OPPONENT_HAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentHand, hints));

        hint = hints.getHintbyVarname("OPPONENT_UNTAPPED_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentLand.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_TAPPED_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(creature.getSubListTapState(true), hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_UNTAPPED_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(creature.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("OPPONENT_TAPPED_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature.getSubListTapState(true), hints));

        hint = hints.getHintbyVarname("OPPONENT_UNTAPPED_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("MAINPHASE2_NEEDED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add( match.getPhase() == match.PHASE_MAIN2 );

        for (int i = 0; i < ands.size(); i++)
        {
            Boolean boolean1 = (Boolean) ands.elementAt(i);
            ret = ret && boolean1;
        }

        if (!ret) return ret;

        hint = hints.getHintbyVarname("PLAYER_CREATURE_ATTACKER_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
                CardList myCreatures = match.getBattlefield(player).getSubListByType("Creature");
                //to ignore! CAN_BE_TAPPED_INSTEAD_ATTACK
                myCreatures = AIHelper.removeWithHint(myCreatures, "CAN_BE_TAPPED_INSTEAD_ATTACK");
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

    }

    public static CardList adjustListWithCardNeeds(CardList list, Card card)
    {
        CardList ret = list.copyList();
        AICardHints hints = new AICardHints(card);

        if (AIHelper.hasHint(card, "CARD_ABILITIES_NEEDED")) ret = ret.onlyWithAbility(AIHelper.getHintString(card, "CARD_ABILITIES_NEEDED"));
        if (AIHelper.hasHint(card, "CARD_COLORS_NEEDED")) ret = ret.onlyWithColors(AIHelper.getHintString(card, "CARD_COLORS_NEEDED"));
        if (AIHelper.hasHint(card, "CARD_SUBCARD_TYPES_NEEDED")) ret = ret.onlyWithSubtypes(AIHelper.getHintString(card, "CARD_SUBCARD_TYPES_NEEDED"));
        if (AIHelper.hasHint(card, "CARD_TYPES_NEEDED")) ret = ret.onlyWithTypes(AIHelper.getHintString(card, "CARD_TYPES_NEEDED"));
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

        for (int i=0; i<list.size(); i++ )
        {
            boolean ok = true;
            Card card = list.getCard(i);
            AICardHints hints = new AICardHints(card);
            if (AIHelper.hasHint(card, "FROM_OPPONENT_LAND"))
            {
                CardList l = adjustListWithCardNeeds(match.getLand(o), card);
                ok = (l.size() > 0);
                D.addLog("AI: adjustListWithCardNeeds, LIST->! "+card+" FROM_OPPONENT_LAND -> ok="+ok,debugLevel);
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

        D.addLog("AI: getInstantsForMain()!",debugLevel);

        CardList ret = new CardList();
        Vector v = cards.getCards();
        AICardHints hints;
        AIHint hint;
        D.addLog("AI: Examining "+cards.size()+" cards.",debugLevel);
        for (int i = 0; i < v.size(); i++)
        {
            Card card = (Card) v.elementAt(i);
            D.addLog("AI: Examining card: "+card,debugLevel);
            hints = new AICardHints(card);
            hint = hints.getHintbyVarname("INSTANT_WHEN_OPPONENT_SORCERY_PLAYED");
            if ((hint != null) && (hint.getBoolean()))
            {
                D.addLog("AI: hint: INSTANT_WHEN_OPPONENT_SORCERY_PLAYED found!",debugLevel);
                ret.addCard(card);
                continue;
            }

            hint = hints.getHintbyVarname("INSTANT_WHEN_OPPONENT_CREATURE_PLAYED");
            if ((hint != null) && (hint.getBoolean()))
            {
                D.addLog("AI: hint: INSTANT_WHEN_OPPONENT_CREATURE_PLAYED found!",debugLevel);
                ret.addCard(card);
                continue;
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

        Logable D = Configuration.getConfiguration().getDebugEntity();

        D.addLog("AI: getInstantsForAttackers()!",debugLevel);
        CardList ret = new CardList();
        Vector v = cards.getCards();
        AICardHints hints;
        AIHint hint;
        D.addLog("AI: Examining "+cards.size()+" cards.",debugLevel);
        for (int i = 0; i < v.size(); i++)
        {
            Card card = (Card) v.elementAt(i);
            D.addLog("AI: Examining card: "+card,debugLevel);
            hints = new AICardHints(card);
            hint = hints.getHintbyVarname("INSTANT_WHEN_ATTACKING");
            if ((hint != null) && (hint.getBoolean()))
            {
                D.addLog("AI: hint: INSTANT_WHEN_ATTACKING found: "+card,debugLevel);
                ret.addCard(card);
                continue;
View Full Code Here

Examples of csa.jportal.ai.standardAI.hints.AICardHints

        boolean ret = true;
        Logable D = Configuration.getConfiguration().getDebugEntity();
        int debugLevel = 3;
        MatchComputerPlayer player = (MatchComputerPlayer)p;

        AICardHints hints = new AICardHints(card);
        AIHint hint = hints.getHintbyVarname("HINT_TARGET");
        if (hint != null)
        {
            if (hint.getString().equals("TAP")) return true;
        }
        if (hint != null)
        {
            if (hint.getString().equals("ATTACK")) return true;
        }
        if (hint != null)
        {
            if (hint.getString().equals("LIBRARY")) return true;
        }

        CardList grave = match.getGraveyard(p);
        CardList creature = match.getBattlefield(p).getSubListByType("Creature");
        CardList land = match.getLand(p);
        CardList hand = match.getHand(p);
        CardList attacker = match.getAttackerList();
        CardList opponentCreature = match.getBattlefieldOpponent(p).getSubListByType("Creature");
        CardList opponentLand = match.getLandOpponent(p);
        CardList opponentHand = match.getHandOpponent(p);

        Vector ands = new Vector ();

        // NEED are and booleans!
        hint = hints.getHintbyVarname("PLAYER_CREATURE_GRAVE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(grave.getSubListByType("Creature"), hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
            ands.add(checkList(creature, hints));
            if (!(AIHelper.hasBoolHint(card, "MAINPHASE2_NEEDED")))
                    ands.add(checkListCreaturesCombatEnabled(creature));
        }

        hint = hints.getHintbyVarname("PLAYER_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(land, hints));

        hint = hints.getHintbyVarname("PLAYER_HAND_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(hand, hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_HAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
            boolean helper = checkList(hand.getSubListByType("Creature"), hints);
            ands.add(helper);
            hint = hints.getHintbyVarname("CARD_SELF_OK");
            if (((hint != null) && (!hint.getBoolean())))
            {
                ands.add(hand.getSubListByType("Creature").size() != 1);
            }
        }

        hint = hints.getHintbyVarname("OPPONENT_ATTACKER_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(attacker, hints));

        hint = hints.getHintbyVarname("OPPONENT_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature, hints));

        hint = hints.getHintbyVarname("OPPONENT_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentLand, hints));

        hint = hints.getHintbyVarname("OPPONENT_HAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentHand, hints));

        hint = hints.getHintbyVarname("OPPONENT_UNTAPPED_LAND_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentLand.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_TAPPED_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(creature.getSubListTapState(true), hints));

        hint = hints.getHintbyVarname("PLAYER_CREATURE_UNTAPPED_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(creature.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("OPPONENT_TAPPED_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature.getSubListTapState(true), hints));

        hint = hints.getHintbyVarname("OPPONENT_UNTAPPED_CREATURE_NEED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add(checkList(opponentCreature.getSubListTapState(false), hints));

        hint = hints.getHintbyVarname("MAINPHASE2_NEEDED");
        if (((hint != null) && (hint.getBoolean())))
            ands.add( match.getPhase() == match.PHASE_MAIN2 );

        hint = hints.getHintbyVarname("OPPONENT_HIGHER_HEALTH_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
          boolean ok = false;
          int myLife = match.getLife(p);
          int opLife = match.getLifeOpponent(p);
          if (myLife < opLife)
          {
            ok = true;
            hint = hints.getHintbyVarname("COUNT");
            if (hint != null)
            {
              int dif = opLife - myLife;
              int count = AIHelper.getHintInt(card, "COUNT");
              if (dif > count) ok = false;
            }
          }

          ands.add( ok );
        }


        if (card.isCreature())
        {
            hint = hints.getHintbyVarname("CARD_ONLY_ONE");
            if (((hint != null) && (hint.getBoolean())))
            {
                ands.add( !creature.isInListID(card) );
            }
        }

        for (int i = 0; i < ands.size(); i++)
        {
            Boolean boolean1 = (Boolean) ands.elementAt(i);
            ret = ret && boolean1;
        }

        if (!ret) return ret;

        ret = !checkDeath(card, match, player);
        if (!ret) return ret;

        hint = hints.getHintbyVarname("PLAYER_CREATURE_ATTACKER_NEED");
        if (((hint != null) && (hint.getBoolean())))
        {
                CardList myCreatures = match.getBattlefield(player).getSubListByType("Creature");
                //to ignore! CAN_BE_TAPPED_INSTEAD_ATTACK
                myCreatures = AIHelper.removeWithHint(myCreatures, "CAN_BE_TAPPED_INSTEAD_ATTACK");
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.