#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;
    }
}
