#include "lotrodatmanagerobserver.h"

#include <QDebug>

LotroDatManagerObserver::LotroDatManagerObserver(LotroDatManager *mgr, QObject *parent) : QObject(parent), lotro_manager_(mgr)
{
}

void LotroDatManagerObserver::startTimer()
{
    connect(&status_update_timer_, &QTimer::timeout, this, &updateStatus);
    status_update_timer_.setInterval(200);
    status_update_timer_.start();
}

void LotroDatManagerObserver::updateStatus()
{
    LotroDatManager::Status status = lotro_manager_->getStatus();
    if (status != status_) {
        qDebug() << "Dat status changed! Percentage: " << status.percent;
        status_ = status;
        emit statusChanged(status);
    }
}
