Esempio n. 1
0
        public MJsonMessageHora Hora(int actor, int target, string pai)
        {
            // validate Hora


            //actorとtargetが異なる場合はロン和了であり手配にはロン牌が含まれていないためツモ和了とは別の求め方をする

            var uradoraMarkers = yama.GetUradoraMarker();
            var ifr            = infoForResult[actor];

            ifr.PassedTurn = yama.GetUsedYamaNum();
            ifr.IsFured    = tehais[actor].furos.Count > 0;
            ifr.IsMenzen   = !ifr.IsFured;



            if (actor == target)
            {
                ifr.IsHaitei = yama.GetRestYamaNum() == 0;
                ifr.IsTsumo  = true;
            }
            else
            {
                infoForResult[actor].SetLastAddedPai(pai);
                ifr.IsHoutei = yama.GetRestYamaNum() == 0;
                ifr.IsTsumo  = false;
            }
            HoraResult horaResult;

            horaResult = ResultCalclator.CalcHoraResult(tehais[actor], infoForResult[actor], field, pai);



            //場況を更新
            //TODO  delta と pointResult


            return(new MJsonMessageHora(actor, target, pai, uradoraMarkers, tehais[actor].GetTehaiString(), horaResult.yakuResult.yakus, horaResult.yakuResult.Fu,
                                        horaResult.yakuResult.Han, new List <int> {
                0, 0, 0, 0
            }, new List <int> {
                0, 0, 0, 0
            }));
        }
Esempio n. 2
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]));
            }
        }
Esempio n. 3
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);
            }
        }