import pytest

import cocos
import cocos.layer
from cocos.tiles import RectMap, RectCell
from cocos.mapcolliders import RectMapCollider, RectMapWithPropsCollider
from cocos.rect import Rect

import aux_RectMapCollider__no_stuck as aux
# set the cocos classes needed in aux before calling any function there
aux.RectMap_cls = RectMap
aux.RectCell = RectCell
aux.Rect = Rect


maps_cache = aux.generate_maps('-')
 
##def test_smoketest_string_to_RectMap():
##    cells_per_row = 5
##    cells_per_column = 6
##    cell_width = 3
##    cell_height = 5
##    string_map = mapstrings['vertical_w_hole']
##    rect_map = string_to_RectMap(string_map, cell_width, cell_height)
##    cells = rect_map.get_in_region(0, 0,
##                                   cells_per_row * cell_width,
##                                   cells_per_column * cell_height)
##    assert len(cells)== cells_per_row * cells_per_column
##    non_empties = set(e for e in cells if e.cell is not None)
##    print(non_empties)
##    # remember rows begin counting from bottom due to openGL origin
            self.model.change(1)
        elif key == pkey.DOWN:
            # prev case
            self.model.change(-1)


print(__doc__)
if len(sys.argv) < 2:
    selector = 0
else:
    selector = 1
collider_cls = [RectMapCollider, RectMapWithPropsCollider][selector]

director.init()
tile_filled = Tile('z', {}, pyglet.image.load('white4x3.png'))
maps_cache = aux.generate_maps(tile_filled)

cases = [
    d for d in aux.case_generator(
        aux.first_expansion(maps_cache, aux.common_base_cases))
]
model = Model(cases)
scene = cocos.scene.Scene()
label = Label("-----------------",
              anchor_x='center',
              anchor_y='center',
              color=(255, 255, 255, 160))
label.position = 320, 20
scene.add(label, z=10)
model.label = label