예제 #1
0
        public static HoraResult CalcHoraResult(Tehai tehai, InfoForResult ifr, Field field, string horaPai)
        {
            //面子手の取りうる和了形を全て列挙
            SplitedTehai      splited        = SplitedTehaiCalclator.CalcSplitedTehai(tehai, horaPai, !ifr.IsTsumo);
            List <YakuResult> yakuResultList = new List <YakuResult>();

            //面子手和了型が0の場合はチートイツか国士無双
            if (splited.AllHoraPatternList.Count == 0)
            {
                yakuResultList.Add(YakuResultCalclator.CalcSpecialYaku(ifr, field, splited.SyuNum));
            }
            else
            {
                //面子手の役を計算
                foreach (var pattern in splited.AllHoraPatternList)
                {
                    yakuResultList.Add(YakuResultCalclator.CalcNormalYaku(pattern, ifr, field, splited.SyuNum));
                }
            }

            Dictionary <YakuResult, PointResult> pointResultMap = new Dictionary <YakuResult, PointResult>();

            foreach (var yakuResult in yakuResultList)
            {
                //役と符から点数を計算
                pointResultMap.Add(yakuResult, PointResultCalclator.AnalyzePoint(yakuResult));
            }


            //一番点数が高い和了形の役と点数を返却
            var        maxMap    = pointResultMap.OrderBy(e => e.Value.HoraPlayerIncome).Last();
            HoraResult maxResult = new HoraResult();

            maxResult.yakuResult  = maxMap.Key;
            maxResult.pointResult = maxMap.Value;

            return(maxResult);
        }
예제 #2
0
        public static HoraResult CalcHoraResult(Tehai tehai, InfoForResult ifr, Field field, string horaPai)
        {
            //面子手の取りうる和了形を全て列挙 
            SplitedTehai splited = SplitedTehaiCalclator.CalcSplitedTehai(tehai, horaPai, !ifr.IsTsumo );
            List<YakuResult> yakuResultList = new List<YakuResult>();

            //面子手和了型が0の場合はチートイツか国士無双
            if (splited.AllHoraPatternList.Count == 0)
            {
                yakuResultList.Add(YakuResultCalclator.CalcSpecialYaku(ifr, field, splited.SyuNum));
            }
            else
            {
                //面子手の役を計算
                foreach (var pattern in splited.AllHoraPatternList)
                {
                    yakuResultList.Add(YakuResultCalclator.CalcNormalYaku(pattern, ifr, field, splited.SyuNum));
                }
            }
            
            Dictionary<YakuResult, PointResult> pointResultMap = new Dictionary<YakuResult, PointResult>();
            foreach (var yakuResult in yakuResultList)
            {
                //役と符から点数を計算
                pointResultMap.Add(yakuResult, PointResultCalclator.AnalyzePoint(yakuResult));
            }


            //一番点数が高い和了形の役と点数を返却
            var maxMap = pointResultMap.OrderBy(e => e.Value.HoraPlayerIncome).Last();
            HoraResult maxResult = new HoraResult();
            maxResult.yakuResult = maxMap.Key;     
            maxResult.pointResult = maxMap.Value;     
            
            return maxResult;
        }
예제 #3
0
        public void 役算出テスト()
        {

            //清一色ピンフ一盃口
            {
                Tehai testTehai = new Tehai(new List<string> { "1m", "2m", "3m", "4m", "5m", "6m", "7m", "7m", "1m", "2m", "2m", "3m", "3m", "4m" });

                var lastAdded = "4m";
                var testIfr = new InfoForResult();
                testIfr.IsMenzen = true;
                testIfr.IsOya = true;
                testIfr.IsTsumo = true;
                testIfr.PassedTurn = 10;
                testIfr.SetLastAddedPai(lastAdded);
                var result = new HoraResult();
                result = ResultCalclator.CalcHoraResult(testTehai, testIfr, new Field(), lastAdded);
                var yakuMap = result.yakuResult.yakus;
                Assert.IsTrue(yakuMap.ContainsKey(MJUtil.YAKU_STRING[(int)MJUtil.Yaku.CHINNITSU]));
                Assert.IsTrue(yakuMap.ContainsKey(MJUtil.YAKU_STRING[(int)MJUtil.Yaku.PINFU]));
                Assert.IsTrue(yakuMap.ContainsKey(MJUtil.YAKU_STRING[(int)MJUtil.Yaku.IIPEIKOU]));
            }
        }