package org.mahjong4j.yaku.yakuman;

import org.mahjong4j.hands.*;
import org.mahjong4j.tile.MahjongTile;

import java.util.List;

import static org.mahjong4j.tile.MahjongTile.*;
import static org.mahjong4j.yaku.yakuman.MahjongYakumanEnum.RYUISO;

/**
 * 緑一色判定クラス
 * 全ての牌が緑色の場合成立
 * すなわち索子の23468 發のみの場合成立
 *
 * @author yu1ro
 */
public class RyuisoResolver implements YakumanResolver {
    private List<Toitsu> toitsuList;
    private List<Shuntsu> shuntsuList;
    private List<Kotsu> kotsuList;
    private List<Kantsu> kantsuList;

    public RyuisoResolver(MentsuComp hands) {
        toitsuList = hands.getToitsuList();
        shuntsuList = hands.getShuntsuList();
        kotsuList = hands.getKotsuList();
        kantsuList = hands.getKantsuList();
    }

    public MahjongYakumanEnum getYakuman() {
        return RYUISO;
    }

    public boolean isMatch() {
        for (Toitsu toitsu : toitsuList) {
            if (!isGreen(toitsu.getTile())) {
                return false;
            }
        }
        for (Kotsu kotsu : kotsuList) {
            if (!isGreen(kotsu.getTile())) {
                return false;
            }
        }
        for (Kantsu kantsu : kantsuList) {
            if (!isGreen(kantsu.getTile())) {
                return false;
            }
        }

        for (Shuntsu shuntsu : shuntsuList) {
            if (shuntsu.getTile() != S3) {
                return false;
            }
        }

        return true;
    }

    /**
     * @param tile 評価する牌
     * @return 緑の牌かどうか
     */
    private boolean isGreen(MahjongTile tile) {
        return tile == HAT
            || tile == S2
            || tile == S3
            || tile == S4
            || tile == S6
            || tile == S8;
    }
}

@@ -57,17 +57,131 @@
 j.hands.
-*
+Kotsu;%0Aimport org.mahjong4j.hands.MentsuComp;%0Aimport org.mahjong4j.hands.Shuntsu;%0Aimport org.mahjong4j.hands.Toitsu
 ;%0Aimport
@@ -607,45 +607,8 @@
 ist;
-%0A    private List%3CKantsu%3E kantsuList;
 %0A%0A  
@@ -779,56 +779,14 @@
 otsu
-List();%0A        kantsuList = hands.get
 Kantsu
-List
 ();%0A
@@ -1073,32 +1073,32 @@
  : kotsuList) %7B%0A
+
             if (
@@ -1183,151 +1183,8 @@
    %7D
-%0A        for (Kantsu kantsu : kantsuList) %7B%0A            if (!isGreen(kantsu.getTile())) %7B%0A                return false;%0A            %7D%0A        %7D
 %0A%0A  

refactor RyuisoResolver