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\\?.*?)\" ?>");

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

    @Override
    public String handleIt() {
        final String html = this.httpGet("/gacha?gachaTabId=2");
        this.resolveInputToken(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);
    }
}

@@ -354,16 +354,49 @@
 %5C?.*?)%5C%22
+ class=%5C%22actBtn jscTouchActive %5C%22
  ?%3E%22);%0D%0A
@@ -631,24 +631,57 @@
 n(html);%0D%0A%0D%0A
+        this.log.debug(html);%0D%0A%0D%0A
         fina

fix Gacha2