Examples of HintBundle


Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

            if (hints.hasHint(hintKey, TY_INHERENT))
            {
                if (!hints.hasHint(hintKey, HintAll.TY_YES_NO))
                    return list; // card has targets, but they are not to be selected
            }
        if (hints.hasAnyHint(hintKey, new HintBundle(TA_SELF)))
        {
            list.addCard(source);
            return list;
        }
        boolean dummyList = false;
        if ((hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_PLAYER))) || (dependenedPlayer == player))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_HAND)))
            {
                list.addList(mHand[player]);
                // dont add source
                list.remove(source);
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_FIELD)))
                list.addList(mBattlefield[player]);
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_LAND)))
                list.addList(mLand[player]);
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(TY_OPENS_PLAYER_LIBRARY))))
                {
                    initLibrary();
                    list.addList(mLibrary[player]);
                }
                else
                {
                    list.addCard(new CardSim (Card.buildDummy(), player ));
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_GRAVE)))
                list.addList(mGraveyard[player]);
        }
        if ((hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_OPPONENT))) || (dependenedPlayer == (player+1)%2))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_FIELD)))
                list.addList(mBattlefield[opponent]);
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_HAND)))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(TY_OPENS_OPPONENTS_HAND)))
                    list.addList(mHand[opponent]);
                else
                {
                    if (mHand[opponent].size() >0)
                    {
                        list.addCard(new CardSim (Card.buildDummy(),opponent));
                    }
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_LAND)))
                list.addList(mLand[opponent]);
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(TY_OPENS_OPPONENTS_LIBRARY))))
                {
                    initLibrary();
                    list.addList(mLibrary[opponent]);
                }
                else
                {
                    list.addCard(new CardSim (Card.buildDummy(),opponent));
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_GRAVE)))
                list.addList(mGraveyard[opponent]);
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TR_CHOICE_LIMITATION)))
        {
            int limit = hints.getHintValueInt(hintKey, TR_CHOICE_LIMITATION);
            list = list.onlyTop(limit);
        }


        if (hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_SELF_NOT_ALLOWED)))
        {
            list.remove(source);
        }
        String type_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_NEED);
        if (type_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                if (list.size() > 0)
                    list.getCard(0).setDummyType(type_mustBeOneOf);
            }
            else
                list = list.onlyWithTypes(type_mustBeOneOf);
        }

        String subtype_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_NEED);
        if (subtype_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                if (list.size() > 0)
                    list.getCard(0).setDummySubType(subtype_mustBeOneOf);
            }
            else
                list = list.onlyWithSubtypes(subtype_mustBeOneOf);
        }

        String color_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_NEED);
        if (color_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                if (list.size() > 0)
                    list.getCard(0).setDummyColor(color_mustBeOneOf);
            }
            else
                list = list.onlyWithColors(color_mustBeOneOf);
        }

        String ability_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_NEED);
        if (ability_mustBeOneOf.length() != 0)
            list = list.onlyWithAbility(ability_mustBeOneOf);

        String type_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_RESTRICTION);
        if (type_mustNotBeOneOf.length() != 0)
            list = list.removeTypes(type_mustNotBeOneOf);

        String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_RESTRICTION);
        if (subtype_mustNotBeOneOf.length() != 0)
            list = list.removeSubtypes(subtype_mustNotBeOneOf);

        String color_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_RESTRICTION);
        if (color_mustNotBeOneOf.length() != 0)
            list = list.removeColors(color_mustNotBeOneOf);

        String ability_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_RESTRICTION);
        if (ability_mustNotBeOneOf.length() != 0)
            list = list.removeWithAbility(ability_mustNotBeOneOf);

        boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_UNTAPPED_NEED));
        if (tapped_mustNotBe)
            list = list.removeTapped();

        boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TAPPED_NEED));
        if (tapped_mustBe)
            list = list.removeUnTapped();

        boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MIN));
        int ipowerMin = hints.getHintValueInt(hintKey, TR_CARD_POWER_MIN);
        boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MAX));
        int ipowerMax = hints.getHintValueInt(hintKey, TR_CARD_POWER_MAX);

        boolean bToughMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MIN));
        int iToughMin = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MIN);
        boolean bToughMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MAX));
        int iToughMax = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MAX);

        if (bpowerMin)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyPowerHigher(ipowerMin-1);
        }
        if (bpowerMax)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyPowerLower(ipowerMax+1);
        }
        if (bToughMin)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyToughnessHigher(iToughMin-1);
        }
        if (bToughMax)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyToughnessLower(iToughMax+1);
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_ATTACKER)))
        {
            list = list.onlyWithTypes("Creature");
            CardSimList listOrg = list.copyList();

            for (int i=0; i< listOrg.size(); i++)
            {
                if (!((listOrg.getCard(i).isAttacker()) || (mOldAttacker.isInList(listOrg.getCard(i)))))
                {
                    list.remove(listOrg.getCard(i));
                }
            }
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_BLOCKER)))
        {
            list = list.onlyWithTypes("Creature");
            CardSimList listOrg = list.copyList();

            for (int i=0; i< listOrg.size(); i++)
            {
                if (!listOrg.getCard(i).isBlocker())
                {
                    list.remove(listOrg.getCard(i));
                }
            }
        }

        HintBundle nta = new HintBundle(TY_NOT_OPPONENT_TARGETABLE);
        for (int i=list.size()-1; i>=0; i--)
        {
            CardSim card = list.getCard(i);
            if (card.owner != player)
            {
                if (EAIHelper.hasHint(card, HintAll.HINT_SITUATION_INHERENT, nta))
                    list.remove(card);
            }
        }
       
        if (hints.hasAllHint(hintKey, new HintBundle(TY_TARGETS_CHOSEN_BY_OWNER, CT_COUNT_EACH_PLAYER)))
        {
            list = list.removeOwner(opponent);
        }
       
        return list;
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        if (player == 0) opponent = 1;
       
        if (!hints.hasHint(hintKey, CS_ALL_CARDS)) // card has targets, but they are not to be selected
            if (hints.hasHint(hintKey, SY_INHERENT)) return list; // card has targets, but they are not to be selected

        if (hints.hasAnyHint(hintKey, new HintBundle(S_SELF)))
        {
            list.addCard(source);
            return list;
        }
        boolean dummyList = false;
        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_PLAYER)))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_HAND)))
            {
                list.addList(mHand[player]);
                // dont add source
                list.remove(source);
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_FIELD)))
                list.addList(mBattlefield[player]);
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_LAND)))
                list.addList(mLand[player]);
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(SY_OPENS_PLAYER_LIBRARY))))
                {
                    initLibrary();
                    list.addList(mLibrary[player]);
                }
                else
                {
                    list.addCard(new CardSim (Card.buildDummy(), player));
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_GRAVE)))
                list.addList(mGraveyard[player]);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_OPPONENT)))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_FIELD)))
                list.addList(mBattlefield[opponent]);
           
             if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_HAND)))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(SY_OPENS_OPPONENTS_HAND)))
                    list.addList(mHand[opponent]);
                else
                {
                    list.addCard(new CardSim (Card.buildDummy(),opponent));
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_LAND)))
                list.addList(mLand[opponent]);
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(SY_OPENS_OPPONENTS_LIBRARY))))
                {
                    initLibrary();
                    list.addList(mLibrary[opponent]);
                }
                else
                {
                    list.addCard(new CardSim (Card.buildDummy(),opponent));
                    dummyList = true;
                }
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(S_FROM_GRAVE)))
                list.addList(mGraveyard[opponent]);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CHOICE_LIMITATION)))
        {
            int limit = hints.getHintValueInt(hintKey, SR_CHOICE_LIMITATION);
            list = list.onlyTop(limit);
        }

       
        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_SELF_NOT_ALLOWED)))
        {
            list.remove(source);
        }
        String type_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_NEED);
        if (type_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                list.getCard(0).setDummyType(type_mustBeOneOf);
            }
            else
                list = list.onlyWithTypes(type_mustBeOneOf);
        }

        String subtype_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_NEED);
        if (subtype_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                list.getCard(0).setDummySubType(subtype_mustBeOneOf);
            }
            else
                list = list.onlyWithSubtypes(subtype_mustBeOneOf);
        }

        String color_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_NEED);
        if (color_mustBeOneOf.length() != 0)
        {
            if (dummyList)
            {
                list.getCard(0).setDummyColor(color_mustBeOneOf);
            }
            else
                list = list.onlyWithColors(color_mustBeOneOf);
        }
       
       
       
       
        String ability_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_NEED);
        if (ability_mustBeOneOf.length() != 0)
            list = list.onlyWithAbility(ability_mustBeOneOf);

        String type_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_RESTRICTION);
        if (type_mustNotBeOneOf.length() != 0)
            list = list.removeTypes(type_mustNotBeOneOf);

        String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_RESTRICTION);
        if (subtype_mustNotBeOneOf.length() != 0)
            list = list.removeSubtypes(subtype_mustNotBeOneOf);

        String color_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_RESTRICTION);
        if (color_mustNotBeOneOf.length() != 0)
            list = list.removeColors(color_mustNotBeOneOf);

        String ability_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_RESTRICTION);
        if (ability_mustNotBeOneOf.length() != 0)
            list = list.removeWithAbility(ability_mustNotBeOneOf);

        boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_UNTAPPED_NEED));
        if (tapped_mustNotBe)
            list = list.removeTapped();

        boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TAPPED_NEED));
        if (tapped_mustBe)
            list = list.removeUnTapped();

        boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MIN));
        int ipowerMin = hints.getHintValueInt(hintKey, SR_CARD_POWER_MIN);
        boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MAX));
        int ipowerMax = hints.getHintValueInt(hintKey, SR_CARD_POWER_MAX);

        boolean bToughMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MIN));
        int iToughMin = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MIN);
        boolean bToughMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MAX));
        int iToughMax = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MAX);

        if (bpowerMin)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyPowerHigher(ipowerMin-1);
        }
        if (bpowerMax)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyPowerLower(ipowerMax+1);
        }
        if (bToughMin)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyToughnessHigher(iToughMin-1);
        }
        if (bToughMax)
        {
            list = list.onlyWithTypes("Creature");
            list = list.onlyToughnessLower(iToughMax+1);
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_ATTACKER)))
        {
            list = list.onlyWithTypes("Creature");
            CardSimList listOrg = list.copyList();

            for (int i=0; i< listOrg.size(); i++)
            {
                if (!listOrg.getCard(i).isAttacker())
                {
                    list.remove(listOrg.getCard(i));
                }
            }
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_BLOCKER)))
        {
            list = list.onlyWithTypes("Creature");
            CardSimList listOrg = list.copyList();

            for (int i=0; i< listOrg.size(); i++)
            {
                if (!listOrg.getCard(i).isBlocker())
                {
                    list.remove(listOrg.getCard(i));
                }
            }
        }

        HintBundle nta = new HintBundle(SY_NOT_OPPONENT_TARGETABLE);
        for (int i=list.size()-1; i>=0; i--)
        {
            CardSim card = list.getCard(i);
            if (card.owner != player)
            {
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        // I will start with Damage player
        // damage creature (s)
        // buffs
        AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_SELF_TO_HAND, SY_SELF_TO_HAND)))
        {
            int tPlayer = source.owner;
//            if (mBattlefield[0].isInList(source)) tPlayer = 0;

            CardSimList from = null;
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

                hintKey = HintAll.HINT_SITUATION_INSTANT;
       
        if (target == null) // effect on "all"
        {
            // only attack phase // only in Main two - for now!
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_REPLAY_PHASE)))
            {
                if (phase == MatchConstants.PHASE_MAIN2)
                {
                    nextPhase = MatchConstants.PHASE_COMBAT_BEGIN;
                    turnsToSimulate += 5;
//                    if (mOldAttacker.size() > 0)
//                        System.out.println("Buh");
                }
            }

            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LOSE_AFTER_ADDITIONAL_TURN)))
            {
                mLose[player] = 2;
            }

            if (hints.hasAnyHint(hintKey, new HintBundle(TY_REPLAY_TURN)))
            {
                nextTurnPlayer = thisTurnPlayer;
                turnsToSimulate += MatchConstants.PHASE_UNDEFINED;
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TY_LIFE_EXCHANGE)))
            {
                int i = life[0];
                life[0] = life[1];
                life[1] = i;
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TY_PLAYER_AURA)))
            {
                if(hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_PLAYER_ATTACK_DAMAGE)))
                {
                    TimedEffect effect = new TimedEffect();
                    effect.name = HintAll.HINT_TTYPE_NEGATE_PLAYER_ATTACK_DAMAGE;
                    effect.isBoolean = true;
                    effect.timeOutBoolean = false;
                    effect.effectOnTargetPlayer = player;
                    negatePlayerAttackDamage[player] = true;

                    int time = hints.getHintValueInt(hintKey, TI_TURN_COUNT);
                    if (time != 0)
                    {
                        effect.isTurnCount = true;
                        effect.turnsToLast = time;
                    }
                    else
                    {
                        time = hints.getHintValueInt(hintKey, TI_PHASE_COUNT);
                        if (time != 0)
                        {
                            effect.isPhaseCount = true;
                            effect.phasesToLast = time;
                        }
                    }
                    if (time != 0)
                    {
                        timedEffects.addElement(effect);
                    }
                }
                else if(hints.hasAnyHint(hintKey, new HintBundle(TY_ATTACK_DENIAL)))
                {
                    if(hints.hasAllHint(hintKey, new HintBundle(TA_IS_OPPONENT, TY_INHERENT)))
                    {
                        TimedEffect effect = new TimedEffect();
                        effect.name = HintAll.HINT_TTYPE_ATTACK_DENIAL;
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = (player+1)%2;
                        negateAttackPhase[effect.effectOnTargetPlayer] = true;
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2;
                        timedEffects.addElement(effect);
                    }
                }
                else if(hints.hasAnyHint(hintKey, new HintBundle(TY_UNTAP_DENIAL)))
                {
                    if(hints.hasAllHint(hintKey, new HintBundle(TA_IS_OPPONENT, TY_INHERENT)))
                    {
                        TimedEffect effect = new TimedEffect();
                        effect.name = HintAll.HINT_TTYPE_UNTAP_DENIAL;
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = (player+1)%2;
                        negateUntapPhase[effect.effectOnTargetPlayer] = true;
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2;
                        timedEffects.addElement(effect);
                    }
                }
                else if(hints.hasAnyHint(hintKey, new HintBundle(TY_ALL_MUST_ATTACK)))
                {
                    if(hints.hasAllHint(hintKey, new HintBundle(TA_IS_OPPONENT, TY_INHERENT)))
                    {
                        TimedEffect effect = new TimedEffect();
                        effect.name = HintAll.HINT_TTYPE_ALL_MUST_ATTACK;
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = (player+1)%2;
                        allMustAttack[effect.effectOnTargetPlayer] = true;
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2;
                        timedEffects.addElement(effect);
                    }
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TY_AURA)))
            {
                if ( !(hints.hasAnyHint(hintKey, new HintBundle(O_WHEN_PLAYED)))
                     || (hints.hasAnyHint(hintKey, new HintBundle(O_WHEN_ACTIVATED))) )
                {
                    // aura will be evaluated in phase "automatically"
                    return;
                }
                CardSimList effectedList = getTargetEffectedList(hintKey, source, player, hints, null);

                if(hints.hasAnyHint(hintKey, new HintBundle(TY_OPPONENT_CHOSEN)))
                {
                    int count = EAIHelper.getTargetCount(source, hints, hintKey);

                    // split target list in chosen and not chosen
                    CardSimList chosenList = new CardSimList();
                    CardSimList restList;// = new CardSimList();

                    while ( (count >0) && (effectedList.size()>0) )
                    {
                        int r = csa.Global.getRand().nextInt(effectedList.size());
                        effectedList.moveCardTo(effectedList.getCard(r), chosenList);
                        count--;
                    }
                    restList = effectedList;

                    if(hints.hasAnyHint(hintKey, new HintBundle(TY_ONE_ONLY_BLOCCK)))
                    {
                        for (int i=0; i< effectedList.size(); i++)
                        {
                            CardSim tCard = effectedList.getCard(i);
                            tCard = allCards.get(tCard.getCard().getUniqueID());
                            int tPlayer = tCard.owner;
        //                    if (mBattlefield[0].isInList(tCard)) tPlayer = 0;
                            doTargetEffectOnOneCard(tCard, tPlayer, hintKey, hints, player, source);
                        }
                    }

                }
                else
                {
                    for (int i=0; i< effectedList.size(); i++)
                    {
                        CardSim tCard = effectedList.getCard(i);
                        tCard = allCards.get(tCard.getCard().getUniqueID());
                        int tPlayer = tCard.owner;
    //                    if (mBattlefield[0].isInList(tCard)) tPlayer = 0;
                        doTargetEffectOnOneCard(tCard, tPlayer, hintKey, hints, player, source);
                    }
                   
                    // sorcery / instant effects can not removed via "battlefield"
                    // but should be timed removed
                    // e.g. Treetop Defense!
                    if (source.isSorcery() || source.isInstant())
                    {

                        TimedEffect effect = new TimedEffect();
                        effect.name = "";
                        effect.effectOnTargetPlayer = player;
                        effect.effectAuraTragetCard = source;
                        effect.key = hintKey;
                        int time = hints.getHintValueInt(hintKey, TI_TURN_COUNT);
                        if (time != 0)
                        {
                            effect.isTurnCount = true;
                            effect.turnsToLast = time;
                        }
                        else
                        {
                            time = hints.getHintValueInt(hintKey, TI_PHASE_COUNT);
                            if (time != 0)
                            {
                                effect.isPhaseCount = true;
                                effect.phasesToLast = time;
                            }
                        }
                        if (time != 0)
                        {
                            timedEffects.addElement(effect);
                        }

                    }

                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(CT_ALL_CARDS)))
            {
                CardSimList effectedList = getTargetEffectedList(hintKey, source, player, hints, null);
                for (int i=0; i< effectedList.size(); i++)
                {
                    CardSim tCard = effectedList.getCard(i);
                    int tPlayer = tCard.owner;
                    tCard = allCards.get(tCard.getCard().getUniqueID());

                    if (tCard != null) // no Dummy
                        doTargetEffectOnOneCard(tCard, tPlayer, hintKey, hints, player, source);
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(CT_ALL_PLAYERS)))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(TA_IS_PLAYER)))
                {
                    doTargetEffectOnPlayer(player, hintKey, hints, source);
                    if(hints.hasAnyHint(hintKey, new HintBundle(TY_INHERENT)))
                    {
                        doTargetEffectInherent(player, hintKey, hints, source);
                    }

                }
                if (hints.hasAnyHint(hintKey, new HintBundle(TA_IS_OPPONENT)))
                {
                    doTargetEffectOnPlayer((player+1)%2, hintKey, hints, source);
                    if(hints.hasAnyHint(hintKey, new HintBundle(TY_INHERENT)))
                    {
                        doTargetEffectInherent((player+1)%2, hintKey, hints, source);
                    }
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TA_IS_PLAYER)))
            {
                doTargetEffectOnPlayer(player, hintKey, hints, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TA_IS_OPPONENT)))
            {
                if (player == 0)
                    doTargetEffectOnPlayer(1, hintKey, hints, source);
                else
                    doTargetEffectOnPlayer(0, hintKey, hints, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TA_SELF)))
            {
                doTargetEffectOnOneCard(source, source.owner, hintKey, hints, player, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TY_INHERENT)))
            {
                doTargetEffectInherent(player, hintKey, hints, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(TY_OPPONENT_CHOSEN)))
            {
                CardSimList effectedList = getTargetEffectedList(hintKey, source, player, hints, null);
                int count = EAIHelper.getTargetCount(source, hints, hintKey);

                if (count > effectedList.size()) count = effectedList.size();
               
                for (int i=0; i< count; i++)
                {
                    CardSim tCard = opponentChoseTargetCard(effectedList, player, source, hintKey);
                    effectedList.remove(tCard);
                    doTargetEffectOnOneCard(tCard, tCard.owner, hintKey, hints, player, source);
                }
            }

            // on death no action target can be given, since
            // there is no ACTION
            // to be able to include some information in VirtualMatch
            // I circumvent here...

            // try todo some calculated sensible chosing of "on" death target selections
            else if(hintKey.equals(HintAll.HINT_SITUATION_DEATH))
            {
                CardSimList effectedList = getTargetEffectedList(hintKey, source, player, hints, null);

                int good = EAIHelper.isGoodEffectCard(source, hintKey);
                int count = EAIHelper.getTargetCount(source, hints, hintKey);

                // For now only for TARGET, not for SOURCE!
                 if (good == -1) // BAD
                 {
                     if (EAIHelper.cardTargetOpponentPossible(source, hintKey , false))
                     {
                        if (EAIHelper.countOwnerCards(effectedList, (player+1)%2) >= count)
                            effectedList = EAIHelper.removeOwnerCards(effectedList, player);
                     }
                 }
                 else if (good == 1) // good
                 {
                     if (EAIHelper.cardTargetPlayerPossible(source, hintKey , false))
                     {
                        if (EAIHelper.countOwnerCards(effectedList, player) >= count)
                            effectedList = EAIHelper.removeOwnerCards(effectedList, (player+1)%2);
                     }
                 }

                for (int i=0; ((i< effectedList.size()) && (count >0)); i++, count--)
                {
                    CardSim tCard = effectedList.getCard(i);
                    doTargetEffectOnOneCard(tCard, tCard.owner, hintKey, hints, player, source);
                }
            }
        }
        else if((target.getSCard() == null) && (target.targetPlayerNumber >= 0))
        {
            doTargetEffectOnPlayer(target.targetPlayerNumber, hintKey, hints, source);
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIFE_EXCHANGE)))
            {
                int i = life[0];
                life[0] = life[1];
                life[1] = i;
            }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        if (hints.hasHint(hintKey, CT_X_COUNT))
        {
           amount = source.xMana;
        }
        // target is a player
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_DAMAGE_AMOUNT)))
        {
            preventPlayerDamage[player] += amount;
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HEAL)))
        {
            life[player] += amount;
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_DAMAGE)))
        {
            life[player] -= amount;
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HALF_LIFE)))
        {
            life[player] /= 2;
        }
    }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        }
        if (hints.hasHint(hintKey, CT_HAS_MULTIPLYER))
        {
            amount = getTargetMultiplyAmount( player,  hintKey, hints);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TA_IS_OWNER)))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HEAL)))
            {
                life[tPlayer] += amount;
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_DAMAGE)))
            {
                life[tPlayer] -= amount;
            }
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_DAMAGE_AMOUNT)))
        {
            tCard.addPreventDamage(amount);
           
//        if (tCard.getCard().getId().equals("4332"))
//            System.out.println("Buh");
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_SELF_DESTRUCT)))
        {
            creatureToGrave(source);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_TO_TAP)))
        {
            tCard.setTapped(true);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_TO_UNTAP)))
        {
            tCard.setTapped(false);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_ABILITY_ADD)))
        {
            String v = hints.getHintValue(hintKey, TY_ABILITY_ADD);
            if (!reverseEffect)
                tCard.addAbility(v);
            else
                tCard.subAbility(v);
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_DAMAGE, TY_TOUGHNESS_SUB)))
        {
            if (amount == 0)
                amount = hints.getHintValueInt(hintKey, TY_TOUGHNESS_SUB);
            if (hints.hasHint(hintKey, CT_X_COUNT))
            {
               amount = source.xMana;
            }
            if (!reverseEffect)
                tCard.addToughness(-amount);
            else
                tCard.subToughness(-amount);



            if (tCard.getNowToughness() <= 0)
            {
                creatureToGrave(tCard);
            }
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_TOUGHNESS_ADD)))
        {
           
            amount = hints.getHintValueInt(hintKey, TY_TOUGHNESS_ADD);
            if (hints.hasHint(hintKey, CT_X_COUNT))
            {
               amount = source.xMana;
            }
            if (!reverseEffect)
                tCard.addToughness(amount);
            else
                tCard.subToughness(amount);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_POWER_ADD)))
        {
            amount = hints.getHintValueInt(hintKey, TY_POWER_ADD);
            if (hints.hasHint(hintKey, CT_X_COUNT))
            {
               amount = source.xMana;
            }
            if (!reverseEffect)
                tCard.addPower(amount);
            else
                tCard.subPower(amount);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_POWER_SUB)))
        {
            amount = hints.getHintValueInt(hintKey, TY_POWER_SUB);
            if (hints.hasHint(hintKey, CT_X_COUNT))
            {
               amount = source.xMana;
            }
            if (!reverseEffect)
                tCard.addPower(-amount);
            else
                tCard.subPower(-amount);
        }

        if(hints.hasAnyHint(hintKey, new HintBundle(TY_ONE_ONLY_BLOCCK)))
        {
            if (!reverseEffect)
                tCard.addAbility("NoBlock");
            else
                tCard.subAbility("NoBlock");
        }
        if(hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_ROCHADE)))
        {
            if (!tCard.getCard().isDummy())
            {
                // NO Dummy library
                initLibrary();

                CardSimList from = null;
                CardSimList to = null;
                from = mHand[tPlayer];
                to = mLibrary[tPlayer];

                from.moveCardTo(tCard, to);
                to.shuffle();

                // draw first
                CardSim nCard = to.getCard(to.size()-1);
                to.moveCardTo(nCard, from);
            }
            return;
        }
        if(hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_GRAVE_ROCHADE)))
        {
            if (!tCard.getCard().isDummy())
            {
                // NO Dummy library
                initLibrary();

                CardSimList from = null;
                CardSimList to = null;
                from = mHand[tPlayer];
                to = mGraveyard[tPlayer];
                from.moveCardTo(tCard, to);
               
                CardSimList from2 = null;
                CardSimList to2 = null;
                from2 = mLibrary[tPlayer];
                to2 = mHand[tPlayer];
                from2.shuffle();

                // draw first
                CardSim nCard = from2.getCard(to.size()-1);
                to2.moveCardTo(nCard, from2);
            }
            return;
        }

        if(hints.hasAnyHint(hintKey, new HintBundle(TY_ALL_BLOCK_ONE)))
        {
            TimedEffect effect = new TimedEffect();
            effect.name = HintAll.HINT_TTYPE_ALL_MUST_ATTACK;
            effect.isObject = true;
            effect.timeOutObject = null;
            effect.effectOnTargetPlayer = (player+1)%2;
            allBlockOne[effect.effectOnTargetPlayer] = tCard;
            effect.isTurnCount = true;
            effect.turnsToLast = 2;
            timedEffects.addElement(effect);
        }


        CardSimList from = null;
        CardSimList to = null;
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_COMTROL_CHANGE)))
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_LAND)))
            {
                to = mLand[player];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TA_FROM_FIELD)))
            {
                to = mBattlefield[player];
            }
            to.addCard(tCard);
            mControlChange = true;
        }
        from = null;
        to = null;

        boolean sicken = false;
//if (tPlayer == -1)
//    System.out.println("Buh!");
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_HAND_TO_LAND, TY_HAND_TO_FIELD, TY_HAND_TO_LIBRARY, TY_HAND_TO_EXILE)))
            from = mHand[tPlayer];
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_LAND_TO_GRAVE, TY_LAND_TO_HAND, TY_LAND_TO_LIBRARY, TY_LAND_TO_EXILE)))
            from = mLand[tPlayer];
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TO_GRAVE, TY_LIBRARY_TO_HAND, TY_LIBRARY_TO_LAND, TY_LIBRARY_TO_FIELD, TY_LIBRARY_TO_EXILE, TY_LIBRARY_TO_LIBRARY)))
            from = mLibrary[tPlayer];
       
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_GRAVE, TY_FIELD_TO_HAND, TY_FIELD_TO_LIBRARY, TY_FIELD_TO_EXILE)))
            from = mBattlefield[tPlayer];
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_HAND, TY_GRAVE_TO_FIELD, TY_GRAVE_TO_LAND, TY_GRAVE_TO_LIBRARY, TY_GRAVE_TO_EXILE)))
            from = mGraveyard[tPlayer];

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_LAND_TO_GRAVE, TY_LIBRARY_TO_GRAVE, TY_FIELD_TO_GRAVE)))
            to = mGraveyard[tPlayer];
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_LIBRARY, TY_LAND_TO_LIBRARY, TY_GRAVE_TO_LIBRARY, TY_FIELD_TO_LIBRARY, TY_LIBRARY_TO_LIBRARY)))
            to = mLibrary[tPlayer];
       
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_FIELD, TY_GRAVE_TO_FIELD, TY_LIBRARY_TO_FIELD)))
        {
            to = mBattlefield[tPlayer];
            sicken = true;
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_HAND, TY_GRAVE_TO_HAND, TY_LAND_TO_HAND, TY_LIBRARY_TO_HAND)))
            to = mHand[tPlayer];
       
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_LAND, TY_LIBRARY_TO_LAND, TY_HAND_TO_LAND)))
            to = mLand[tPlayer];
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_EXILE, TY_LAND_TO_EXILE, TY_FIELD_TO_EXILE, TY_GRAVE_TO_EXILE, TY_LIBRARY_TO_EXILE)))
        {
            to = mGraveyard[tPlayer];
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
        {
            to = mLibrary[tPlayer];
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
        {
            to = mLibrary[tPlayer];
        }

        if (from == null)
        {
            if (mHand[tPlayer].isInList(tCard)) from = mHand[tPlayer];
            if (mLand[tPlayer].isInList(tCard)) from = mLand[tPlayer];
            if (mGraveyard[tPlayer].isInList(tCard)) from = mGraveyard[tPlayer];
            if (mLibrary[tPlayer].isInList(tCard)) from = mLibrary[tPlayer];
            if (mBattlefield[tPlayer].isInList(tCard)) from = mBattlefield[tPlayer];
        }


        if ((from != null) && (to != null))
        {
            if ((to == mGraveyard[tPlayer]) && (from == mBattlefield[tPlayer]))
            {
                creatureToGrave(tCard);
            }
            else
            {
                if (to.isDummy())
                {
                    if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
                    {
                        if (!hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                        {
                            to.toRealDummy(tPlayer);
                        }
                    }
                }
               
                boolean done = false;
                if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
                {
                    if (to == mLibrary[tPlayer])
                    {
                        done = true;
                        from.remove(tCard);
                        to.addCardFront(tCard);
                    }
                }
                if (!done)
                    from.moveCardTo(tCard, to);

                if (to == mGraveyard[tPlayer])
                    checkTriggerMoveToGrave(tCard);
                removeFromBlock(tCard);
                removeFromAttack(tCard);
            }
            if (sicken)
            {
                tCard.setSick(true);
            }

            // shuffle AFTER libryry top!
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
            {
                if(hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                {
                    CardSim newCard = mLibrary[tCard.owner].getCard(mLibrary[tCard.owner].size()-1);
                    int size = mLibrary[tCard.owner].size()-1;
                    mLibrary[tCard.owner] = new CardSimList();
                    for (int i=0; i< size; i++)
                    {
                        mLibrary[tCard.owner].addCard(Card.buildDummy(), tCard.owner);
                    }
                    mLibrary[tCard.owner].addCard(newCard);
                }
            }
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_CHOICE_LIBTOP_GRAVE)))
        {
//            if (target.yesNo)
//                tCard.helper = 1;
//            else
//                tCard.helper = 0;
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

                    amount =  mLand[(player+1)%2].size() - mLand[player].size();
                count = amount;
            }
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(TY_SELF_DESTRUCT)))
        {
            creatureToGrave(source);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(TY_SELF_TO_HAND)))
        {
            mBattlefield[player].moveCardTo(source, mHand[player]);
            removeFromAttack(source);
            removeFromBlock(source);
        }

        // stack cards!
        if ( (hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_STACK_CARD)))
          || (hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_STACK_ABILITY)))
          || (hints.hasAnyHint(hintKey, new HintBundle(TY_NEGATE_STACK_PLAYER_DAMAGE)))
          )
        {
            // no checking done here!
            // we negate the last card on stack
            if (mStack.size()>=2)
            {
                EAIAction removed = mStack.elementAt(mStack.size()-2);
                CardSim rCard = removed.getSCard();
                int owner = rCard.owner;

                if (removed.type == EAIAction.ACTION_PLAY_CARD)
                {
                    mHand[owner].remove(rCard);
                    mGraveyard[owner].remove(rCard);
                    mLibrary[owner].remove(rCard);
                    mGraveyard[owner].addCard(rCard);
                }

                mStack.removeElementAt(mStack.size()-2);
            }
        }



        boolean sicken = false;

        if (hints.hasHint(hintKey, HintTargetRestrictions.TR_CARD_PLAYER))
        {
            CardSimList from = null;
            CardSimList to = null;
            player = source.owner;
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_HAND_TO_LAND, TY_HAND_TO_FIELD, TY_HAND_TO_LIBRARY, TY_HAND_TO_EXILE)))
                from = mHand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LAND_TO_GRAVE, TY_LAND_TO_HAND, TY_LAND_TO_LIBRARY, TY_LAND_TO_EXILE)))
                from = mLand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TO_GRAVE, TY_LIBRARY_TO_HAND, TY_LIBRARY_TO_LAND, TY_LIBRARY_TO_FIELD, TY_LIBRARY_TO_EXILE, TY_LIBRARY_TO_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(TY_OPENS_PLAYER_LIBRARY))))
                {
                    initLibrary();
                }
                from = mLibrary[player];
            }
           
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_GRAVE, TY_FIELD_TO_HAND, TY_FIELD_TO_LIBRARY, TY_FIELD_TO_EXILE)))
                from = mBattlefield[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_HAND, TY_GRAVE_TO_FIELD, TY_GRAVE_TO_LAND, TY_GRAVE_TO_LIBRARY, TY_GRAVE_TO_EXILE)))
                from = mGraveyard[player];

            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_LAND_TO_GRAVE, TY_LIBRARY_TO_GRAVE, TY_FIELD_TO_GRAVE)))
            {
                to = mGraveyard[player];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_LIBRARY, TY_LAND_TO_LIBRARY, TY_GRAVE_TO_LIBRARY, TY_FIELD_TO_LIBRARY, TY_LIBRARY_TO_LIBRARY)))
                to = mLibrary[player];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_FIELD, TY_GRAVE_TO_FIELD, TY_LIBRARY_TO_FIELD)))
            {
                to = mBattlefield[player];
                sicken = true;
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_HAND, TY_GRAVE_TO_HAND, TY_LAND_TO_HAND, TY_LIBRARY_TO_HAND)))
                to = mHand[player];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_LAND, TY_LIBRARY_TO_LAND, TY_HAND_TO_LAND)))
                to = mLand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_EXILE, TY_LAND_TO_EXILE, TY_FIELD_TO_EXILE, TY_GRAVE_TO_EXILE, TY_LIBRARY_TO_EXILE)))
                to = mGraveyard[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
                to = mLibrary[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
                to = mLibrary[player];
           
            CardSimList fromOrg = from;
            if (from != null)
                from = fromOrg.copyList();
            if ((from != null) && (to != null))
            {

                if (hints.hasAnyHint(hintKey, new HintBundle(TR_CHOICE_LIMITATION)))
                {
                    int limit = hints.getHintValueInt(hintKey, TR_CHOICE_LIMITATION);
                    from = from.onlyTop(limit);
                }


                if (hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_SELF_NOT_ALLOWED)))
                {
                    from.remove(source);
                }
                String type_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_NEED);
                if (type_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithTypes(type_mustBeOneOf);
                }

                String subtype_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_NEED);
                if (subtype_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithSubtypes(subtype_mustBeOneOf);
                }

                String color_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_NEED);
                if (color_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithColors(color_mustBeOneOf);
                }

                String ability_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_NEED);
                if (ability_mustBeOneOf.length() != 0)
                    from = from.onlyWithAbility(ability_mustBeOneOf);

                String type_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_RESTRICTION);
                if (type_mustNotBeOneOf.length() != 0)
                    from = from.removeTypes(type_mustNotBeOneOf);

                String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_RESTRICTION);
                if (subtype_mustNotBeOneOf.length() != 0)
                    from = from.removeSubtypes(subtype_mustNotBeOneOf);

                String color_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_RESTRICTION);
                if (color_mustNotBeOneOf.length() != 0)
                    from = from.removeColors(color_mustNotBeOneOf);

                String ability_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_RESTRICTION);
                if (ability_mustNotBeOneOf.length() != 0)
                    from = from.removeWithAbility(ability_mustNotBeOneOf);

                boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_UNTAPPED_NEED));
                if (tapped_mustNotBe)
                    from = from.removeTapped();

                boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TAPPED_NEED));
                if (tapped_mustBe)
                    from = from.removeUnTapped();

                boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MIN));
                int ipowerMin = hints.getHintValueInt(hintKey, TR_CARD_POWER_MIN);
                boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MAX));
                int ipowerMax = hints.getHintValueInt(hintKey, TR_CARD_POWER_MAX);

                boolean bfromughMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MIN));
                int ifromughMin = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MIN);
                boolean bfromughMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MAX));
                int ifromughMax = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MAX);

                if (bpowerMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerHigher(ipowerMin-1);
                }
                if (bpowerMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerLower(ipowerMax+1);
                }
                if (bfromughMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessHigher(ifromughMin-1);
                }
                if (bfromughMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessLower(ifromughMax+1);
                }

                for (int i=0; i< count; i++)
                {
                    if (from.size() > 0)
                    {
                        CardSim tCard = from.getCard(from.size()-1);
                        if (from.isDummy())
                            tCard.owner = player;
                        if ((to == mGraveyard[player]) && (fromOrg == mBattlefield[player]))
                        {
                            creatureToGrave(tCard);
                        }
                        else
                        {
                            boolean done = false;
                            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
                            {
                                if (to == mLibrary[player])
                                {
                                    done = true;
                                    from.remove(tCard);
                                    fromOrg.remove(tCard);
                                    to.addCardFront(tCard);
                                }
                            }
                            if (!done)
                            {
                                if (tCard.isDummy())
                                {
                                    fromOrg.remove(tCard);
                                    to.addCard(tCard);
                                }
                                else
                                    fromOrg.moveCardTo(tCard, to);
                               from.remove(tCard);
                            }
                            if (to == mGraveyard[player])
                                checkTriggerMoveToGrave(tCard);
                            removeFromAttack(tCard);
                            removeFromBlock(tCard);
                        }
                        if (sicken)
                        {
                            tCard.setSick(true);
                        }
                    }
                }
                if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
                {
                    int p = player;
                    if(hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                    {
                        CardSim newCard = mLibrary[p].getCard(mLibrary[p].size()-1);
                        int size = mLibrary[p].size()-1;
                        mLibrary[p] = new CardSimList();
                        for (int i=0; i< size; i++)
                        {
                            mLibrary[p].addCard(Card.buildDummy(), p);
                        }
                        mLibrary[p].addCard(newCard);
                    }
                }
                else
                {
                    int p = player;
                    if(hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                    {
                        mLibrary[p].shuffle();
                    }
                }
            }
        }
        if (hints.hasHint(hintKey, HintTargetRestrictions.TR_CARD_OPPONENT))
        {
            CardSimList from = null;
            CardSimList to = null;
            int tPlayer = (source.owner+1)%2;

            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_HAND_TO_LAND, TY_HAND_TO_FIELD, TY_HAND_TO_LIBRARY, TY_HAND_TO_EXILE)))
                from = mHand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LAND_TO_GRAVE, TY_LAND_TO_HAND, TY_LAND_TO_LIBRARY, TY_LAND_TO_EXILE)))
                from = mLand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TO_GRAVE, TY_LIBRARY_TO_HAND, TY_LIBRARY_TO_LAND, TY_LIBRARY_TO_FIELD, TY_LIBRARY_TO_EXILE, TY_LIBRARY_TO_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(TY_OPENS_PLAYER_LIBRARY))))
                {
                    initLibrary();
                }
                from = mLibrary[tPlayer];
            }
           
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_GRAVE, TY_FIELD_TO_HAND, TY_FIELD_TO_LIBRARY, TY_FIELD_TO_EXILE)))
                from = mBattlefield[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_HAND, TY_GRAVE_TO_FIELD, TY_GRAVE_TO_LAND, TY_GRAVE_TO_LIBRARY, TY_GRAVE_TO_EXILE)))
                from = mGraveyard[tPlayer];

            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_GRAVE, TY_LAND_TO_GRAVE, TY_LIBRARY_TO_GRAVE, TY_FIELD_TO_GRAVE)))
                to = mGraveyard[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_LIBRARY, TY_LAND_TO_LIBRARY, TY_GRAVE_TO_LIBRARY, TY_FIELD_TO_LIBRARY, TY_LIBRARY_TO_LIBRARY)))
                to = mLibrary[tPlayer];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_FIELD, TY_GRAVE_TO_FIELD, TY_LIBRARY_TO_FIELD)))
            {
                sicken = true;
                to = mBattlefield[tPlayer];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_FIELD_TO_HAND, TY_GRAVE_TO_HAND, TY_LAND_TO_HAND, TY_LIBRARY_TO_HAND)))
                to = mHand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_GRAVE_TO_LAND, TY_LIBRARY_TO_LAND, TY_HAND_TO_LAND)))
                to = mLand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_HAND_TO_EXILE, TY_LAND_TO_EXILE, TY_FIELD_TO_EXILE, TY_GRAVE_TO_EXILE, TY_LIBRARY_TO_EXILE)))
                to = mGraveyard[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
                to = mLibrary[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
                to = mLibrary[tPlayer];
           
           
            CardSimList fromOrg = from;
            if (fromOrg != null)
                from = fromOrg.copyList();
           
            if ((from != null) && (to != null))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(TR_CHOICE_LIMITATION)))
                {
                    int limit = hints.getHintValueInt(hintKey, TR_CHOICE_LIMITATION);
                    from = from.onlyTop(limit);
                }


                if (hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_SELF_NOT_ALLOWED)))
                {
                    from.remove(source);
                }
                String type_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_NEED);
                if (type_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithTypes(type_mustBeOneOf);
                }

                String subtype_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_NEED);
                if (subtype_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithSubtypes(subtype_mustBeOneOf);
                }

                String color_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_NEED);
                if (color_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithColors(color_mustBeOneOf);
                }

                String ability_mustBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_NEED);
                if (ability_mustBeOneOf.length() != 0)
                    from = from.onlyWithAbility(ability_mustBeOneOf);

                String type_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_TYPE_RESTRICTION);
                if (type_mustNotBeOneOf.length() != 0)
                    from = from.removeTypes(type_mustNotBeOneOf);

                String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_SUBTYPE_RESTRICTION);
                if (subtype_mustNotBeOneOf.length() != 0)
                    from = from.removeSubtypes(subtype_mustNotBeOneOf);

                String color_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_COLOR_RESTRICTION);
                if (color_mustNotBeOneOf.length() != 0)
                    from = from.removeColors(color_mustNotBeOneOf);

                String ability_mustNotBeOneOf = hints.getHintValue(hintKey, TR_CARD_ABILITY_RESTRICTION);
                if (ability_mustNotBeOneOf.length() != 0)
                    from = from.removeWithAbility(ability_mustNotBeOneOf);

                boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_UNTAPPED_NEED));
                if (tapped_mustNotBe)
                    from = from.removeTapped();

                boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TAPPED_NEED));
                if (tapped_mustBe)
                    from = from.removeUnTapped();

                boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MIN));
                int ipowerMin = hints.getHintValueInt(hintKey, TR_CARD_POWER_MIN);
                boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_POWER_MAX));
                int ipowerMax = hints.getHintValueInt(hintKey, TR_CARD_POWER_MAX);

                boolean bfromughMin = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MIN));
                int ifromughMin = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MIN);
                boolean bfromughMax = hints.hasAnyHint(hintKey, new HintBundle(TR_CARD_TOUGHNESS_MAX));
                int ifromughMax = hints.getHintValueInt(hintKey, TR_CARD_TOUGHNESS_MAX);

                if (bpowerMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerHigher(ipowerMin-1);
                }
                if (bpowerMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerLower(ipowerMax+1);
                }
                if (bfromughMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessHigher(ifromughMin-1);
                }
                if (bfromughMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessLower(ifromughMax+1);
                }
               
               
               
                if(hints.hasAnyHint(hintKey, new HintBundle(TY_OPPONENT_CHOSEN)))
                {

                    // split target list in chosen and not chosen
                    CardSimList chosenList = new CardSimList();
                    CardSimList restList;// = new CardSimList();
                    int c = count;
                    // assuming source is negative effect!
                    from = from.sortListByCost();
                    while ( (c >0) && (from.size()>0) )
                    {
                        from.moveCardTo(from.getCard(0), chosenList);
                        c--;
                    }
                    from = chosenList;
                }
               
               
               
                for (int i=0; i< count; i++)
                {
                    if (from.size() > 0)
                    {
                        CardSim tCard = from.getCard(from.size()-1);
                        if (from.isDummy())
                            tCard.owner = tPlayer;
                        if ((to == mGraveyard[tPlayer]) && (fromOrg == mBattlefield[tPlayer]))
                        {
                            creatureToGrave(tCard);
                        }
                        else
                        {
                            boolean done = false;
                            if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_BOTTOM)))
                            {
                                if (to == mLibrary[tPlayer])
                                {
                                    done = true;
                                    fromOrg.remove(tCard);
                                    from.remove(tCard);
                                    to.addCardFront(tCard);
                                }
                            }
                            if (!done)
                            {
                                if (tCard.isDummy())
                                {
                                    fromOrg.remove(tCard);
                                    to.addCard(tCard);
                                }
                                else
                                    fromOrg.moveCardTo(tCard, to);
                                from.remove(tCard);
                            }
                           
                            if (to == mGraveyard[tPlayer])
                                checkTriggerMoveToGrave(tCard);
                            removeFromAttack(tCard);
                            removeFromBlock(tCard);
                        }
                        if (sicken)
                        {
                            tCard.setSick(true);
                        }
                    }
                }
                if (hints.hasAnyHint(hintKey, new HintBundle(TY_LIBRARY_TOP)))
                {
                    int p = tPlayer;
                    if(hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                    {
                        CardSim newCard = mLibrary[p].getCard(mLibrary[p].size()-1);
                        int size = mLibrary[p].size()-1;
                        mLibrary[p] = new CardSimList();
                        for (int i=0; i< size; i++)
                        {
                            mLibrary[p].addCard(Card.buildDummy(), p);
                        }
                        mLibrary[p].addCard(newCard);
                    }
                }
                else
                {
                    int p = tPlayer;
                    if(hints.hasAnyHint(hintKey, new HintBundle(HintAll.TY_LIBRARY_SHUFFLE)))
                    {
                        mLibrary[p].shuffle();
                    }
                }
               
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        {
            amount = getSourceMultiplyAmount( player,  hintKey, hints);
            count = amount;
        }

        if (hints.hasAnyHint(hintKey, new HintBundle(SY_SELF_DESTRUCT)))
        {
            creatureToGrave(source);
        }
        if (hints.hasAnyHint(hintKey, new HintBundle(SY_SELF_TO_HAND)))
        {
            mBattlefield[player].moveCardTo(source, mHand[player]);
            removeFromAttack(source);
            removeFromBlock(source);
        }

        // stack cards!
        if ( (hints.hasAnyHint(hintKey, new HintBundle(SY_NEGATE_STACK_CARD)))
          || (hints.hasAnyHint(hintKey, new HintBundle(SY_NEGATE_STACK_ABILITY)))
          || (hints.hasAnyHint(hintKey, new HintBundle(SY_NEGATE_STACK_PLAYER_DAMAGE)))
          )
        {
            // no checking done here!
            // we negate the last card on stack
            if (mStack.size()>=2)
            {
                EAIAction removed = mStack.elementAt(mStack.size()-2);
                CardSim rCard = removed.getSCard();
                int owner = rCard.owner;

                if (removed.type == EAIAction.ACTION_PLAY_CARD)
                {
                    mHand[owner].remove(rCard);
                    mGraveyard[owner].remove(rCard);
                    mLibrary[owner].remove(rCard);
                    mGraveyard[owner].addCard(rCard);
                }

                mStack.removeElementAt(mStack.size()-2);
            }
        }

        boolean sicken = false;
       
        if (hints.hasHint(hintKey, HintSourceRestrictions.SR_CARD_PLAYER))
        {
            CardSimList from = null;
            CardSimList to = null;

            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_GRAVE, SY_HAND_TO_LAND, SY_HAND_TO_FIELD, SY_HAND_TO_LIBRARY, SY_HAND_TO_EXILE)))
                from = mHand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LAND_TO_GRAVE, SY_LAND_TO_HAND, SY_LAND_TO_LIBRARY, SY_LAND_TO_EXILE)))
                from = mLand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_TO_GRAVE, SY_LIBRARY_TO_HAND, SY_LIBRARY_TO_LAND, SY_LIBRARY_TO_FIELD, SY_LIBRARY_TO_EXILE, SY_LIBRARY_TO_LIBRARY)))
            {
                if ((!libShuffled)&&(hints.hasAnyHint(hintKey, new HintBundle(SY_OPENS_PLAYER_LIBRARY))))
                {
                    initLibrary();
                }
                from = mLibrary[player];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_FIELD_TO_GRAVE, SY_FIELD_TO_HAND, SY_FIELD_TO_LIBRARY, SY_FIELD_TO_EXILE)))
                from = mBattlefield[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_GRAVE_TO_HAND, SY_GRAVE_TO_FIELD, SY_GRAVE_TO_LAND, SY_GRAVE_TO_LIBRARY, SY_GRAVE_TO_EXILE)))
                from = mGraveyard[player];

            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_GRAVE, SY_LAND_TO_GRAVE, SY_LIBRARY_TO_GRAVE, SY_FIELD_TO_GRAVE)))
            {
                to = mGraveyard[player];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_LIBRARY, SY_LAND_TO_LIBRARY, SY_GRAVE_TO_LIBRARY, SY_FIELD_TO_LIBRARY, SY_LIBRARY_TO_LIBRARY)))
                to = mLibrary[player];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_FIELD, SY_GRAVE_TO_FIELD, SY_LIBRARY_TO_FIELD)))
            {
                sicken = true;
                to = mBattlefield[player];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_FIELD_TO_HAND, SY_GRAVE_TO_HAND, SY_LAND_TO_HAND, SY_LIBRARY_TO_HAND)))
                to = mHand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_GRAVE_TO_LAND, SY_LIBRARY_TO_LAND, SY_HAND_TO_LAND)))
                to = mLand[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_EXILE, SY_LAND_TO_EXILE, SY_FIELD_TO_EXILE, SY_GRAVE_TO_EXILE, SY_LIBRARY_TO_EXILE)))
                to = mGraveyard[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_TOP)))
                to = mLibrary[player];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_BOTTOM)))
                to = mLibrary[player];
           
            CardSimList fromOrg = from;
