Package csa.jportal.config

Examples of csa.jportal.config.Logable


     * @param lands
     * @return true if the landlist provides enough mana for the land to be played
     */
    public static boolean hasEnoughMana(Card card, ManaCollection mana)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        Logable L = Configuration.getConfiguration().getLogEntity();
        boolean ret = true;
        int debugLevel=4;

        D.addLog("EAI: I have mana: "+mana+" ", debugLevel);

View Full Code Here


        return ret;
    }
   
    public static boolean hasEnoughMana(ManaCollection cost, ManaCollection mana)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        Logable L = Configuration.getConfiguration().getLogEntity();
        boolean ret = true;
        int debugLevel=4;

        D.addLog("EAI: I have mana: "+mana+" ", debugLevel);
View Full Code Here

        return hasEnoughManaActivate(card.getCard(), mana);

    }
    public static boolean hasEnoughManaActivate(Card card, ManaCollection mana)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        Logable L = Configuration.getConfiguration().getLogEntity();
        boolean ret = true;
        int debugLevel=4;

        D.addLog("EAI: I have mana: "+mana+" ", debugLevel);
View Full Code Here

        return hasEnoughManaInText(card.getCard(), mana);

    }
    public static boolean hasEnoughManaInText(Card card, ManaCollection mana)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        Logable L = Configuration.getConfiguration().getLogEntity();
        boolean ret = true;
        int debugLevel=4;

        D.addLog("EAI: I have mana: "+mana+" ", debugLevel);
View Full Code Here

    {
        return AIHelper.hasEnoughManaGeneral(card, lands);
    }
    public static boolean hasEnoughManaGeneral(CardSim card, CardSimList lands)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        Logable L = Configuration.getConfiguration().getLogEntity();
        boolean ret = true;
        int debugLevel=4;

        D.addLog("EAI: I have "+lands.size()+" lands.", debugLevel);
