import datetime
import cocos
from .economy import Resources


class Verkolst:

    def __init__(self):
        self.map = None
        self.date = None
        self.resources = Resources()
        self.height = 0
        self.width = 0

    def init(self, tmx_source):
        self.map = cocos.tiles.load('Verkolst.tmx')
        self.height = len(self['terrain'].cells[0])
        self.width = len(self['terrain'].cells)
        self.date = datetime.date(1278, 1, 1)
        self.resources.init(self)

    def process_turn(self):
        self.date += datetime.timedelta(days=1)
        self.resources.process_turn()

    def __getitem__(self, item):
        return self.map[item]


verkolst = Verkolst()
