Ejemplo n.º 1
0
    public static int GetAgariScore(Tehai tehai, Hai addHai, AgariParam param, ref HaiCombi[] combis, ref AgariInfo agariInfo)
    {
        formatWorker.setCounterFormat(tehai, addHai);

        // あがりの組み合わせを取得します
        int combisCount = formatWorker.calculateCombisCount(combis);

        //Debug.Log ("GetAgariScore() combisCount="+combisCount);
        combis = formatWorker.getCombis();

        /*
         * /// 1. check Chiitoitsu(七对子)
         * if( formatWorker.isChiitoitsu() )
         * {
         * Yaku yaku = Yaku.NewYaku_Chiitoitsu(tehai, addHai, param);
         *
         * agariInfo.han = yaku.getHan();
         * agariInfo.fu = 25;
         * agariInfo.hanteiYakus = yaku.getHanteiYakus();
         *
         * agariInfo.scoreInfo = GetScoreInfo(agariInfo.han, agariInfo.fu);
         *
         * return agariInfo.scoreInfo.koAgari;
         * }
         */
        /*
         * /// 2. check Kokushi(国士无双)
         * if( formatWorker.isKokushi() )
         * {
         * Yaku yaku = Yaku.NewYaku_Kokushi(tehai, addHai, param);
         *
         * if( yaku.isKokushi )
         * {
         * agariInfo.han = 13;
         * agariInfo.fu = 20;
         * agariInfo.hanteiYakus = yaku.getHanteiYakus();
         *
         * agariInfo.scoreInfo = GetScoreInfo(agariInfo.han, agariInfo.fu);
         *
         * return agariInfo.scoreInfo.koAgari;
         * }
         *
         * return 0;
         * }
         */
        //return combisCount;

        /// 3. check common combi yaku.
        if (combisCount <= 0)
        {
            return(0);
        }

        int[] hanSuuArr = new int[combisCount];         // 役 計算台數
        //int[] huSuuArr  = new int[combisCount]; // 符
        //int[] scoreArr = new int[combisCount]; // 点数(子のロン上がり)

        int maxAgariScore = 0; // 最大の点数

        for (int i = 0; i < combisCount; i++)
        {
            Yaku yaku = Yaku.NewYaku_Common(tehai, addHai, combis[i], param);
            hanSuuArr[i] = yaku.calculateHanSuu();//計算台數
            //maxAgariScore += hanSuuArr[i];
            //huSuuArr[i] = CalculateHu(tehai, addHai, combis[i], param, yaku);

            //Score scoreInfo = GetScoreInfo(hanSuuArr[i], huSuuArr[i]);

            //scoreArr[i] = scoreInfo.koAgari;

            if (hanSuuArr[i] > maxAgariScore)
            {
                agariInfo.han = hanSuuArr[i];
                //agariInfo.fu = huSuuArr[i];
                agariInfo.hanteiYakus = yaku.getHanteiYakus();

                //agariInfo.scoreInfo = scoreInfo;

                maxAgariScore = hanSuuArr[i];
            }
        }
        //agariInfo.han = maxAgariScore;
        //agariInfo.fu = 0;
        //agariInfo.scoreInfo = GetScoreInfo(5, 30);

        //agariInfo.hanteiYakus = yaku.getHanteiYakus();
        // 最大値を探す
        //maxAgariScore = 0;

        //for(int i = 0; i < combisCount; i++)
        //{
        //    if( scoreArr[i] > maxAgariScore )
        //        maxAgariScore = scoreArr[i];
        //}
        //return maxAgariScore;
        return(combisCount);
    }
    public static int GetAgariScore(Tehai tehai, Hai addHai, AgariParam param, ref HaiCombi[] combis, ref AgariInfo agariInfo)
    {
        formatWorker.setCounterFormat(tehai, addHai);

        // あがりの組み合わせを取得します
        int combisCount = formatWorker.calculateCombisCount(combis);

        combis = formatWorker.getCombis();

        /// 1. check Chiitoitsu(七对子)
        if (formatWorker.isChiitoitsu())
        {
            Yaku yaku = Yaku.NewYaku_Chiitoitsu(tehai, addHai, param);

            agariInfo.han         = yaku.getHan();
            agariInfo.fu          = 25;
            agariInfo.hanteiYakus = yaku.getHanteiYakus();

            agariInfo.scoreInfo = GetScoreInfo(agariInfo.han, agariInfo.fu);

            return(agariInfo.scoreInfo.koAgari);
        }

        /// 2. check Kokushi(国士无双)
        if (formatWorker.isKokushi())
        {
            Yaku yaku = Yaku.NewYaku_Kokushi(tehai, addHai, param);

            if (yaku.isKokushi)
            {
                agariInfo.han         = 13;
                agariInfo.fu          = 20;
                agariInfo.hanteiYakus = yaku.getHanteiYakus();

                agariInfo.scoreInfo = GetScoreInfo(agariInfo.han, agariInfo.fu);

                return(agariInfo.scoreInfo.koAgari);
            }

            return(0);
        }


        /// 3. check common combi yaku.
        if (combisCount <= 0)
        {
            return(0);
        }

        int[] hanSuuArr = new int[combisCount]; // 役
        int[] huSuuArr  = new int[combisCount]; // 符
        int[] scoreArr  = new int[combisCount]; // 点数(子のロン上がり)

        int maxAgariScore = 0;                  // 最大の点数

        for (int i = 0; i < combisCount; i++)
        {
            Yaku yaku = Yaku.NewYaku_Common(tehai, addHai, combis[i], param);
            hanSuuArr[i] = yaku.calculateHanSuu();
            huSuuArr[i]  = CalculateHu(tehai, addHai, combis[i], param, yaku);

            Score scoreInfo = GetScoreInfo(hanSuuArr[i], huSuuArr[i]);

            scoreArr[i] = scoreInfo.koAgari;

            if (scoreArr[i] > maxAgariScore)
            {
                agariInfo.han         = hanSuuArr[i];
                agariInfo.fu          = huSuuArr[i];
                agariInfo.hanteiYakus = yaku.getHanteiYakus();

                agariInfo.scoreInfo = scoreInfo;

                maxAgariScore = scoreArr[i];
            }
        }


        // 最大値を探す
        maxAgariScore = 0;

        for (int i = 0; i < combisCount; i++)
        {
            if (scoreArr[i] > maxAgariScore)
            {
                maxAgariScore = scoreArr[i];
            }
        }

        return(maxAgariScore);
    }