View Full Code Here

            int playerNo,
            VirtualMatch vmatch,
            CardSim initiator
            )
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        int debugLevel = 4;
        int opponentNo = (playerNo+1)%2;

        D.addLog("EAI:selectGoodCard() list: "+list ,debugLevel);
        CardSim result = null;
        if (list.size() == 0) return null;
        Scoring scorting = new Scoring();

        CardSimList creatures;
        CardSimList creaturesO;
        CardSimList lands;
        CardSimList landsO;
        CardSimList hand;
        CardSimList orgList = list.copyList();

        creaturesO = vmatch.getBattlefield(opponentNo).getSubListByType("Creature");
        landsO = vmatch.getLand(opponentNo);
        creatures = vmatch.getBattlefield(playerNo).getSubListByType("Creature");
        lands = vmatch.getLand(playerNo).copyList();
        hand = vmatch.getHand(playerNo);
        lands.addList(hand.getSubListByType("Land"));

        int creatureAdd=0;
        int spellAdd=0;

        int landScore = 10 - (lands.size()-1+hand.getSubListByType("Land").size())*2;
        scorting.addScore(landScore, Scoring.LAND);
        D.addLog("Scoring LAND: "+landScore,debugLevel);

        int healthScore = spellAdd+(20 - vmatch.getLife(playerNo))/2;
        scorting.addScore(healthScore, Scoring.HEALTH);
        D.addLog("Scoring HEALTH: "+healthScore,debugLevel);

        int opponentDamageScore = spellAdd+5-(vmatch.getLife(opponentNo)-5);
        scorting.addScore(opponentDamageScore, Scoring.DAMAGE);
        D.addLog("Scoring DAMAGE: "+opponentDamageScore,debugLevel);

        int creatureScore = creatureAdd+(creaturesO.size()-creatures.size())*2;
        scorting.addScore(creatureScore, Scoring.CREATURE);
        D.addLog("Scoring CREATURE: "+creatureScore,debugLevel);

        int creatureDamageScore = spellAdd+(creatureScore+2)/2;
        scorting.addScore(creatureDamageScore, Scoring.CREATURE_DAMAGE);
        D.addLog("Scoring CREATURE_DAMAGE: "+creatureDamageScore,debugLevel);

        int landDestroyScore = (5-landsO.size())+ spellAdd;
        scorting.addScore(landDestroyScore, Scoring.LAND_DESTROY);
        D.addLog("Scoring LAND_DESTROY: "+landDestroyScore,debugLevel);

        int handScore = spellAdd+10-(hand.size()*3);
        scorting.addScore(handScore, Scoring.HAND);
        D.addLog("Scoring HAND: "+handScore,debugLevel);

        boolean nothingDone = false;
        int NOTHING_SCORE = -99;
        int lastScoreValue = -100;
        while (result == null)
        {
            lastScoreValue = scorting.getHighScoreValue();

            int switcher = scorting.getHighScoreType();
            if ((!nothingDone) && (lastScoreValue<NOTHING_SCORE))
            {
                switcher = 22882; // a default :-)
            }
            if ((switcher == Scoring.NOTHING ) && (nothingDone))
            {
                break;
            }
            switch (switcher)
            {
                case Scoring.LAND_DESTROY:
                {
                    D.addLog("Taken LAND_DESTROY",debugLevel);
                    scorting.removeType(Scoring.LAND_DESTROY);

                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (aHints.hasHint(HintTargetTypes.TY_LAND_TO_GRAVE))
                        {
                            if (!(aHints.hasHint(HintTargetCount.CT_ALL_CARDS)))
                            {
                                result = card;
                                D.addLog("Found: "+result,debugLevel);
                            }
                        }
                    }
                    break;
                }

                case Scoring.LAND:
                {
                    D.addLog("Taken LAND",debugLevel);
                    scorting.removeType(Scoring.LAND);
                    CardSimList l = list.getSubListByType("Land");
                    if (l.size()>0)
                    {
                        result = l.getCard(0);
                        break;
                    }

                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (aHints.hasHint(HintTargetTypes.TY_LIBRARY_TO_HAND))
                        if ((aHints.getHintValue(HintTargetRestrictions.TR_CARD_TYPE_NEED).toUpperCase().indexOf("Land") != -1)
                            ||
                            (aHints.getHintValue(HintTargetRestrictions.TR_CARD_TYPE_RESTRICTION).toUpperCase().indexOf("Land") == -1))
                        {
                            result = card;
                            D.addLog("Found: "+result,debugLevel);
                            break;
                        }

                    }
                    if (result == null)
                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (aHints.hasHint(HintTargetTypes.TY_LIBRARY_TO_LAND))
                        {
                            result = card;
                            D.addLog("Found: "+result,debugLevel);
                            break;
                        }
                    }
                    break;
                }
                case Scoring.HEALTH:
                {
                    D.addLog("Taken HEALTH",debugLevel);
                    scorting.removeType(Scoring.HEALTH);

                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (aHints.hasHint(HintTargetTypes.TY_HEAL))
                        {
                            result = card;
                            D.addLog("Found: "+result,debugLevel);
                            break;
                        }

                    }
                    break;
                }
                case Scoring.DAMAGE:
                {
                    D.addLog("Taken DAMAGE",debugLevel);
                    scorting.removeType(Scoring.DAMAGE);
                    String[] h={"EFFECT_ONE_PLAYER_DAMAGE"};
                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if ((aHints.hasHint(HintTargetTypes.TY_DAMAGE))
                            || (aHints.hasHint(HintSourceTypes.SY_DAMAGE)))
                        {
                            if ((aHints.hasHint(HintTargetRestrictions.TR_CARD_OPPONENT))
                                || (aHints.hasHint(HintSourceRestrictions.SR_CARD_OPPONENT)))
                            {
                                if (!(card.isCreature()))
                                    result = card;
                            }
                        }
                    }
                    break;
                }
                case Scoring.CREATURE:
                {
                    D.addLog("Taken CREATURE",debugLevel);
                    scorting.removeType(Scoring.CREATURE);
                    CardSimList l = list.getSubListByType("Creature");

                    boolean testMana=true;
                    if (initiator!=null)
                    {
                        AIEnhancedCardHints iHints = AIEnhancedCardHints.getHints(initiator);

                        if (iHints.hasHint(HintTargetTypes.TY_LIBRARY_TO_FIELD))
                        {
                            testMana=false;
                        }
                        if (iHints.hasHint(HintTargetTypes.TY_HAND_TO_FIELD))
                        {
                            testMana=false;
                        }
                    }
                    if (testMana)
                        l = onlyEnoughManaGeneral(l, lands);

                    l = l.sortListByManaCost();
                    if (l.size()>0)
                    {
                        result = l.getCard(l.size()-1);
                    }
                    break;
                }
                case Scoring.CREATURE_DAMAGE:
                {
                    D.addLog("Taken CREATURE_DAMAGE",debugLevel);
                    scorting.removeType(Scoring.CREATURE_DAMAGE);

                    // NOT checked if one of the sorcueries does damage to the player!
                    // (e.g. "Rain of Daggers")
                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (   ((aHints.hasHint(HintTargetTypes.TY_FIELD_TO_GRAVE)) && (aHints.hasHint(HintTargetRestrictions.TR_CARD_OPPONENT)))
                            || ((aHints.hasHint(HintSourceTypes.SY_FIELD_TO_GRAVE)) && (aHints.hasHint(HintSourceRestrictions.SR_CARD_OPPONENT)))
                             )
                        {
                            {
                                result = card;
                                break;
                            }
                        }
                    }


                    if (result == null)
                    {
                        for (int i=0; i< list.size(); i++)
                        {
                            CardSim card = list.getCard(i);
                            AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                            if (   ((aHints.hasHint(HintTargetTypes.TY_FIELD_TO_HAND)) && (aHints.hasHint(HintTargetRestrictions.TR_CARD_OPPONENT)))
                                || ((aHints.hasHint(HintSourceTypes.SY_FIELD_TO_HAND)) && (aHints.hasHint(HintSourceRestrictions.SR_CARD_OPPONENT)))
                                || ((aHints.hasHint(HintTargetTypes.TY_LIBRARY_TOP)) && (aHints.hasHint(HintTargetRestrictions.TR_CARD_OPPONENT)))
                                )
                                {
                                    result = card;
                                    break;
                                }
                        }
                    }
                    if (result == null)
                    {
                        for (int i=0; i< list.size(); i++)
                        {
                            CardSim card = list.getCard(i);
                            AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                            if (   ((aHints.hasHint(HintTargetTypes.TY_DAMAGE)) && (aHints.hasHint(HintTargetRestrictions.TR_CARD_OPPONENT)))
                                || ((aHints.hasHint(HintSourceTypes.SY_DAMAGE)) && (aHints.hasHint(HintSourceRestrictions.SR_CARD_OPPONENT)))
                                )
                                {
                                    result = card;
                                    break;
                                }
                        }
                    }
                    break;
                }

                case Scoring.HAND:
                {
                    D.addLog("Taken HAND",debugLevel);
                    scorting.removeType(Scoring.HAND);

                    String[] h={"EFFECT_WHEN_DRAW_CARD"};
                    for (int i=0; i< list.size(); i++)
                    {
                        CardSim card = list.getCard(i);
                        AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(card);
                        if (   ((aHints.hasHint(HintTargetTypes.TY_LIBRARY_TO_HAND)) && (aHints.hasHint(HintTargetRestrictions.TR_CARD_PLAYER)))
                            || ((aHints.hasHint(HintSourceTypes.SY_LIBRARY_TO_HAND)) && (aHints.hasHint(HintSourceRestrictions.SR_CARD_PLAYER)))
                            )
                            {
                                result = card;
                                break;
                            }
                    }
                    break;
                }
                default: // NOTHING
                {
                    D.addLog("Taken NOTHING",debugLevel);
                    nothingDone = true;
                    CardSimList nothingList = onlyEnoughManaGeneral(list, lands);
/*

                    // not HAND
View Full Code Here

        // looking for "MASTER" works for me - dont know if that control is allways labeld master....

        // this pretty hard coded. should probable be better made
        public static void setAllVolumneLinux(int vol)
        {
            Logable D = Configuration.getConfiguration().getDebugEntity();
            boolean volumeSet = false;
            List<Mixer> portMixers = getPortMixers();
            if (portMixers.size() == 0)
            {
                D.addLog("There are no mixers that support Port lines. Sound volume can not be set!",0);
            }
            Iterator<Mixer> iterator = portMixers.iterator();
            while (iterator.hasNext())
            {
                Mixer mixer = iterator.next();
                String strMixerName = mixer.getMixerInfo().getName();
//System.out.println("Mixer: " + strMixerName);
    Port.Info[] infosToCheck = getPortInfo(mixer);
    for (int i = 0; i < infosToCheck.length; i++)
    {
                    Port port = null;
                    try
                    {
                            port = (Port) mixer.getLine(infosToCheck[i]);
                            port.open();
                    }
                    catch (LineUnavailableException e)
                    {
                         //   e.printStackTrace();
                    }
                    if (port != null)
                    {
                        String  strPortName = ((Port.Info) port.getLineInfo()).getName();
//System.out.println("Port: " + strPortName);
                        if (strPortName.toUpperCase().indexOf("MASTER") ==-1 ) continue;
                        Control[]  aControls = port.getControls();
                        for (int t = 0; t < aControls.length; t++)
                        {
                            if (aControls[t] instanceof FloatControl)
                            {
                                FloatControl control = (FloatControl) aControls[t];
                                Control.Type type = control.getType();
                                String strControlName = type.toString();
                                if (!isVolumne(control)) continue;
//System.out.println("Control direct: " +  strControlName);
//
                                FloatControl volumeControl = (FloatControl) control;
                                float min = volumeControl.getMinimum();
                                float max = volumeControl.getMaximum();
                                float current = volumeControl.getValue();
                                double percent = 100.0 * (current - min) / (max - min);
                                // System.out.println("Current Volume is " + percent + "%.");
                                volumeSet = true;
    // setting to 50%
                                float v = (max - min) / 2.0f + min;
                                v = (((max - min)/100)*vol) +min;
                                volumeControl.setValue(v);
                            }
                            if (aControls[t] instanceof CompoundControl)
                            {
                                CompoundControl control = (CompoundControl) aControls[t];

                                String strControlName = control.getType().toString();
//System.out.println("Control compound: " +  strControlName);
                                Control[] subControls = control.getMemberControls();
                                for (int s = 0; s < subControls.length; s++)
                                {
                                    Control con = subControls[s];
                                    if (con instanceof FloatControl)
                                    {
                                        FloatControl subCon = (FloatControl)con;
                                        String strControlSubName = subCon.getType().toString();
                                        if (!isVolumne(subCon)) continue;
//System.out.println("Control sub: " +  strControlSubName);
//



                                        FloatControl volumeControl = (FloatControl) subCon;
                                        float min = volumeControl.getMinimum();
                                        float max = volumeControl.getMaximum();
                                        float current = volumeControl.getValue();
                                        double percent = 100.0 * (current - min) / (max - min);
                                        // System.out.println("Current Volume is " + percent + "%.");
            // setting to 50%
                                        float v = (max - min) / 2.0f + min;
                                        v = (((max - min)/100)*vol) +min;
                                        volumeControl.setValue(v);

                                        volumeSet = true;
                                    }
                                }

                            }
                        }
                    }
    }
            }
            if (!volumeSet)
            {
                D.addLog("Volume was not set, please contact auhtor, this should be easy to fix, once known what to look for!", 0);
            }
        }
View Full Code Here

  }


        public static void setAllVolumneMac(int vol)
        {
            Logable D = Configuration.getConfiguration().getDebugEntity();
            boolean volumeSet = false;

    Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
    for (Mixer.Info mixerInfo:mixerInfos)
                {
View Full Code Here

    boolean bActivated = false;

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton3ActionPerformed
    {//GEN-HEADEREND:event_jButton3ActionPerformed

        Logable D = Configuration.getConfiguration().getDebugEntity();
        D.addLog("Enter jButton3ActionPerformed", 3);
try{
        if (bActivated) return;
        bActivated = true;
        BoosterScheduler c = new BoosterScheduler();
        BoosterPlayer hp = new BoosterPlayer();
        boolean auto = mAutoAI;
        if (mPlayer != null)
        {
            hp.name = mPlayer.getName();
            hp.type = MatchPlayable.TYPE_HUMAN;
            hp.no = 0;
            hp.hplayer = mPlayer;
            hp.panel = null;
            hp.mDeckBase = mBoosterBaseName;
            mPlayers.add(0, hp);
            auto = false;

        }
        c.setAutoBattle(auto);
        c.setPlayer(mPlayers, mBoosterBaseName, mWinsNeeded);

        mParent.addPanel(c);
        mParent.setMainPanel(c);
        mParent.removePanel(this);
        mParent.hideMyWindow(this);
        D.addLog("Exit jButton3ActionPerformed", 3);
        if (mAutoAI) c.go();
}catch(Throwable e){D.addLog(e, 3);}
    }//GEN-LAST:event_jButton3ActionPerformed
View Full Code Here

    Vector<PairedBattleInfo> mBattles = null;
    BoosterPlayer winner =null;
    public void checkNextRound()
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        D.addLog("Entering: checkNextRound(), currentRound: " + mCurrentRound, 3);
        if (mCurrentRound>3)
        {
            for (int i = 0; i < mBattles.size(); i++)
            {
                PairedBattleInfo pi = mBattles.elementAt(i);
                BoosterPlayer pl = pi.getWinner();
                winner = pl;
            }
            setWin();
            return;
        }
        if (mCurrentRound == 0) mBattles = mBattles1;
        if (mCurrentRound == 1) mBattles = mBattles2;
        if (mCurrentRound == 2) mBattles = mBattles3;
        if (mCurrentRound == 3) mBattles = mBattles4;

        for (int i = 0; i < mBattles.size(); i++)
        {
            final PairedBattleInfo pi = mBattles.elementAt(i);
            if (!pi.mBattlesDone)
            {
                if (!mAutoBattle) return;
                else
                {
                    Runnable caller = new Runnable()
                    {
                        public void run()
                        {
                            pi.doBattle();
                        }
                    };
                    java.awt.EventQueue.invokeLater(caller);
                    return;
                }
            }
        }

        mActivePlayers = new Vector<BoosterPlayer>();
        if (leftOver != null)
        {
            leftOver.wins=0;
            mActivePlayers.addElement(leftOver);
        }

        for (int i = 0; i < mBattles.size(); i++)
        {
            PairedBattleInfo pi = mBattles.elementAt(i);
            BoosterPlayer pl = pi.getWinner();
            pl.wins=0;
            mActivePlayers.addElement(pl);
            winner = pl;
        }

        //if (mCurrentRound >0)
        {
            D.addLog("Checking player victories", 3);
            for (int i = 0; i < mActivePlayers.size(); i++)
            {
                BoosterPlayer boosterPlayer = mActivePlayers.elementAt(i);
                if (boosterPlayer.hplayer != null)
                {
                    D.addLog("Adding 5 dollars to player: " + boosterPlayer.hplayer, 3);
                    // for each round > 0 5$!
                    boosterPlayer.hplayer.addDollar(5);
                    boosterPlayer.hplayer.save();
                }
            }
View Full Code Here

TOP

Related Classes of csa.jportal.config.Logable

Copyright © 2018 www.massapicom. 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.