Examples of AIEnhancedCardHints


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

            if (!EAIHelper.hasEnoughMana(cam.cost, possibleMana))
            {
                continue;
            }

            AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
            Vector<Vector> sources = createSources(cam, hints); // at least one empty target! or null -> must targets not available!
            if (sources == null)
            {
                continue;
            }
View Full Code Here

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

                    String uid = (String) entry2.getKey();
                    CardTrigger trigger = (CardTrigger) entry2.getValue();

                    Card sourceCard = trigger.initiatorCard;

                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(sourceCard);

                    AIEnhancedHint hint = hints.getHint(HintAll.HINT_SITUATION_CARD_PLAYED, HintAll.TY_ATTACK_DENIAL);
                    if (hint != null)
                    {
                        // False Peace
                        TimedEffect effect = new TimedEffect();

                        effect.name = hint.toString();
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = mMatch.getMyNumber(trigger.targetPlayer);
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2; // best guess
                        negateAttackPhase[effect.effectOnTargetPlayer] = true;
                        timedEffects.addElement(effect);
                    }

                    hint = hints.getHint(HintAll.HINT_SITUATION_CARD_PLAYED, HintAll.TY_UNTAP_DENIAL);
                    if (hint != null)
                    {
                        // exahustion
                        TimedEffect effect = new TimedEffect();

                        effect.name = hint.toString();
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = mMatch.getMyNumber(trigger.targetPlayer);
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2; // best guess
                        negateUntapPhase[effect.effectOnTargetPlayer] = true;
                        timedEffects.addElement(effect);
                    }
                    hint = hints.getHint(HintAll.HINT_SITUATION_CARD_PLAYED, HintAll.TY_ALL_MUST_ATTACK);
                    if (hint != null)
                    {
                        // taunt
                        TimedEffect effect = new TimedEffect();

                        effect.name = hint.toString();
                        effect.isBoolean = true;
                        effect.timeOutBoolean = false;
                        effect.effectOnTargetPlayer = mMatch.getMyNumber(trigger.targetPlayer);
                        effect.isTurnCount = true;
                        effect.turnsToLast = 2; // best guess
                        allMustAttack[effect.effectOnTargetPlayer] = true;
                        timedEffects.addElement(effect);
                    }
                    hint = hints.getHint(HintAll.HINT_SITUATION_CARD_PLAYED, HintAll.TY_ALL_BLOCK_ONE);
                    if (hint != null)
                    {
                        // Alluring Scent
                        TimedEffect effect = new TimedEffect();
View Full Code Here

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

            boolean isX = (cam.card.getCard().getManaCost() == -1);
            Vector<CardAndMana> newVariable = (Vector<CardAndMana>) variable.clone();
            Vector<CardAndMana> newFixed = (Vector<CardAndMana>) fixed.clone();

            // and (possibly) one WITH           
            AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
               
            Vector<Vector> sources = createSources(cam, hints); // at least one empty target! or null -> must targets not available!
            if (sources == null)
            {
                continue;
            }

            int sourceCount = sources.size();

            for (int s=0; s< sourceCount; s++)
            {
                Vector<EAIAction> currentSource = sources.elementAt(s);
                Vector<Vector> targets = createTargets(cam, hints, currentSource)// at least one empty target! or null -> must targets not available!

                if (targets == null)
                {
                    break;
                }

               
                int targetCount = targets.size();

                for (int t=0; t< targetCount; t++)
                {
                    Vector<EAIAction> currentTargets = targets.elementAt(t);
                    Vector<EAIAction> target = joinSourceAndTarget(currentSource, currentTargets);
                    leaf = new EAIPlanTree(this);
                    leaf.maxDamageInTodo = maxDamageInTodo;

                    boolean successfull = leaf.leafExceuteOneAction(cam, target, player, camList(fixed,variable) );
                    if (doTestTwins)
                    {
                        String key =  EnhancedAI.generateCurrentVMatchKeyID(leaf.vMatch, player) + target.toString();
                        if (isX) key += cam.card.getCard().getUniqueID()+cam.cost.getAllManaCount();
                        String hintKey = "";
                        if (cam.type == CardAndMana.CAM_ACTIVATE)
                            hintKey = HintAll.HINT_SITUATION_ACTIVATION;
                        else if(cam.type == CardAndMana.CAM_PLAY)
                                if (cam.card.isInstant()) hintKey = HintAll.HINT_SITUATION_INSTANT;
                                else hintKey = HintAll.HINT_SITUATION_CARD_PLAYED;

                        // assumes ONE source
                        // assumes depends on source is player!
                        if (hints.hasHint(hintKey, HintAll.TR_TARGET_DEPENDS_ON_SOURCE)) // card has targets, but they are not to be selected
                        {
                            if (currentSource.size() > 0)
                            {
                                if (currentSource.elementAt(0).targetIsPlayer)
                                    key+=""+currentSource.elementAt(0).targetPlayerNumber;
View Full Code Here

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

            boolean isX = (cam.card.getCard().getManaCost() == -1);
           
            Vector<CardAndMana> newToDos = (Vector<CardAndMana>) toDos.clone();
            newToDos.remove(i);
           
            AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
            if (cam.card.getCard().getUniqueID().equals("377"))
                System.out.println("Buh");
           
            if (UID == 169)
            {
View Full Code Here

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

            // evaluate Aura in Attack
            CardSimList playerAuras = getAurasOccurrence(new HintBundle(O_WHEN_ATTACKING), player);
            for (int i=0; i < playerAuras.size(); i++)
            {
                CardSim source = playerAuras.getCard(i);
                AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);
                String key = hints.getKey(O_WHEN_ATTACKING);

                CardSimList effectedList = getTargetEffectedList(key, source, player, hints, null);
                for (int e=0; e< effectedList.size(); e++)
                {
                    CardSim tCard = effectedList.getCard(e);
                    tCard = allCards.get(tCard.getCard().getUniqueID());
                    int tPlayer = tCard.owner;

                    doTargetEffectOnOneCard(tCard, tPlayer, key, hints, player, source);
                }
            }

            // evaluate Aura in Attack
            CardSimList opponentAuras = getAurasOccurrence(new HintBundle(O_WHEN_BLOCKING), opponent);
            for (int i=0; i < opponentAuras.size(); i++)
            {
                CardSim source = opponentAuras.getCard(i);
                AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);
                String key = hints.getKey(O_WHEN_BLOCKING);

                CardSimList effectedList = getTargetEffectedList(key, source, opponent, hints, null);
                for (int e=0; e< effectedList.size(); e++)
                {
                    CardSim tCard = effectedList.getCard(e);
                    tCard = allCards.get(tCard.getCard().getUniqueID());

                    int tPlayer = tCard.owner;
                    doTargetEffectOnOneCard(tCard, tPlayer, key, hints, player, source);
                }
            }

        }
        else if (phase == PHASE_MAIN2) // combat is reolved AFTRER setting the phase so we must take the next one
        {
            reverseEffect = true;
            // remove auras

            // add auras
            int player = 0;
            if (!isAttacker[0]) player = 1;
            int opponent = (player+1)%2;

            // evaluate Aura in Attack
            CardSimList playerAuras = getAurasOccurrence(new HintBundle(O_WHEN_ATTACKING), player);
            for (int i=0; i < playerAuras.size(); i++)
            {
                CardSim source = playerAuras.getCard(i);
                AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);
                String key = hints.getKey(O_WHEN_ATTACKING);

                CardSimList effectedList = getTargetEffectedList(key, source, player, hints, null);
                for (int e=0; e< effectedList.size(); e++)
                {
                    CardSim tCard = effectedList.getCard(e);
                    tCard = allCards.get(tCard.getCard().getUniqueID());
                    int tPlayer = tCard.owner;
                    doTargetEffectOnOneCard(tCard, tPlayer, key, hints, player, source);
                }
            }

            // evaluate Aura in Block
            CardSimList opponentAuras = getAurasOccurrence(new HintBundle(O_WHEN_BLOCKING), opponent);
            for (int i=0; i < opponentAuras.size(); i++)
            {
                CardSim source = opponentAuras.getCard(i);
                AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(source);
                String key = hints.getKey(O_WHEN_BLOCKING);

                CardSimList effectedList = getTargetEffectedList(key, source, opponent, hints, null);
                for (int e=0; e< effectedList.size(); e++)
                {
                    CardSim tCard = effectedList.getCard(e);
View Full Code Here

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

                // cams ready, now -> targets! (one)
                for (int i = _cam.size()-1; i >= 0; i--)
                {
                    CardAndMana cam = _cam.elementAt(i);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
                    Vector<EAIAction> sources = createOneOpponentSource(cam, hints); // at least one empty target! or null -> must targets not available!
                    if (sources == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> targets = createOneOpponentTarget(cam, hints)// at least one empty target! or null -> must targets not available!
                    if (targets == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> target = joinSourceAndTarget(sources, targets);
                    boolean successfull = leaf.leafExceuteOneAction(cam, target, opponent, camListBefor(_cam, i));
                }
            }
            else if(currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)
            {
                if (mDoStacking)
                {
                    // in stack I dont estimate opponents attackers
                    EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                    leafs.addElement(leaf);
                    return;
                }

                // opponent: activate cards that are in battlefield

                // todo build best attacking opponent can do
                // which would be the worst case scenario
                // doing an ALL OUT attack :-)
                // therefor only that option is to be tested
                // "Phew" - no explosion of choices here!

//System.out.println("Try declaring attackers of other AI!");
                // generate instant, activations

                // generate instant, activations
                // after that create all possible attackers

                // create permutations
                // possibly reuse same in different leafs (not known from here,
                // other leafs are in parent - caching and cloning?

                // now for each leaf all attack possibilities

                // dummy as long as above is not implemented
                // allways add a empty leaf
                EAIPlanTree leaf = new EAIPlanTree(this, false);

                // opponent: activate cards that are in battlefield -> like kings assassin!
                ManaCollection possibleMana = EAIHelper.getMaxAvailableMana(vMatch, opponent);
                CardSimList possibleActivateableCards = vMatch.getBattlefield(opponent);
                possibleActivateableCards = EAIHelper.onlyAllowedToActivate(possibleActivateableCards, currentPhase, true, vMatch);
                possibleActivateableCards = EAIHelper.onlyUntappedToActivate(possibleActivateableCards);

                CardSimList activated = new CardSimList();
               
                Vector<CardAndMana> _cam = new Vector<CardAndMana>();
                for(int c=0; c< possibleActivateableCards.size(); c++)
                {
                    CardSim card = possibleActivateableCards.getCard(c);
                    ManaCollection cost = ManaCollection.getActivateCost(card);
                    if (possibleMana.isCostFit(cost))
                    {
                        _cam.addElement(new CardAndMana(CardAndMana.CAM_ACTIVATE , card, cost));
                        possibleMana = possibleMana.subMana(cost);
                    }
                }

                // cams ready, now -> targets! (one)
                for (int i = _cam.size()-1; i >= 0; i--)
                {
                    CardAndMana cam = _cam.elementAt(i);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
                    Vector<EAIAction> sources = createOneOpponentSource(cam, hints); // at least one empty target! or null -> must targets not available!
                    if (sources == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> targets = createOneOpponentTarget(cam, hints)// at least one empty target! or null -> must targets not available!
                    if (targets == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> target = joinSourceAndTarget(sources, targets);
                    boolean successfull = leaf.leafExceuteOneAction(cam, target, opponent, camListBefor(_cam, i));
                    activated.addCard(cam.card);
                }

                leafs.addElement(leaf);

                int no = 0;
                for (int i = 0; i < leafs.size(); i++)
                {
                    leaf = leafs.elementAt(i);
                    CardSimList possibleAttackers = leaf.vMatch.getPossibleAttackers();
                    possibleAttackers.removeListDirect(activated);
    //public CombatFormation computeBestAttack(Weighting weighting, int attackerHealth, int blockerHealth, CardSimList notHereEvaluatedAttackers, CardSimList externalRemovedAttackers, CardSimList allBlockers)

           
                    CombatSimConfig c = new CombatSimConfig(E.aiPlayer);
                    c.attackers = possibleAttackers;
                    c.attackerLands = vMatch.getLand(opponent);
                    c.blockerLands = vMatch.getLand(player);
                    CardSimList blocker = vMatch.getBattlefield(player).getSubListByType("Creature");
                    blocker = blocker.removeActivateable();
                    //blocker = vMatch.removeAllreadyBlocking(blocker);
                    blocker = blocker.onlyTapstate(false);

                    CombatSimNew csim = new CombatSimNew(possibleAttackers, blocker, c, false);
                    int blockerHealth = vMatch.getLife(player);

                    // TEST new Attacking!
                    CombatFormation attackFormation = csim.computeBestAttack(Weighting.DEFAULT, blockerHealth);

                    for (int a=0; a< attackFormation.singleFights.size(); a++)
                    {
                        CardSim at = attackFormation.singleFights.elementAt(a).attacker;
                        EAIAction attack = EAIAction.createDeclareAttackerAction(no++, at);

                        boolean success = leaf.vMatch.executeAction(attack, opponent, false);
                        if (success)
                        {
                            leaf.addAction(currentPhaseExtended, attack);
                            String key = EnhancedAI.generateCurrentVMatchKey(leaf.vMatch, player);
                            attack.setVMatchKeyAfter(key);
                        }
                    }

                    /*
                    // old -> all out attack
                    for (int a=0; a< possibleAttackers.size(); a++)
                    {
                        CardSim at = possibleAttackers.getCard(a);
                        EAIAction attack = EAIAction.createDeclareAttackerAction(no++, at);

                        boolean success = leaf.vMatch.executeAction(attack, opponent, false);
                        if (success)
                        {
                            leaf.addAction(currentPhaseExtended, attack);
                            String key = EnhancedAI.generateCurrentVMatchKey(leaf.vMatch, player);
                            attack.setVMatchKeyAfter(key);
                        }
                    }
                    *
                    */
                }
               
                flatten();

            }
            else if (currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
            {
                // todo build best blocking for ourselfs to block oppoents attack
//System.out.println("Try declaring blockers!");


                // do nothing if there is nothing to block!
                // stupid thing wants to play giant growth on no attacket!

                // here we come for each of our own attacker definitions
                // in order to simulate the game
                // here we get a best guess - of our opponents bloking actions

                // sets all corresponding actions!

                // generate instant, activations
                // after that create all possible attackers
                futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));

                // rod of ruin
                buildLeafs(futurePrePlan);
                if (leafs.isEmpty())
                {
                    EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                    leafs.addElement(leaf);
                }
                flattenNoScore();
                // create permutations
                // possibly reuse same in different leafs (not known from here,
                // other leafs are in parent - caching and cloning?

                // now for each leaf all attack possibilities

                // Todo: for now opponent strategy!
                int opponentBlockStrategy = E.aiPlayer.getEAIConfig().getOpponentBlockStrategy();
                if (E.aiPlayer.getEAIConfig().getOpponentAdaptiveBlocking())
                {
                    int life = vMatch.getLife(player);
                    int maxDamage = EAIHelper.getPowerSum(vMatch.getAttacker());

                    if (life <= maxDamage+E.aiPlayer.getEAIConfig().getSavetyHealthThreshold())
                        opponentBlockStrategy = BLOCK_PLAYER_LEAST_DAMAGE;
                    else
                        opponentBlockStrategy = BLOCK_PLAYER_LEAST_CREATURE_DEAD;
                }
                generatePlayerBlockerActions(opponentBlockStrategy); // for now!
            }
            else if (currentPhase == MatchConstants.PHASE_COMBAT_END)
            {
                if (UID == 7325)
                    System.out.println("Buh!");
                vMatch.doCombat((player+1)%2);
            }

            if (leafs.isEmpty())
            {
                EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                leafs.addElement(leaf);
            }
            return;
        }
        if (currentPhase == MatchConstants.PHASE_BEGINNING_UNTAP)
        {
            CACHEHIT = false;
            int actionCounter = 0;
            Vector<CardAndMana> willBeActions = new Vector<CardAndMana>();
            Vector<CardAndMana> futurePlanWithoutActions = new Vector<CardAndMana>();

            CardSimList lands = vMatch.getLand(E.pNumber);
            CardSimList creatures = vMatch.getBattlefield(E.pNumber);
            Vector ls = lands.getCards();
            for (int i = 0; i < ls.size(); i++)
            {
                CardSim card = (CardSim) ls.elementAt(i);
                if (card.isTapped())
                {
                    CardAndMana untapLand = new CardAndMana(CardAndMana.CAM_UNTAP,card, null);
                    willBeActions.add(untapLand);
                }
            }
            Vector cs = creatures.getCards();
            for (int i = 0; i < cs.size(); i++)
            {
                CardSim card = (CardSim) cs.elementAt(i);
                if (card.isTapped())
                {
                    CardAndMana untapCreature = new CardAndMana(CardAndMana.CAM_UNTAP,card, null);
                    willBeActions.add(untapCreature);
                }
            }

            if (willBeActions.isEmpty())
            {
                // will allways be empty if nextRound() by match was played
                // sincew vmatch resets all tapped items on newRound()!
                EAIPlanTree leaf = new EAIPlanTree(this, false);
                leafs.addElement(leaf);
                return;
            }

            EAIPlanTree leaf = new EAIPlanTree(this);
            leaf.futurePrePlan = futurePlanWithoutActions;
            while (!willBeActions.isEmpty())
            {
                CardAndMana cam = willBeActions.elementAt(0);
                willBeActions.removeElement(cam);
                boolean reEvaluate = leaf.leafExceuteOneAction(cam, new Vector<EAIAction>(), player, null); // no targets (as of yet) for untapping
            }
            leaf.playerScore = Weighting.DEFAULT.buildScore(leaf.getMatch(), player, false);
            leaf.opponentScore = Weighting.DEFAULT.buildScore(leaf.getMatch(), (player+1)%2, false);
            leaf.difScore = leaf.playerScore-leaf.opponentScore;
            leafs.addElement(leaf);
        }
        if (currentPhase == MatchConstants.PHASE_BEGINNING_DRAW)
        {
            EAIPlanTree leaf = new EAIPlanTree(this);
            leaf.vMatch.drawLibCardToHand(player);
            leafs.addElement(leaf);
        }
        else if(currentPhase == MatchConstants.PHASE_MAIN1)
        {
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
            // in future plan all possible playing cards / actions are ilsted
            // permutation of these are done in build leafs...

            buildLeafs(futurePrePlan);
        }
        else if(currentPhase == MatchConstants.PHASE_MAIN2)
        {
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
            buildLeafs(futurePrePlan);
        }
        else if (currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)
        {
            // generate instant, activations
            // after that create all possible attackers
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
           
// 10572          
            buildLeafs(futurePrePlan);
            if (leafs.isEmpty())
            {
                EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                leafs.addElement(leaf);
            }
            flatten();
            // create permutations
            // possibly reuse same in different leafs (not known from here,
            // other leafs are in parent - caching and cloning?

            // now for each leaf all attack possibilities
            for (int i = 0; i < leafs.size(); i++)
            {
                EAIPlanTree leaf = leafs.elementAt(i);
                // attackers in respect to allready activated cards -> therefor in respect to leaf!
                CardSimList possibleAttackers = new CardSimList();
                CardSimList removedPossibleAttackers = new CardSimList();

                // removed possible attackers are interesting for blocking a re attack! (Evaluation)
                leaf.generatePossibleAttackers(E.pNumber, possibleAttackers, removedPossibleAttackers);

                // NOTICE:
                // general Attacking Hints (SELF - ONLY!) are applied in
                // SingleFight:  applyAttackingHints(CardSim at)
                // targetting attacking hints are applied here!

                /*
                 * look for attackers which inherently do something upon attack
                  e.g. Seasoned marshal.
                  Than build leaves for attack / no attack

                 */
                CardSimList tryAttackerList = new CardSimList();
                for (int t=possibleAttackers.size()-1; t>=0; t--)
                {
                    CardSim card = possibleAttackers.getCard(t);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(card);
                    if (hints == null) continue;
                    if (hints.hasKey(HintAll.HINT_SITUATION_ATTACKER))
                    {
                        if (EAIHelper.isRemoveHand(card, HintAll.HINT_SITUATION_ATTACKER))
                            continue;
                       
                        if (!hints.hasHint(HintAll.HINT_SITUATION_ATTACKER, HintAll.PA_NO_EXTERNAL_INFLUENCE))
                        {
                            tryAttackerList.addCard(card);
                            possibleAttackers.remove(card);
                        }
                    }
View Full Code Here

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

                    CardSim c = targets.getCard(ii);
                    CardSim effectedCard = allCards.get( c.getCard().toUString());
                    // assuming all effects are target effects!
                    if (effectedCard != null)
                    {
                        AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(card);
                        if (hints.hasHintType(HintAll.HINT_SITUATION_CARD_PLAYED, HINT_TYPE_TIME))       
                            effectedCard.addEffectTarget(card, HintAll.HINT_SITUATION_CARD_PLAYED); // all enchantments are of hint type played!
                    }
                }
               
            }
View Full Code Here

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

                    // not included in "allCards"
                    // but this also means, that this card
                    // is "dead" so we dont have to do anything and can just go on
                    if (effectCard == null) continue;
                   
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(effectCard);
                   
                    if (hints.hasHint(TI_SOURCE_DEATH))
                    {
                        if (mBattlefield[p].isInList(effectCard))
                        {
                            if (oneEffect.isSource)
                            {
                                doSourceEffectOnOneCard(card, card.getOwner(), oneEffect.key, hints, effectCard.getOwner(), effectCard);
                            }
                            else
                            {
                                doTargetEffectOnOneCard(card, card.getOwner(), oneEffect.key, hints, effectCard.getOwner(), effectCard);
                            }
                        }
                    }
                }
            }
        }
        //half reset "opponent" battlefield
        mBattlefield[(newActivePlayer+1)%2].newRound(false);
        // apply auras etc
        for (int i = 0; i < mBattlefield[(newActivePlayer+1)%2].size(); i++)
        {
            int p = (newActivePlayer+1)%2;
            CardSim card = mBattlefield[p].getCard(i);
           
            Vector<OneEffect> effects = card.getEffects();
            if (effects != null)
            {
                card.clearEffects();
                for (int j = 0; j < effects.size(); j++)
                {
                    OneEffect oneEffect = effects.elementAt(j);
                    CardSim effectCard = oneEffect.effectCard;
                    effectCard = allCards.get(effectCard.getCard().getUniqueID());

                    // null might happen, if
                    // effect card is moved to library top
                    // library is on short copy / library dummy
                    // not included in "allCards"
                    // but this also means, that this card
                    // is "dead" so we dont have to do anything and can just go on
                    if (effectCard == null) continue;
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(effectCard);
                   
                    if (hints.hasHint(TI_SOURCE_DEATH))
                    {
                        if (mBattlefield[p].isInList(effectCard))
                        {
                            if (oneEffect.isSource)
                                doSourceEffectOnOneCard(card, card.getOwner(), oneEffect.key, AIEnhancedCardHints.getHints(effectCard), effectCard.getOwner(), effectCard);
View Full Code Here

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

        // here ALL possible card hint effects should be taken account off *shudder*

        // 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.AIEnhancedCardHints

        // here ALL possible card hint effects should be taken account off *shudder*

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

        if (hintKey.equals(HintAll.HINT_SITUATION_CARD_PLAYED))
            if (source.isInstant())
                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
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.