#pragma once

#include <cstdint>

#include "core/jail/jdraw8.hpp"
#include "game/info.hpp"
#include "game/prota.hpp"

enum : std::uint8_t {
    CONTE_RES = 0,
    CONTE_TRESOR = 1,
    CONTE_FARAO = 2,
    CONTE_CLAU = 3,
    CONTE_MOMIA = 4,
    CONTE_PERGAMI = 5,
    CONTE_DIAMANT = 6,
    VALOR_DIAMANT = 5
};

struct Tomba {
    bool costat[4];
    Uint8 contingut;
    bool oberta;
    Uint16 x, y;
};

struct Vertex {
    Uint8 columna;
    Uint8 fila;
};

class Mapa {
   public:
    explicit Mapa(Jd8::Surface gfx, Prota* sam);
    ~Mapa();

    Mapa(const Mapa&) = delete;
    auto operator=(const Mapa&) -> Mapa& = delete;
    Mapa(Mapa&&) = delete;
    auto operator=(Mapa&&) -> Mapa& = delete;

    void draw();
    void update();
    auto novaMomia() -> bool;
    void comprovaCaixa(Uint8 num);

    Tomba tombes[16];

   protected:
    void preparaFondoEstatic();
    void preparaTombes();

    void comprovaUltimCami();
    void comprovaPorta();

    Jd8::Surface gfx_;
    Jd8::Surface fondo_;
    Vertex vertex_;
    Vertex ultim_vertex_;
    Uint8 frame_torxes_;

    Prota* sam_;

    bool farao_;
    bool clau_;
    bool porta_oberta_;
    bool nova_momia_;
};
