import datetime
import cocos

from app.verkolst import verkolst


class StatusBar(cocos.layer.Layer):

    def __init__(self):
        super().__init__()

        background = cocos.sprite.Sprite('bottom_bar_1920_100_px.png',
                                         position=(0, 0),
                                         anchor=(0, 0))
        self.add(background)
        gold_icon = cocos.sprite.Sprite('gold_40_40_px.png',
                                        position=(100, 4),
                                        anchor=(0, 0))
        gold_count = cocos.text.Label('1238',
                                      position=(140, 12),
                                      font_size=20,
                                      )
        self.add(gold_icon)
        self.add(gold_count)

        self.date_label = cocos.text.Label('-',
                                           position=(1920-5, 12),
                                           font_size=20,
                                           anchor_x="right")
        self.add(self.date_label)

    def on_turn_start(self):
        month = datetime.datetime.strftime(verkolst.date, '%B')
        self.date_label.element.text = f'{month} {verkolst.date.day}, {verkolst.date.year}'

