Package csa.jportal.card

Examples of csa.jportal.card.CardList


        deck.addList(heap.drawRandom(1));
    }
   
    public CardList genDeck()
    {
        CardList heap = buildHeapList();       
       
        // generate deck from heap
        CardList deck = new CardList();
        if (heap.onlyWithTypes("Land").size() == 0) return deck;
       
       
        double deckSize = csa.util.UtilityString.IntX(jTextFieldDecksize.getText(), 65);
        double landPercent = csa.util.UtilityString.IntX(jTextFieldLand.getText(), 22);
        maxSame = csa.util.UtilityString.IntX(jTextField4.getText(), 3);
       
        double noLandsPercent = 100 - landPercent;
        double cardPerPercent = deckSize/100;
        int cardLands = (int) (landPercent*cardPerPercent);
        int cardNoLands = (int) (noLandsPercent*cardPerPercent);

        boolean toggle = true;
        while (cardLands+cardNoLands <deckSize)
        {
            if (toggle)
                cardLands++;
            else
                cardNoLands++;
            toggle = !toggle;
        }
       
        int cardNowLands = 0;
       
       
        while (cardNowLands<cardLands)
        {
            if (hasBlack) addLand(heap, deck, "B");cardNowLands = deck.size();if (cardNowLands>=cardLands) break;
            if (hasWhite) addLand(heap, deck, "W");cardNowLands = deck.size();if (cardNowLands>=cardLands) break;
            if (hasGreen) addLand(heap, deck, "G");cardNowLands = deck.size();if (cardNowLands>=cardLands) break;
            if (hasRed) addLand(heap, deck, "R");cardNowLands = deck.size();if (cardNowLands>=cardLands) break;
            if (hasBlue) addLand(heap, deck, "U");cardNowLands = deck.size();if (cardNowLands>=cardLands) break;
        }

        heap = heap.removeTypes("Land")

       
        initBaseValues();

        double allStrength = 0;
        allStrength += healValue;
        allStrength += creatureValue;
        allStrength += playerDamageValue;
        allStrength += creatureDamageValue;
        allStrength += landDestroyValue;
        allStrength += antiMagicValue;
        allStrength += cardMagicValue;
        allStrength += buffyValue;
        allStrength += trickyValue;
        if (allStrength == 0) return new CardList();

        healPercent = healValue / allStrength;
        creaturePercent = creatureValue / allStrength;
        playerDamagePercent = playerDamageValue / allStrength;
        creatureDamagePercent = creatureDamageValue / allStrength;
        landDestroyPercent = landDestroyValue / allStrength;
        antiMagicPercent = antiMagicValue / allStrength;
        cardMagicPercent = cardMagicValue / allStrength;
        buffyPercent = buffyValue / allStrength;
        trickyPercent = trickyValue / allStrength;
       
        double cardPercent = ((double)cardNoLands);///100.0;
        healCards = (int) (cardPercent*healPercent);
        creatureCards = (int) (cardPercent*creaturePercent);
        playerDamageCards = (int) (cardPercent*playerDamagePercent);
        creatureDamageCards = (int) (cardPercent*creatureDamagePercent);
        landDestroyCards = (int) (cardPercent*landDestroyPercent);
        antiMagicCards = (int) (cardPercent*antiMagicPercent);
        cardMagicCards = (int) (cardPercent*cardMagicPercent);
        buffyCards = (int) (cardPercent*buffyPercent);
        trickyCards = (int) (cardPercent*trickyPercent);
       
        int allCounted = healCards+creatureCards+playerDamageCards+creatureDamageCards+landDestroyCards+antiMagicCards+cardMagicCards+buffyCards+trickyCards;
        while (allCounted<cardNoLands)
        {
            if(creaturePercent>0) {creatureCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(healPercent>0) {healCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(playerDamagePercent>0) {playerDamageCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(creatureDamagePercent>0) {creatureDamageCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(landDestroyPercent>0) {landDestroyCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(antiMagicPercent>0) {antiMagicCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cardMagicPercent>0) {cardMagicCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(buffyPercent>0) {buffyCards++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(trickyPercent>0) {trickyCards++;allCounted++;} if (allCounted>=cardNoLands) break;
        }
       
        double allCostStrength = 0;
        allCostStrength += cost1Value;
        allCostStrength += cost2Value;
        allCostStrength += cost3Value;
        allCostStrength += cost4Value;
        allCostStrength += cost5Value;
        allCostStrength += cost6Value;
        allCostStrength += cost7Value;
        allCostStrength += cost8Value;
        allCostStrength += cost9Value;
        allCostStrength += cost10Value;
        if (allCostStrength == 0) return new CardList();
               
        double cost1Percent = cost1Value / allCostStrength;
        double cost2Percent = cost2Value / allCostStrength;
        double cost3Percent = cost3Value / allCostStrength;
        double cost4Percent = cost4Value / allCostStrength;
        double cost5Percent = cost5Value / allCostStrength;
        double cost6Percent = cost6Value / allCostStrength;
        double cost7Percent = cost7Value / allCostStrength;
        double cost8Percent = cost8Value / allCostStrength;
        double cost9Percent = cost9Value / allCostStrength;
        double cost10Percent = cost10Value / allCostStrength;
       
        double costPercent = ((double)cardNoLands);///100.0;
        int cost1 = (int) (costPercent*cost1Percent);
        int cost2 = (int) (costPercent*cost2Percent);
        int cost3 = (int) (costPercent*cost3Percent);
        int cost4 = (int) (costPercent*cost4Percent);
        int cost5 = (int) (costPercent*cost5Percent);
        int cost6 = (int) (costPercent*cost6Percent);
        int cost7 = (int) (costPercent*cost7Percent);
        int cost8 = (int) (costPercent*cost8Percent);
        int cost9 = (int) (costPercent*cost9Percent);
        int cost10 = (int) (costPercent*cost10Percent);
       
        allCounted = cost1+cost2+cost3+cost4+cost5+cost6+cost7+cost8+cost9+cost10;
        while (allCounted<cardNoLands)
        {
            if(cost1Percent>0) {cost1++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost2Percent>0) {cost2++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost3Percent>0) {cost3++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost4Percent>0) {cost4++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost5Percent>0) {cost5++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost6Percent>0) {cost6++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost7Percent>0) {cost7++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost8Percent>0) {cost8++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost9Percent>0) {cost9++;allCounted++;} if (allCounted>=cardNoLands) break;
            if(cost10Percent>0) {cost10++;allCounted++;} if (allCounted>=cardNoLands) break;
        }
       
        buildCurrents(cost1, allStrength);
        while (cost1>0)
        {
            CardList subList = heap.getSubListByManaCost(1);
            if (subList.size() == 0)
            {
                cost2+= cost1;
                cost1=0;
                break;
            }
           
            cost1 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
       
        buildCurrents(cost2, allStrength);
        while (cost2>0)
        {
            CardList subList = heap.getSubListByManaCost(2);
            if (subList.size() == 0)
            {
                cost3+= cost2;
                cost2=0;
                break;
            }
           
            cost2 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost3, allStrength);
        while (cost3>0)
        {
            CardList subList = heap.getSubListByManaCost(3);
            if (subList.size() == 0)
            {
                cost4+= cost3;
                cost3=0;
                break;
            }
           
            cost3 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost4, allStrength);
        while (cost4>0)
        {
            CardList subList = heap.getSubListByManaCost(4);
            if (subList.size() == 0)
            {
                cost5+= cost4;
                cost4=0;
                break;
            }
           
            cost4 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost5, allStrength);
        while (cost5>0)
        {
            CardList subList = heap.getSubListByManaCost(5);
            if (subList.size() == 0)
            {
                cost6+= cost5;
                cost5=0;
                break;
            }
           
            cost5 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost6, allStrength);
        while (cost6>0)
        {
            CardList subList = heap.getSubListByManaCost(6);
            if (subList.size() == 0)
            {
                cost7+= cost6;
                cost6=0;
                break;
            }
           
            cost6 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost7, allStrength);
        while (cost7>0)
        {
            CardList subList = heap.getSubListByManaCost(7);
            if (subList.size() == 0)
            {
                cost8+= cost7;
                cost7=0;
                break;
            }
           
            cost7 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost8, allStrength);
        while (cost8>0)
        {
            CardList subList = heap.getSubListByManaCost(8);
            if (subList.size() == 0)
            {
                cost9+= cost8;
                cost8=0;
                break;
            }
           
            cost8 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost9, allStrength);
        while (cost9>0)
        {
            CardList subList = heap.getSubListByManaCost(9);
            if (subList.size() == 0)
            {
                cost10+= cost9;
                cost9=0;
                break;
            }
           
            cost9 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
        buildCurrents(cost10, allStrength);
        while (cost10>0)
        {
            CardList subList = heap.getSubListByManaCostHigher(9);
            if (subList.size() == 0)
            {
                cost10=0;
                break;
            }
           
            cost10 -= addOneCard(deck, subList, heap);
            if (getCurrentSum()==0) break;
        }
       
        // fill up with anything if we have not enough yet!
        // addOneCard should handle the correct types
        int i=0;
        buildCurrents(((int)deckSize)-deck.size(), allStrength);
        while (deck.size() != deckSize)
        {
            CardList subList = heap.copyList();
            addOneCard(deck, subList, heap);
            if (heap.size() == 0) break; // savety for not  endless loop
            i++;
            if (i>100) break; // savety for not  endless loop
        }
View Full Code Here


    }

    public void init()
    {
        jPanel2.removeAll();
        heapDisplay.setHand(new CardList());
        heapDisplay.setMyPrefferedSize(jPanel2.getWidth(), 285);
        heapDisplay.scaleChanged();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
View Full Code Here


            heap = new CardHeap(p.heap.getCards(), mBoosterBaseName+"AI"+(i+1)+"_Heap");
            heap.save();

            CardList deckList = p.cplayer.buildBoosterDeck(p.heap);
           
            deck = new CardDeck(deckList, mBoosterBaseName+"AI"+(i+1)+"_", "", mBoosterBaseName+"AI"+(i+1)+"_", true);
            deck.save();
            p.cplayer.setDeck(deck);
            p.cplayer.setBoosterHeap(mBoosterBaseName, i+1);
View Full Code Here

        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonShowPoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowPoolActionPerformed
        // show current "Heap"
        CardList list = buildHeapList();
       
        CardHeapPanel panel = new CardHeapPanel(list);
        panel.setParentWindow(mParent);
       
        mParent.showPanelModal(panel, "Current pool for genDeck", 950, 750);
View Full Code Here

    }
   
    int maxSame = 3;
    private void jButtonBuildADeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuildADeckActionPerformed

        CardList deck = genDeck();
       
        DeckEditPanel panel = new DeckEditPanel(deck);
        panel.setParent(mParent);
//        CardHeapPanel panel = new CardHeapPanel(deck);
        //panel.setParentWindow(mParent);
View Full Code Here

        if (heap.size()==0) return null;
       
        String preferredAbilities = jTextFieldPrefferedAbilities.getText();
        String preferredCreatures = jTextFieldPreferredCreatures.getText();

        CardList prefAb = heap.getSubListWithOneAbility(preferredAbilities);
        CardList prefCre = heap.getSubListByAnySubType(preferredCreatures);
        CardList prefAbCre = prefAb.getSubListByAnySubType(preferredCreatures);
        if (prefAbCre.size() != 0)
            return prefAbCre.drawRandom(1).getCard(0);       
        if (prefAb.size() != 0)
            return prefAb.drawRandom(1).getCard(0);       
        if (prefCre.size() != 0)
            return prefCre.drawRandom(1).getCard(0);       
        return heap.drawRandom(1).getCard(0);       
View Full Code Here

            return prefCre.drawRandom(1).getCard(0);       
        return heap.drawRandom(1).getCard(0);       
    }
    Card getHealCard(CardList heap)
    {
        CardList subList = new CardList();
        if (jCheckBoxForceCreature.isSelected()) heap = heap.removeTypes("Creature");
        for (int i=0; i<heap.size(); i++)
        {
            Card c = heap.getCard(i);
            if (EAIHelper.isHealCard(c))
                subList.addCard(c);
        }
        if (subList.size()==0) return null;
       
        return subList.drawRandom(1).getCard(0);       
    }
View Full Code Here

       
        return subList.drawRandom(1).getCard(0);       
    }
    Card getPlayerDamageCard(CardList heap)
    {
        CardList subList = new CardList();
        if (jCheckBoxForceCreature.isSelected()) heap = heap.removeTypes("Creature");
        for (int i=0; i<heap.size(); i++)
        {
            Card c = heap.getCard(i);
            if (EAIHelper.isPlayerDamageCard(c) )
                subList.addCard(c);
        }
        if (subList.size()==0) return null;
       
        return subList.drawRandom(1).getCard(0);       
    }
View Full Code Here

       
        return subList.drawRandom(1).getCard(0);       
    }
    Card getCreatureDamageCard(CardList heap)
    {
        CardList subList = new CardList();
        if (jCheckBoxForceCreature.isSelected()) heap = heap.removeTypes("Creature");
        for (int i=0; i<heap.size(); i++)
        {
            Card c = heap.getCard(i);
            if (EAIHelper.isCreatureDamageCard(c) )
                subList.addCard(c);
        }
        if (subList.size()==0) return null;
       
        return subList.drawRandom(1).getCard(0);       
    }
View Full Code Here

       
        return subList.drawRandom(1).getCard(0);       
    }
    Card getLandDestroyCard(CardList heap)
    {
        CardList subList = new CardList();
        if (jCheckBoxForceCreature.isSelected()) heap = heap.removeTypes("Creature");
        for (int i=0; i<heap.size(); i++)
        {
            Card c = heap.getCard(i);
            if (EAIHelper.isLandDestroy(c) )
                subList.addCard(c);
        }
        if (subList.size()==0) return null;
       
        return subList.drawRandom(1).getCard(0);       
    }
View Full Code Here

TOP

Related Classes of csa.jportal.card.CardList

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.