package robot.tnk47.gacha;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringEscapeUtils;

import robot.tnk47.Tnk47Robot;

public class Gacha2Handler extends AbstractGachaHandler {

    private static final Pattern ACTBTN_PATTHERN = Pattern.compile("<a href=\"(/gacha/gacha-free-animation\\?.*?)\" class=\"actBtn jscTouchActive \" ?>");

    public Gacha2Handler(final Tnk47Robot robot) {
        super(robot);
    }

    @Override
    public String handleIt() {
        final String html = this.httpGet("/gacha?gachaTabId=2");
        this.resolveInputToken(html);

        this.log.debug(html);

        final Matcher matcher = ACTBTN_PATTHERN.matcher(html);
        if (matcher.find()) {
            String url = matcher.group(1);
            url = StringEscapeUtils.unescapeHtml(url);
            this.openGachaAnimation(url);
        }
        return "/mypage";
    }

    private void openGachaAnimation(final String path) {
        final String html = this.httpGet(path);
        this.resolveGachaResult(html);
    }
}

@@ -639,41 +639,8 @@
 %0D%0A%0D%0A
-        this.log.debug(html);%0D%0A%0D%0A
     
@@ -667,16 +667,30 @@
 tcher = 
+Gacha2Handler.
 ACTBTN_P

remove debug