Exemplo n.º 1
0
        public void 手配ポンテスト()
        {
            Tehai testTehai = new Tehai(new List<string> { "1m", "2m", "3m", "4m", "5m", "6m", "7m", "8m", "9m", "1s", "2s", "3s", "4s" });
            testTehai.Tsumo(new Pai("1m"));


            //chi
            var actor = 0;
            var target = 3;
            var furopai = new Pai("1m");
            var consumed = new List<Pai> { new Pai("1m"), new Pai("1m") };
            consumed.Sort();

            Assert.IsTrue(testTehai.tehai.Contains(new Pai("1m")));
            

            //実施
            testTehai.Pon(actor, target, furopai, consumed);

            //フーロオブジェクトの構成が正しいか
            Assert.AreEqual(testTehai.furos[0].ftype, MJUtil.TartsuType.MINKO);
            Assert.AreEqual(testTehai.furos[0].furopai, furopai);
            CollectionAssert.AreEqual(testTehai.furos[0].consumed, consumed);

            //晒した牌が手配に残っていないか
            Assert.IsFalse(testTehai.tehai.Contains( new Pai("1m")));

        }
Exemplo n.º 2
0
 public void 手配ツモテスト()
 {
     Tehai testTehai = new Tehai(new List<string> { "1m", "2m", "3m", "4m", "5m", "6m", "7m", "8m", "9m", "1s", "2s", "3s", "4s" });
     Assert.IsFalse(testTehai.tehai.Contains(new Pai("5s")));
     testTehai.Tsumo(new Pai("5s"));
     Assert.IsTrue(testTehai.tehai.Contains(new Pai("5s")));
 }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public void 手配暗槓テスト()
        {
            Tehai testTehai = new Tehai( new List<Pai> { new Pai("1m"), new Pai("1m"), new Pai("1m") });

            //ankan
            var actor = 0;
            var consumed = new List<Pai> { new Pai("1m"), new Pai("1m"), new Pai("1m"), new Pai("1m") };
            consumed.Sort();

            Assert.IsTrue(testTehai.tehai.Contains(new Pai("1m")));

            //実施
            testTehai.Ankan(actor, consumed);

            //フーロオブジェクトの構成が正しいか
            Assert.AreEqual(testTehai.furos[0].ftype,  MJUtil.TartsuType.ANKANTSU);
            CollectionAssert.AreEqual(testTehai.furos[0].consumed, consumed);

            //晒した牌が手配に残っていないか
            Assert.IsFalse(testTehai.tehai.Contains(new Pai("1m")));

        }
Exemplo n.º 5
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]));
            }
        }
Exemplo n.º 6
0
        public void 点数算出テスト()
        {
            //親40符3翻 ダブ東 ツモ 7800点
            {
                var expected = 7800;
                var tehai = new Tehai(new List<string>() { "1m", "2m", "3m", "4p", "5p", "6p", "7p", "7p", "7p", "9p", "9p", "E", "E", "E" });

                var gameId = 0;
                var playerPosition = 0;
                var lastAddedPai = "E";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = true;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                ifr.SetLastAddedPai(lastAddedPai);
                var fd = new Field();

                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }

            //親50符2翻 ツモ 三暗刻
            {
                var expected = 9600;
                var tehai = new Tehai(new List<string>() { "1m", "1m", "1m", "2p", "2p", "2p", "4p", "5p", "5p", "5p", "6p", "E", "E","5p" });

                var gameId = 0;
                var playerPosition = 0;
                var lastAddedPai = "5p";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = true;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                ifr.SetLastAddedPai(lastAddedPai);
                var fd = new Field();

                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }

            //子20符2翻 タンピン
            {
                var expected = 2000;
                var tehai = new Tehai(new List<string>() { "2m", "3m", "4m", "2p", "3p", "4p", "4p", "5p", "6p", "4s", "5s", "8s", "8s" });

                var gameId = 0;
                var playerPosition = 1;
                var lastAddedPai = "6s";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = false;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                var fd = new Field();
                ifr.SetLastAddedPai(lastAddedPai);
                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }


            //子20符3翻 タンヤオ三食一盃口
            {
                var expected = 8000;
                var tehai = new Tehai(new List<string>() { "2m", "3m", "4m", "2p", "3p", "4p", "2p", "4p", "5s", "5s", "2s", "3s", "4s" });

                var gameId = 0;
                var playerPosition = 1;
                var lastAddedPai = "3p";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = false;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                var fd = new Field();
                ifr.SetLastAddedPai(lastAddedPai);
                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }

            //子40符1翻 自摸
            {
                var expected = 1500;
                var tehai = new Tehai(new List<string>() { "1m", "2m", "3m", "3m", "4m", "5m", "1p", "1p", "1p", "2s", "3s", "4s", "5s", "5s" });

                var gameId = 0;
                var playerPosition = 1;
                var lastAddedPai = "3m";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = true;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                var fd = new Field();
                ifr.SetLastAddedPai(lastAddedPai);
                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }

            //子50符2翻 ロン
            {
                var expected = 3200;
                var tehai = new Tehai(new List<string>() { "1m", "1m", "1m", "2m", "2m", "2m", "1p", "1p", "1p", "2p", "3p", "4s", "4s" });

                var gameId = 0;
                var playerPosition = 1;
                var lastAddedPai = "1p";

                var ifr = new InfoForResult(gameId, playerPosition);
                ifr.IsTsumo = false;
                ifr.IsFured = false;
                ifr.IsMenzen = true;
                ifr.PassedTurn = 4;
                var fd = new Field();
                ifr.SetLastAddedPai(lastAddedPai);
                var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai);
                Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome);
            }

        }
Exemplo n.º 7
0
        public void 和了時構成分割テスト()
        {
            Tehai testTehai = new Tehai(new List<string> { "1m", "2m", "3m", "4m", "5m", "6m", "7m", "7m", "1m", "1m", "2m", "2m", "3m" });

            var isRon = true;
            var result = SplitedTehaiCalclator.CalcSplitedTehai(testTehai,"3m", isRon);
            Debug.WriteLine(result.AllHoraPatternList.Count);
            foreach (var r in result.AllHoraPatternList)
            {
                foreach (var t in r.TartsuList)
                {
                    Debug.WriteLine(t.TartsuType + "," + t.TartsuStartPaiSyu);
                }
                Debug.WriteLine("");
            }

            Assert.AreEqual(result.AllHoraPatternList.Count, 4);//testTehaiは111222333の部分が順子3つのパターンと暗刻3つのパターンがある
        }