package org.mahjong4j.yaku.yakuman;

import org.mahjong4j.hands.Kantsu;
import org.mahjong4j.hands.Kotsu;
import org.mahjong4j.hands.MentsuComp;

import java.util.List;

import static org.mahjong4j.yaku.yakuman.MahjongYakumanEnum.SUANKO;

/**
 * 四暗刻判定クラス
 * 暗刻を4つ作って和了した場合成立
 * 暗槓が含まれても良い
 *
 * @author yu1ro
 */
public class SuankoResolver implements YakumanResolver {

    private final int count;
    private final List<Kotsu> kotsuList;
    private final List<Kantsu> kantsuList;

    public SuankoResolver(MentsuComp comp) {
        kotsuList = comp.getKotsuList();
        kantsuList = comp.getKantsuList();
        count = comp.getKotsuCount() + comp.getKantsuCount();
    }

    public MahjongYakumanEnum getYakuman() {
        return SUANKO;
    }

    public boolean isMatch() {
        if (count < 4) {
            return false;
        }
        for (Kotsu kotsu : kotsuList) {
            if (kotsu.getIsOpen()) {
                return false;
            }
        }
        for (Kantsu kantsu : kantsuList) {
            if (kantsu.getIsOpen()) {
                return false;
            }
        }

        return true;
    }
}

@@ -34,43 +34,8 @@
 n;%0A%0A
-import org.mahjong4j.hands.Kantsu;%0A
 impo
@@ -64,16 +64,16 @@
 .Kotsu;%0A
+
 import o
@@ -402,51 +402,8 @@
 ist;
-%0A    private final List%3CKantsu%3E kantsuList;
 %0A%0A  
@@ -482,55 +482,14 @@
 otsu
-List();%0A        kantsuList = comp.get
 Kantsu
-List
 ();%0A
@@ -756,32 +756,32 @@
  : kotsuList) %7B%0A
+
             if (
@@ -858,143 +858,8 @@
    %7D
-%0A        for (Kantsu kantsu : kantsuList) %7B%0A            if (kantsu.getIsOpen()) %7B%0A                return false;%0A            %7D%0A        %7D
 %0A%0A  

refactor SuankoResolver