public void Unit_TehaiDaiminkanTest() { Tehai testTehai = new Tehai(new List<string> { "1m", "2m", "3m", "4m", "5m", "6m", "7m", "8m", "9m", "1s", "2s", "3s", "1m" }); 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"), new Pai("1m") }; consumed.Sort(); Assert.IsTrue(testTehai.tehai.Contains(new Pai("1m"))); //実施 testTehai.Daiminkan(actor, target, furopai, consumed); //フーロオブジェクトの構成が正しいか Assert.AreEqual(testTehai.furos[0].furoType, MJUtil.TartsuType.MINKANTSU); Assert.AreEqual(testTehai.furos[0].furopai, furopai); CollectionAssert.AreEqual(testTehai.furos[0].consumed, consumed); //晒した牌が手配に残っていないか Assert.IsFalse(testTehai.tehai.Contains(new Pai("1m"))); }
public bool CanPon(Tehai tehai, int dapaiActor, int playerId, string pai) { if ((dapaiActor != playerId)) { // can pon return false; } return false; }
public bool CanChi(Tehai tehai, int dapaiActor, int playerId, string pai) { if ((dapaiActor != playerId) && ((dapaiActor + 1) % 4 == playerId)) { // can chi return false; } // cann't chi return false; }
public bool CanHora(Tehai tehai, InfoForResult ifr, Field field, int dapaiActor, int playerId, string pai) { if (dapaiActor == playerId) { return CanHoraIntsumo( tehai, ifr, field, dapaiActor, playerId, pai); } else { return CanHoraInRon(tehai, ifr, field, dapaiActor, playerId, pai); } }
private bool CanHoraIntsumo(Tehai tehai, InfoForResult ifr, Field field, int dapaiActor, int playerId, string pai) { if( tehai.GetShanten() == -1 ) { var horaResult = ResultCalclator.CalcHoraResult(tehai, ifr, field, pai); if (horaResult.yakuResult.HasYakuExcludeDora) { return true; } } return false; }
public void Unit_TehaiAnkanTest() { Tehai testTehai = new Tehai(new List<Pai> { new Pai("1m"), 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].furoType, MJUtil.TartsuType.ANKANTSU); CollectionAssert.AreEqual(testTehai.furos[0].consumed, consumed); //晒した牌が手配に残っていないか Assert.IsFalse(testTehai.tehai.Contains(new Pai("1m"))); }
bool CanReach(Tehai tehai, InfoForResult infoForResult, Yama yama) { return ( tehai.IsTenpai() || tehai.IsHora() ) && tehai.IsMenzen() && (infoForResult.IsReach == false && infoForResult.IsDoubleReach == false) && (yama.GetRestYamaNum() >= Constants.PLAYER_NUM); }
public void Unit_TehaiKakanTest() { 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")); //pon infomation 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"))); //execute pon testTehai.Pon(actor, target, furopai, consumed); //tsumo for kakan testTehai.Tsumo(new Pai("1m")); //kakan infomation var kakanFuropai = new Pai("1m"); var kakanConsumed = new List<Pai> { new Pai("1m"), new Pai("1m"), new Pai("1m") }; consumed.Sort(); //execute kakan testTehai.Kakan(actor, kakanFuropai, kakanConsumed); //フーロオブジェクトの構成が正しいか Assert.AreEqual(MJUtil.TartsuType.MINKANTSU, testTehai.furos.LastOrDefault().furoType); Assert.AreEqual(kakanFuropai, testTehai.furos.LastOrDefault().furopai); CollectionAssert.AreEqual(kakanConsumed, testTehai.furos.LastOrDefault().consumed); //晒した牌が手配に残っていないか Assert.IsFalse(testTehai.tehai.Contains(new Pai("1m"))); }
public void Unit_TehaiTsumoTest() { 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"))); }
public void Unit_YakuResultTest() { //chinitsu pinfu iipeiko { 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.UseYamaPaiNum = 10; testIfr.SetLastAddedPai(lastAdded); var result = new HoraResult(); result = ResultCalclator.CalcHoraResult(testTehai, testIfr, new Field(), lastAdded); var yakuMap = result.yakuResult.yakus; Assert.IsTrue(yakuMap.Count(e => (string)e[0] == MJUtil.YAKU_STRING[(int)MJUtil.Yaku.CHINNITSU]) == 1); Assert.IsTrue(yakuMap.Count(e => (string)e[0] == MJUtil.YAKU_STRING[(int)MJUtil.Yaku.PINFU]) == 1); Assert.IsTrue(yakuMap.Count(e => (string)e[0] == MJUtil.YAKU_STRING[(int)MJUtil.Yaku.IIPEIKOU]) == 1); } }
public void Unit_HoraResultTest() { //親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 = 1; var playerPosition = 0; var lastAddedPai = "E"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = true; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; 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 = 1; var playerPosition = 0; var lastAddedPai = "5p"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = true; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; 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 = 1; var playerPosition = 1; var lastAddedPai = "6s"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = false; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; 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 = 1; var playerPosition = 1; var lastAddedPai = "3p"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = false; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; 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 = 1; var playerPosition = 1; var lastAddedPai = "3m"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = true; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; 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 = 1; var playerPosition = 1; var lastAddedPai = "1p"; var ifr = new InfoForResult(gameId, playerPosition); ifr.IsTsumo = false; ifr.IsFured = false; ifr.IsMenzen = true; ifr.UseYamaPaiNum = 5; var fd = new Field(); ifr.SetLastAddedPai(lastAddedPai); var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai); Assert.AreEqual(expected, result.pointResult.HoraPlayerIncome); } }
public void Unit_HoraMentsuPatternResultTest() { 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つのパターンがある }
public void Unit_HoraResultTestUseHoraPatternExamples() { using (StreamReader sr = new StreamReader(@"../../HoraPatternOutputSmall.txt", Encoding.GetEncoding("shift_jis"))) { var lineNumber = 0; while (true) { string line = sr.ReadLine(); if (line == null) break; lineNumber++; var obj = JsonConvert.DeserializeObject<MJsonMessageHora_Extend>(line); int expected = obj.hora_points; var gameId = obj.kyoku; var playerPosition = obj.actor; var lastAddedPai = obj.pai; var stubOyaId = 0;// replaced after var ifr = new InfoForResult(gameId, playerPosition, stubOyaId, obj.bakaze); ifr.IsTsumo = obj.actor == obj.target; var ankantsuCount = obj.hora_furos.Count(e => e[0] == "ankantsu"); ifr.IsMenzen = obj.hora_furos.Count - ankantsuCount == 0; ifr.IsFured = !ifr.IsMenzen; ifr.UseYamaPaiNum = 5; ifr.SetLastAddedPai(lastAddedPai); ifr.IsIppatsu = yakuContains(obj, "ippatsu"); ifr.IsReach = yakuContains(obj, "reach"); ifr.IsDoubleReach = yakuContains(obj, "double_reach"); ifr.IsHaitei = yakuContains(obj, "haiteiraoyue"); ifr.IsHoutei = yakuContains(obj, "hoteiraoyui"); ifr.IsRinshan = yakuContains(obj, "rinshankaiho"); ifr.IsChankan = yakuContains(obj, "chankan"); ifr.IsOya = (obj.kyoku - 1 - obj.actor + Constants.PLAYER_NUM) % Constants.PLAYER_NUM == 0; foreach (var doraMarker in obj.dora_markers) { ifr.RegisterDoraMarker(doraMarker); } ifr.RegisterUraDoraMarker(obj.uradora_markers); var fd = new Field(obj.kyoku, 0, 0, 0,obj.bakaze); var tehai = new Tehai(obj.hora_tehais); foreach (var furo in obj.hora_furos) { // ankan don't contains furo.furopai if (MJUtil.TARTSU_TYPE_STRING_ENUM_MAP[furo[0]] == MJUtil.TartsuType.ANKANTSU) { var f = new Furo(furo[0], Pai.UNKNOWN_PAI_STRING, furo.GetRange(1, furo.Count - 1)); tehai.furos.Add(f); } else { var f = new Furo(furo[0], furo[1], furo.GetRange(2, furo.Count - 2)); tehai.furos.Add(f); } } if (ifr.IsTsumo) { tehai.tehai.Add(new Pai(lastAddedPai)); } var result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai); var myPointResult = result.pointResult.HoraPlayerIncome; if (myPointResult != expected) { Debug.WriteLine(lineNumber + ", acc = " + expected + " --> " + myPointResult + " tehais:" + string.Join(",", tehai.GetTehaiStringList().ToList())); foreach (var yaku in result.yakuResult.yakus) { Debug.WriteLine("accual yaku {0}, han {1}",yaku[0],yaku[1]); } result = ResultCalclator.CalcHoraResult(tehai, ifr, fd, lastAddedPai); } Assert.AreEqual(expected, myPointResult); } } }