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.REWARD_PROGRESS;

public class RewardProgress extends GenericParser {

    @Override
    public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
        Protocol.RewardProgress rewardProgress = Protocol.RewardProgress.newBuilder()
                .setSeasonEnd(Protocol.Date.newBuilder()
                        .setYear(2016)
                        .setMonth(5)
                        .setDay(31)
                        .setHours(22)
                        .setMin(6)
                        .setSec(18))
                .setWinsPerGold(3)
                .setGoldPerReward(10)
                .setMaxGoldPerDay(100)
                .setSeasonNumber(31)
                .setXpSoloLimit(60)
                .setMaxHeroLevel(60)
                .setEventTimingMod(-0.08333333f)
                .setNextQuestCancel(Protocol.Date.newBuilder()
                        .setYear(2016)
                        .setMonth(5)
                        .setDay(3)
                        .setHours(0)
                        .setMin(0)
                        .setSec(0))
                .build();

        Protocol.Notification n = generateNotification(271, rewardProgress.toByteString(), rewardProgress.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 REWARD_PROGRESS.getValue();
    }
}