//            can be null from org Loyal Retainers
            if (fromOrg != null)
                from = fromOrg.copyList();
           
            if ((from != null) && (to != null))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(SR_CHOICE_LIMITATION)))
                {
                    int limit = hints.getHintValueInt(hintKey, SR_CHOICE_LIMITATION);
                    from = from.onlyTop(limit);
                }


                if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_SELF_NOT_ALLOWED)))
                {
                    from.remove(source);
                }
                String type_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_NEED);
                if (type_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithTypes(type_mustBeOneOf);
                }

                String subtype_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_NEED);
                if (subtype_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithSubtypes(subtype_mustBeOneOf);
                }

                String color_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_NEED);
                if (color_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithColors(color_mustBeOneOf);
                }

                String ability_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_NEED);
                if (ability_mustBeOneOf.length() != 0)
                    from = from.onlyWithAbility(ability_mustBeOneOf);

                String type_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_RESTRICTION);
                if (type_mustNotBeOneOf.length() != 0)
                    from = from.removeTypes(type_mustNotBeOneOf);

                String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_RESTRICTION);
                if (subtype_mustNotBeOneOf.length() != 0)
                    from = from.removeSubtypes(subtype_mustNotBeOneOf);

                String color_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_RESTRICTION);
                if (color_mustNotBeOneOf.length() != 0)
                    from = from.removeColors(color_mustNotBeOneOf);

                String ability_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_RESTRICTION);
                if (ability_mustNotBeOneOf.length() != 0)
                    from = from.removeWithAbility(ability_mustNotBeOneOf);

                boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_UNTAPPED_NEED));
                if (tapped_mustNotBe)
                    from = from.removeTapped();

                boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TAPPED_NEED));
                if (tapped_mustBe)
                    from = from.removeUnTapped();

                boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MIN));
                int ipowerMin = hints.getHintValueInt(hintKey, SR_CARD_POWER_MIN);
                boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MAX));
                int ipowerMax = hints.getHintValueInt(hintKey, SR_CARD_POWER_MAX);

                boolean bfromughMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MIN));
                int ifromughMin = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MIN);
                boolean bfromughMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MAX));
                int ifromughMax = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MAX);

                if (bpowerMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerHigher(ipowerMin-1);
                }
                if (bpowerMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerLower(ipowerMax+1);
                }
                if (bfromughMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessHigher(ifromughMin-1);
                }
                if (bfromughMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessLower(ifromughMax+1);
                }
                for (int i=0; i< count; i++)
                {
                    if (from.size() > 0)
                    {
                        CardSim tCard = from.getCard(from.size()-1);
                        if (from.isDummy())
                            tCard.owner = player;
                        if ((to == mGraveyard[player]) && (fromOrg == mBattlefield[player]))
                        {
                            creatureToGrave(tCard);
                        }
                        else
                        {
                            boolean done = false;
                            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_BOTTOM)))
                            {
                                if (to == mLibrary[player])
                                {
                                    done = true;
                                    from.remove(tCard);
                                    fromOrg.remove(tCard);
                                    to.addCardFront(tCard);
                                }
                            }
                            if (!done)
                            {
                                if (tCard.isDummy())
                                {
                                    fromOrg.remove(tCard);
                                    to.addCard(tCard);
                                }
                                else
                                    fromOrg.moveCardTo(tCard, to);
                                from.remove(tCard);
                            }
                            if (to == mGraveyard[player])
                                checkTriggerMoveToGrave(tCard);
                            removeFromAttack(tCard);
                            removeFromBlock(tCard);
                        }
                        if (sicken)
                        {
                            tCard.setSick(true);
                        }
                    }
                }
            }
        }
        if (hints.hasHint(hintKey, HintSourceRestrictions.SR_CARD_OPPONENT))
        {
            CardSimList from = null;
            CardSimList to = null;
            int tPlayer = (player+1)%2;

            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_GRAVE, SY_HAND_TO_LAND, SY_HAND_TO_FIELD, SY_HAND_TO_LIBRARY, SY_HAND_TO_EXILE)))
                from = mHand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LAND_TO_GRAVE, SY_LAND_TO_HAND, SY_LAND_TO_LIBRARY, SY_LAND_TO_EXILE)))
                from = mLand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_TO_GRAVE, SY_LIBRARY_TO_HAND, SY_LIBRARY_TO_LAND, SY_LIBRARY_TO_FIELD, SY_LIBRARY_TO_EXILE, SY_LIBRARY_TO_LIBRARY)))
                from = mLibrary[tPlayer];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_FIELD_TO_GRAVE, SY_FIELD_TO_HAND, SY_FIELD_TO_LIBRARY, SY_FIELD_TO_EXILE)))
                from = mBattlefield[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_GRAVE_TO_HAND, SY_GRAVE_TO_FIELD, SY_GRAVE_TO_LAND, SY_GRAVE_TO_LIBRARY, SY_GRAVE_TO_EXILE)))
                from = mGraveyard[tPlayer];

            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_GRAVE, SY_LAND_TO_GRAVE, SY_LIBRARY_TO_GRAVE, SY_FIELD_TO_GRAVE)))
                to = mGraveyard[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_LIBRARY, SY_LAND_TO_LIBRARY, SY_GRAVE_TO_LIBRARY, SY_FIELD_TO_LIBRARY, SY_LIBRARY_TO_LIBRARY)))
                to = mLibrary[tPlayer];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_FIELD, SY_GRAVE_TO_FIELD, SY_LIBRARY_TO_FIELD)))
            {
                sicken = true;
                to = mBattlefield[tPlayer];
            }
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_FIELD_TO_HAND, SY_GRAVE_TO_HAND, SY_LAND_TO_HAND, SY_LIBRARY_TO_HAND)))
                to = mHand[tPlayer];
           
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_GRAVE_TO_LAND, SY_LIBRARY_TO_LAND, SY_HAND_TO_LAND)))
                to = mLand[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_HAND_TO_EXILE, SY_LAND_TO_EXILE, SY_FIELD_TO_EXILE, SY_GRAVE_TO_EXILE, SY_LIBRARY_TO_EXILE)))
                to = mGraveyard[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_TOP)))
                to = mLibrary[tPlayer];
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_BOTTOM)))
                to = mLibrary[tPlayer];
           
            CardSimList fromOrg = from;
            if (fromOrg != null)
                from = fromOrg.copyList();
            if ((from != null) && (to != null))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(SR_CHOICE_LIMITATION)))
                {
                    int limit = hints.getHintValueInt(hintKey, SR_CHOICE_LIMITATION);
                    from = from.onlyTop(limit);
                }


                if (hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_SELF_NOT_ALLOWED)))
                {
                    from.remove(source);
                }
                String type_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_NEED);
                if (type_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithTypes(type_mustBeOneOf);
                }

                String subtype_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_NEED);
                if (subtype_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithSubtypes(subtype_mustBeOneOf);
                }

                String color_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_NEED);
                if (color_mustBeOneOf.length() != 0)
                {
                    from = from.onlyWithColors(color_mustBeOneOf);
                }

                String ability_mustBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_NEED);
                if (ability_mustBeOneOf.length() != 0)
                    from = from.onlyWithAbility(ability_mustBeOneOf);

                String type_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_TYPE_RESTRICTION);
                if (type_mustNotBeOneOf.length() != 0)
                    from = from.removeTypes(type_mustNotBeOneOf);

                String subtype_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_SUBTYPE_RESTRICTION);
                if (subtype_mustNotBeOneOf.length() != 0)
                    from = from.removeSubtypes(subtype_mustNotBeOneOf);

                String color_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_COLOR_RESTRICTION);
                if (color_mustNotBeOneOf.length() != 0)
                    from = from.removeColors(color_mustNotBeOneOf);

                String ability_mustNotBeOneOf = hints.getHintValue(hintKey, SR_CARD_ABILITY_RESTRICTION);
                if (ability_mustNotBeOneOf.length() != 0)
                    from = from.removeWithAbility(ability_mustNotBeOneOf);

                boolean tapped_mustNotBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_UNTAPPED_NEED));
                if (tapped_mustNotBe)
                    from = from.removeTapped();

                boolean tapped_mustBe = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TAPPED_NEED));
                if (tapped_mustBe)
                    from = from.removeUnTapped();

                boolean bpowerMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MIN));
                int ipowerMin = hints.getHintValueInt(hintKey, SR_CARD_POWER_MIN);
                boolean bpowerMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_POWER_MAX));
                int ipowerMax = hints.getHintValueInt(hintKey, SR_CARD_POWER_MAX);

                boolean bfromughMin = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MIN));
                int ifromughMin = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MIN);
                boolean bfromughMax = hints.hasAnyHint(hintKey, new HintBundle(SR_CARD_TOUGHNESS_MAX));
                int ifromughMax = hints.getHintValueInt(hintKey, SR_CARD_TOUGHNESS_MAX);

                if (bpowerMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerHigher(ipowerMin-1);
                }
                if (bpowerMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyPowerLower(ipowerMax+1);
                }
                if (bfromughMin)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessHigher(ifromughMin-1);
                }
                if (bfromughMax)
                {
                    from = from.onlyWithTypes("Creature");
                    from = from.onlyToughnessLower(ifromughMax+1);
                }
                for (int i=0; i< count; i++)
                {
                    if (from.size() > 0)
                    {
                        CardSim tCard = from.getCard(from.size()-1);
                        if (from.isDummy())
                            tCard.owner = tPlayer;
                        if ((to == mGraveyard[tPlayer]) && (fromOrg == mBattlefield[tPlayer]))
                        {
                            creatureToGrave(tCard);
                        }
                        else
                        {
                            boolean done = false;
                            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIBRARY_BOTTOM)))
                            {
                                if (to == mLibrary[tPlayer])
                                {
                                    done = true;
                                    from.remove(tCard);
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);
        int amount = hints.getHintValueInt(hintKey, CS_AMOUNT_COUNT);

        if (target == null) // effect on "all"
        {
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIFE_EXCHANGE)))
            {
                int i = life[0];
                life[0] = life[1];
                life[1] = i;
            }

            else if(hints.hasAnyHint(hintKey, new HintBundle(SY_AURA)))
            {
                CardSimList effectedList = getSourceEffectedList(hintKey, source, player, hints);
                for (int i=0; i< effectedList.size(); i++)
                {
                    CardSim tCard = effectedList.getCard(i);
                    tCard = allCards.get(tCard.getCard().getUniqueID());
                    int tPlayer = tCard.owner;
//                    if (mBattlefield[0].isInList(tCard)) tPlayer = 0;
                    doSourceEffectOnOneCard(tCard, tPlayer, hintKey, hints, player, source);
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(CS_ALL_CARDS)))
            {
                CardSimList effectedList = getSourceEffectedList(hintKey, source, player, hints);

                for (int i=0; i< effectedList.size(); i++)
                {
                    CardSim tCard = effectedList.getCard(i);
                    tCard = allCards.get(tCard.getCard().getUniqueID());
                    int tPlayer = tCard.owner;
//                    if (mBattlefield[0].isInList(tCard)) tPlayer = 0;

                    doSourceEffectOnOneCard(tCard, tPlayer, hintKey, hints, player, source);
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(CS_ALL_PLAYERS)))
            {
                if (hints.hasAnyHint(hintKey, new HintBundle(S_IS_PLAYER)))
                {
                    doSourceEffectOnPlayer(player, hintKey, hints, source);
                }
                if (hints.hasAnyHint(hintKey, new HintBundle(S_IS_OPPONENT)))
                {
                    if (player == 0)
                        doSourceEffectOnPlayer(1, hintKey, hints, source);
                    else
                        doSourceEffectOnPlayer(0, hintKey, hints, source);
                }
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(S_IS_PLAYER)))
            {
                doSourceEffectOnPlayer(player, hintKey, hints, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(S_IS_OPPONENT)))
            {
                if (player == 0)
                    doSourceEffectOnPlayer(1, hintKey, hints, source);
                else
                    doSourceEffectOnPlayer(0, hintKey, hints, source);
            }
            else if(hints.hasAnyHint(hintKey, new HintBundle(SY_INHERENT)))
            {
                doSourceEffectInherent(player, hintKey, hints, source);
            }
        }
        else if((target.getSCard() == null) && (target.targetPlayerNumber >= 0))
        {
                // target is a player
            doSourceEffectOnPlayer(target.targetPlayerNumber, hintKey, hints, source);
            if (hints.hasAnyHint(hintKey, new HintBundle(SY_LIFE_EXCHANGE)))
            {
                int i = life[0];
                life[0] = life[1];
                life[1] = i;
            }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedHints.HintBundle

        }

        AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(action.getCard());
       
        // e.g.: Burning of Xinye
        if (hints.hasAllHint(HintAll.HINT_SITUATION_CARD_PLAYED, new HintBundle(CT_COUNT_EACH_PLAYER, TY_TARGETS_CHOSEN_BY_OWNER)))
        {
            // than in addition to the above handled manual targets
            // the opponent player also has to chose his targets
            // and all effects must be applied to them
            CardSimList allPossibleOpponentCards = getTargetEffectedList(HintAll.HINT_SITUATION_CARD_PLAYED, card, (player+1)%2, hints, null);
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.