package com.alterdekim.hearthhack.component.processor.client.request;

import com.alterdekim.Protocol;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.component.processor.client.request.generic.GeneralGenericParser;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;

public class NetCacheObjectList extends ClientRequestParser {

    private final GeneralGenericParser parser;

    public NetCacheObjectList() {
        this.parser = new GeneralGenericParser();
    }

    @Override
    public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) throws Exception {
        Protocol.GenericRequestList genericRequestList = Protocol.GenericRequestList.parseFrom(body.getBody());
        genericRequestList.getRequestsList().forEach(gr -> parser.parseGenericRequest(packet.getHeader().getToken(), gr, conn));
    }

    @Override
    public int getId() {
        return 327;
    }
}
