⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playercardmodule.java

📁 麻将程序
💻 JAVA
字号:
package com.newpalm.game.mj.share;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.Vector;

/**
 * @author liyamin
 */
public class PlayerCardModule {
        private Collection handCards = new Vector();
        private MJCard newCard;
        private List droppedCards = new Vector();
        private Collection tCaptivePairs = new Vector();
        private Collection oCaptivePairs = new Vector();

        public void fetchNewCard(MJCard card) {
                mergeNewCard();
                newCard = card;
        }

        public void dropACard(MJCard card) {
                if (card == null)
                        return;
                mergeNewCard();
                if (handCards.contains(card)) {
                        handCards.remove(card);
                        droppedCards.add(card);
                }
        }

        public void eatWithPair(MJCard card, MJCard[] pair) {
                mergeNewCard();
                MJCard c1 = pair[0];
                MJCard c2 = pair[1];
                handCards.remove(c1);
                handCards.remove(c2);
                MJCard[] captivedPair = new MJCard[3];
                captivedPair[0] = card;
                captivedPair[1] = c1;
                captivedPair[2] = c2;
                getTransparentCaptivePairs().add(captivedPair);
        }

        public void peng(MJCard card) {
                mergeNewCard();
                handCards.remove(card);
                handCards.remove(card);
                MJCard[] captivedPair = new MJCard[3];
                captivedPair[0] = card;
                captivedPair[1] = (MJCard)card.clone();
                captivedPair[2] = (MJCard)card.clone();
                getTransparentCaptivePairs().add(captivedPair);

        }

        public void gang(MJCard card) {
                mergeNewCard();
                handCards.remove(card);
                handCards.remove(card);
                handCards.remove(card);
                MJCard[] captivedPair = new MJCard[4];
                captivedPair[0] = card;
                captivedPair[1] = (MJCard)card.clone();
                captivedPair[2] = (MJCard)card.clone();
                captivedPair[3] = (MJCard)card.clone();
                getTransparentCaptivePairs().add(captivedPair);
        }

        public void anGang(MJCard card) {
                mergeNewCard();
                handCards.remove(card);
                handCards.remove(card);
                handCards.remove(card);
                handCards.remove(card);
                MJCard[] captivedPair = new MJCard[4];
                captivedPair[0] = card;
                captivedPair[1] = (MJCard)card.clone();
                captivedPair[2] = (MJCard)card.clone();
                captivedPair[3] = (MJCard)card.clone();
                getOpacityCaptivePairs().add(captivedPair);
        }

        public Collection getAllTransparentCards() {
                Collection rt = new Vector(getDroppedCards());
                Collection capts = getTransparentCaptivePairs();
                for (Iterator iter = capts.iterator(); iter.hasNext();) {
            Collection capt = (Collection) iter.next();
            rt.addAll(capt);
        }
                return rt;
        }

    /**
     * @return
     */
    public Collection getTransparentCaptivePairs() {
        return tCaptivePairs;
    }

        /**
         * @return
         */
        public Collection getOpacityCaptivePairs() {
                return oCaptivePairs;
        }

    /**
     * @return
     */
    public List getDroppedCards() {
        return droppedCards;
    }

    /**
     * @return
     */
    public SortedSet getSortedHandCards() {
        TreeSet set = new TreeSet(handCards);
        return set;
    }

        public List getDroppableCards() {
                List rt = new Vector(getSortedHandCards());
                if (newCard != null)
                        rt.add(newCard);
                return rt;
        }

        public MJCardCollection getHandCards() {
                MJCardCollection rt = new MJCardCollection();
                rt.addAll(handCards);
                if (newCard != null)
                        rt.add(newCard);
                return rt;
        }
    /**
     * @return
     */
    public MJCard getNewCard() {
        return newCard;
    }


        public void mergeNewCard() {
                if (newCard!= null) {
                        handCards.add(newCard);
                        newCard = null;
                }
        }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -