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

import com.alterdekim.Protocol;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;

import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.MEDAL_INFO;

public class MedalInfo extends GenericParser {

    @Override
    public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
        Protocol.MedalInfo medalInfo = Protocol.MedalInfo.newBuilder()
                .setWild(Protocol.MedalInfoData.newBuilder()
                        .setSeasonWins(0)
                        .setStars(0)
                        .setStreak(0)
                        .setStarLevel(1)
                        .setLevelStart(1)
                        .setLevelEnd(3)
                        .setCanLoseLevel(false)
                        .setBestStarLevel(1)
                        .setCanLoseStars(false))
                .setStandard(Protocol.MedalInfoData.newBuilder()
                        .setSeasonWins(0)
                        .setStars(0)
                        .setStreak(0)
                        .setStarLevel(1)
                        .setLevelStart(1)
                        .setLevelEnd(3)
                        .setCanLoseLevel(false)
                        .setBestStarLevel(1)
                        .setCanLoseStars(false))
                .build();

        Protocol.Notification n = generateNotification(232, medalInfo.toByteString(), medalInfo.getSerializedSize());

        Protocol.Header header = Protocol.Header.newBuilder()
                .setServiceId(4)
                .setMethodId(1)
                .setToken(conn.nextToken())
                .setObjectId(0)
                .setSize(n.getSerializedSize())
                .setStatus(0)
                .build();

        conn.send(new BattleNetPacket(header, n.toByteArray()));
    }

    @Override
    public int getId() {
        return MEDAL_INFO.getValue();
    }
}
