from direct.showbase.DirectObject import DirectObject
from panda3d.core import TextNode

from entity.entity import Entity
from global_stuff import base, colors, kaushan


class Shrine(Entity, DirectObject):
    model_name = 'shrine'

    def __init__(self, tile, color):
        super().__init__(tile, color)
        self.ghosts_enshrined = 0
        self.accept('ghost_enshrined', self.enshrine)

        self.label = TextNode('shrine ghost label')
        self.label.set_font(kaushan)
        self.label.set_text_color(colors[color])
        self.label.text = "0/5"
        self.label.set_align(TextNode.ACenter)
        self.label_np = self.model.attach_new_node(self.label)
        self.label_np.set_pos(0, 0, 1.5)
        self.label_np.set_hpr(-45, 0, 0)
        self.label_np.set_scale(0.5)

    def enshrine(self, ghost):
        if ghost.tile != self.tile:
            return
        self.ghosts_enshrined += 1
        self.label.text = str(min(self.ghosts_enshrined, 5)) + "/5"
