#include "game/marcador.hpp"

Marcador::Marcador(Jd8::Surface gfx, Prota* sam) {
    this->gfx_ = gfx;
    this->sam_ = sam;
}

void Marcador::draw() {
    if (Info::ctx.num_piramide < 6) {
        this->pintaNumero(55, 2, Info::ctx.num_piramide);
        this->pintaNumero(80, 2, Info::ctx.num_habitacio);
    }

    this->pintaNumero(149, 2, Info::ctx.diners / 100);
    this->pintaNumero(156, 2, (Info::ctx.diners % 100) / 10);
    this->pintaNumero(163, 2, Info::ctx.diners % 10);

    if (this->sam_->pergami) {
        Jd8::blitCK(190, 1, this->gfx_, 209, 185, 15, 14, 255);
    }

    Jd8::blitCK(271, 1, this->gfx_, 0, 20, 15, Info::ctx.vida * 3, 255);
    if (Info::ctx.vida < 5) {
        Jd8::blitCK(271, 1 + (Info::ctx.vida * 3), this->gfx_, 75, 20, 15, 15 - (Info::ctx.vida * 3), 255);
    }
}

void Marcador::pintaNumero(Uint16 x, Uint16 y, Uint8 num) {
    switch (num) {
        case 0:
            Jd8::blitCK(x, y, this->gfx_, 141, 193, 10, 7, 255);
            break;
        case 1:
            Jd8::blitCK(x, y, this->gfx_, 100, 185, 10, 7, 255);
            break;
        case 2:
            Jd8::blitCK(x, y, this->gfx_, 110, 185, 10, 7, 255);
            break;
        case 3:
            Jd8::blitCK(x, y, this->gfx_, 120, 185, 10, 7, 255);
            break;
        case 4:
            Jd8::blitCK(x, y, this->gfx_, 130, 185, 10, 7, 255);
            break;
        case 5:
            Jd8::blitCK(x, y, this->gfx_, 140, 185, 10, 7, 255);
            break;
        case 6:
            Jd8::blitCK(x, y, this->gfx_, 101, 193, 10, 7, 255);
            break;
        case 7:
            Jd8::blitCK(x, y, this->gfx_, 111, 193, 10, 7, 255);
            break;
        case 8:
            Jd8::blitCK(x, y, this->gfx_, 121, 193, 10, 7, 255);
            break;
        case 9:
            Jd8::blitCK(x, y, this->gfx_, 131, 193, 10, 7, 255);
            break;
        default:
            break;
    }
}
