Package csa.jportal.match

Examples of csa.jportal.match.TestMatch


        if (jComboBox1.getSelectedIndex() == -1) return;

        String matchName = jComboBox1.getSelectedItem().toString();


        TestMatch match = new TestMatch();

        MatchStartOptions options = new MatchStartOptions();
        CardDeck.mDummyLoadingActive = true;
        // assuming a AI named SimpleAI exists!
        options.setPlayer1(new MatchComputerPlayer(new AIPlayer("SimpleAI")));
        options.setPlayer2(new MatchComputerPlayer(new AIPlayer("SimpleAI")));
        CardDeck.mDummyLoadingActive = false;

        Match.loadMatchUnstated(matchName, null, match, options);

        if (!match.didMatchStart()) return;

        vMatch = new VirtualMatch(match);
        //jButton3.setEnabled(vMatch != null);
        jButtonTest.setEnabled(vMatch != null);
    }//GEN-LAST:event_jButton2ActionPerformed
View Full Code Here


    }//GEN-LAST:event_jButton9ActionPerformed

    void showOneGameState(String stateBase, String stateName)
    {
        final TestMatch match = new TestMatch();

        boolean oldConfig = Configuration.getConfiguration().isBackImageShown();
        Configuration.getConfiguration().setBackImageShown(false);       
        match.displayAnyway = true;
        Match.loadMatchUnstated(stateName,
                                    "Default",
                                    "Default",
                                    false, mParent, match, stateBase);


        if (match!= null)
        {
            DefaultMatchDisplay display = (DefaultMatchDisplay) match.getPlayer(0).getMatchDisplay();
            match.mGameStarted = true;
            display.setUseParentSizing(false);
            int w = 700;
            int h = 500;       
            display.dontShowPlayers();
            display.arrange(w-10, h-60); // adjusting for titel and button

            display.disableButtons();
            mParent.showPanelModal(display, stateName, w, h);
            match.mGameStarted = false;
            match.deinitCompletely();
      

        }
        Configuration.getConfiguration().setBackImageShown(oldConfig);  
       
View Full Code Here

    boolean compare(Match eMatch, AITestData test, int orhHealth0, int orgHealth1)
    {
        boolean ret = true;
        reason = "ok";
        error = "";
        TestMatch tmatch = new TestMatch();
        Match.loadMatchLists(    test.mTargetState, test.getTargetSwitch(), tmatch, "testmatches"+File.separator);

        ret = ret && CardList.compareID(eMatch.getBattlefield(0), tmatch.getBattlefield(0));
        if (!ret) {reason = "Battlefield 0 dif"; error = "Expected: "+tmatch.getBattlefield(0)+"\n"+"got     : "+eMatch.getBattlefield(0); return false;}

        ret = ret && CardList.compareID(eMatch.getHand(0), tmatch.getHand(0));
        if (!ret) {reason = "Hand 0 dif"; error = "Expected: "+tmatch.getHand(0)+"\n"+"got     : "+eMatch.getHand(0);return false;}

        ret = ret && CardList.compareID(eMatch.getLand(0), tmatch.getLand(0));
        if (!ret) {reason = "Land 0 dif"; error = "Expected: "+tmatch.getLand(0)+"\n"+"got     : "+eMatch.getLand(0);return false;}

        ret = ret && CardList.compareID(eMatch.getLibrary(0), tmatch.getLibrary(0));
        if (!ret) {reason = "Library 0 dif"; error = "Expected: "+tmatch.getLibrary(0)+"\n"+"got     : "+eMatch.getLibrary(0);return false;}

        ret = ret && CardList.compareID(eMatch.getGraveyard(0), tmatch.getGraveyard(0));
        if (!ret) {reason = "Graveyard 0 dif"; error = "Expected: "+tmatch.getGraveyard(0)+"\n"+"got     : "+eMatch.getGraveyard(0);return false;}

        ret = ret && CardList.compareID(eMatch.getDiscarded(0), tmatch.getDiscarded(0));
        if (!ret) {reason = "Discard 0 dif"; error = "Expected: "+tmatch.getDiscarded(0)+"\n"+"got     : "+eMatch.getDiscarded(0);return false;}


        ret = ret && CardList.compareID(eMatch.getBattlefield(1), tmatch.getBattlefield(1));
        if (!ret) {reason = "Battlefield 1 dif"; error = "Expected: "+tmatch.getBattlefield(1)+"\n"+"got     : "+eMatch.getBattlefield(1);return false;}

        ret = ret && CardList.compareID(eMatch.getHand(1), tmatch.getHand(1));
        if (!ret) {reason = "Hand 1 dif"; error = "Expected: "+tmatch.getHand(1)+"\n"+"got     : "+eMatch.getHand(1);return false;}

        ret = ret && CardList.compareID(eMatch.getLand(1), tmatch.getLand(1));
        if (!ret) {reason = "Land 1 dif"; error = "Expected: "+tmatch.getLand(1)+"\n"+"got     : "+eMatch.getLand(1);return false;}

        ret = ret && CardList.compareID(eMatch.getLibrary(1), tmatch.getLibrary(1));
        if (!ret) {reason = "Library 1 dif"; error = "Expected: "+tmatch.getLibrary(1)+"\n"+"got     : "+eMatch.getLibrary(1);return false;}

        ret = ret && CardList.compareID(eMatch.getGraveyard(1), tmatch.getGraveyard(1));
        if (!ret) {reason = "Graveyard 1 dif"; error = "Expected: "+tmatch.getGraveyard(1)+"\n"+"got     : "+eMatch.getGraveyard(1);return false;}

        ret = ret && CardList.compareID(eMatch.getDiscarded(1), tmatch.getDiscarded(1));
        if (!ret) {reason = "Discard 1 dif"; error = "Expected: "+tmatch.getDiscarded(1)+"\n"+"got     : "+eMatch.getDiscarded(1);return false;}


        ret = ret&&(eMatch.getLife(0) - orhHealth0 == test.getTarget0Health());
        if (!ret) {reason = "Health 0 dif"; error = "Expected: "+(test.getTarget0Health())+"\n"+"got     : "+(eMatch.getLife(0) - orhHealth0);return false;}
View Full Code Here

            public String error="";
        }
       
        final Result result = new Result();

        final TestMatch match = new TestMatch();

       
        String AI1 = "";
        String AI2 = "";
        if (test.mFixedAIName.length()==0)
        {
            error2 = "No fixed AI name!";
            reason2 = "No fixed AI name!";
            return false;
        }
        if (test.mFixedAINumber == 0)
        {
            AI1 = test.mFixedAIName;
            AI2 = jComboBoxAITest.getSelectedItem().toString();
        }
        else
        {
            AI2 = test.mFixedAIName;
            AI1 = jComboBoxAITest.getSelectedItem().toString();
        }
           
       
       
       
        Match.loadMatchUnstated(    test.mSourceState,
                                    AI1,
                                    AI2,
                                    test.getSourceSwitch(), mParent, match, "testmatches"+File.separator);
        match.setLife(0, test.mPlayer1StartHealth);
        match.setLife(1, test.mPlayer2StartHealth);
        jButtonUnpause.setVisible(false);
        if (match!= null)
        {
            final int orgHealth0 = match.getLife(0);
            final int orgHealth1 = match.getLife(1);
            match.setTurnsOnly(new MatchListener()
            {
                synchronized public void matchDoneNotify()
                {
                    result.result = compare(match, test, orgHealth0, orgHealth1);
                    result.reason = reason;
                    result.error = error;
                    mBreak = true;
                    if (testerThread != null)
                        testerThread.interrupt();
                }
            }, test.mAfterRounds);
            if (match.didMatchStart())
            {
                Match.mGameStarted = true;
                JPortalInternalFrame frame = null;
                if (jCheckBoxDebug.isSelected())
                {
                    frame = mParent.showEAIDebug((mAITestData.mFixedAINumber+1)%2, match);
                }
// must be set in order for all
// old AI actions to work,
// since it sometimes refferences match.Match.getLife() - e.g.
Match.match = match;
                match.startMatch();
               
                mBreak = false;
//                synchronized (this)
                {
                    try
                    {
                        while (!mBreak)
                        {
                            testerThread.sleep(100);
                            if (match.isPause())
                            {
                                jLabelRunning.setForeground(new java.awt.Color(204,0, 0));
                                jLabelRunning.setText("Pause!");
                                jButtonUnpause.setVisible(true);
                                unpauseMatch = match;
View Full Code Here

TOP

Related Classes of csa.jportal.match.TestMatch

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.