def setUpClass(cls): BaseGameTest.setUpClass() grass = get_theme(name='grass') van = get_character('Van') TestCowCrashes.cow_level = Level(name='Cow crashing', anonymous=False, blocklyEnabled=True, character=van, cows='[{"minCows":"7","maxCows":"7","potentialCoordinates":[{"x":4,"y":4},{"x":2,"y":4},{"x":3,"y":7},{"x":4,"y":6},{"x":2,"y":6},{"x":3,"y":1},{"x":4,"y":2}],"type":"WHITE"}]', default=False, destinations='[[4,5]]', direct_drive=True, fuel_gauge=False, max_fuel=50, model_solution='[1]', origin='{"coordinate":[2,5],"direction":"E"}', path='[{"coordinate":[2,5],"connectedNodes":[1]},{"coordinate":[3,5],"connectedNodes":[0,4,2,5]},{"coordinate":[4,5],"connectedNodes":[1]},{"coordinate":[3,7],"connectedNodes":[4]},{"coordinate":[3,6],"connectedNodes":[8,3,6,1]},{"coordinate":[3,4],"connectedNodes":[10,1,11,16]},{"coordinate":[4,6],"connectedNodes":[4,7]},{"coordinate":[4,7],"connectedNodes":[6]},{"coordinate":[2,6],"connectedNodes":[9,4]},{"coordinate":[2,7],"connectedNodes":[8]},{"coordinate":[2,4],"connectedNodes":[13,5,12]},{"coordinate":[4,4],"connectedNodes":[5,14,15]},{"coordinate":[2,3],"connectedNodes":[10]},{"coordinate":[1,4],"connectedNodes":[10]},{"coordinate":[5,4],"connectedNodes":[11]},{"coordinate":[4,3],"connectedNodes":[11,19]},{"coordinate":[3,3],"connectedNodes":[5,17]},{"coordinate":[3,2],"connectedNodes":[18,16,19,20]},{"coordinate":[2,2],"connectedNodes":[17]},{"coordinate":[4,2],"connectedNodes":[17,15,23,22]},{"coordinate":[3,1],"connectedNodes":[21,17,22]},{"coordinate":[2,1],"connectedNodes":[20]},{"coordinate":[4,1],"connectedNodes":[20,19]},{"coordinate":[5,2],"connectedNodes":[19]}]', pythonEnabled=False, theme=grass, threads=1, traffic_lights='[]', ) TestCowCrashes.cow_level.save() blocks = Block.objects.filter(type__in=["move_forwards", "turn_left", "turn_right"]) for block in blocks: new_block = LevelBlock(type=block, number=None, level=TestCowCrashes.cow_level) new_block.save()
def theme(self): from game.theme import get_theme try: return get_theme(self.theme_name) except KeyError: return None
def theme(self): if not self.theme_name: if self.theme_old: self.theme_name = self.theme_old.name else: return None from game.theme import get_theme return get_theme(self.theme_name)
def decor_data(): theme = get_theme(name='grass') return {'bush': {'ratio': 5, 'decor': get_decor_element(theme=theme, name='bush')}, 'tree1': {'ratio': 4, 'decor': get_decor_element(theme=theme, name='tree1')}, 'tree2': {'ratio': 3, 'decor': get_decor_element(theme=theme, name='tree2')}, 'pond': {'ratio': 1, 'decor': get_decor_element(theme=theme, name='pond')} }
def decor_data(): theme = get_theme(name="grass") return { "bush": {"ratio": 5, "decor": get_decor_element(theme=theme, name="bush")}, "tree1": {"ratio": 4, "decor": get_decor_element(theme=theme, name="tree1")}, "tree2": {"ratio": 3, "decor": get_decor_element(theme=theme, name="tree2")}, "pond": {"ratio": 1, "decor": get_decor_element(theme=theme, name="pond")}, }
def decor_data(): theme = get_theme(name="grass") return { "bush": { "ratio": 5, "decor": get_decor_element(theme=theme, name="bush") }, "tree1": { "ratio": 4, "decor": get_decor_element(theme=theme, name="tree1") }, "tree2": { "ratio": 3, "decor": get_decor_element(theme=theme, name="tree2") }, "pond": { "ratio": 1, "decor": get_decor_element(theme=theme, name="pond") }, }
def decor_data(): theme = get_theme(name='grass') return { 'bush': { 'ratio': 5, 'decor': get_decor_element(theme=theme, name='bush') }, 'tree1': { 'ratio': 4, 'decor': get_decor_element(theme=theme, name='tree1') }, 'tree2': { 'ratio': 3, 'decor': get_decor_element(theme=theme, name='tree2') }, 'pond': { 'ratio': 1, 'decor': get_decor_element(theme=theme, name='pond') } }
from game.theme import get_theme, get_all_themes class Decor(object): def __init__(self, pk, name, url, width, height, theme, z_index): self.id = self.pk = pk self.name = name self.url = url self.width = width self.height = height self.theme = theme self.z_index = z_index DECOR_DATA = { (u'tree1', u'grass'): Decor(z_index=4, name=u'tree1', url=u'decor/grass/tree1.svg', height=100, width=100, theme=get_theme('grass'), pk=1), (u'tree2', u'grass'): Decor(z_index=4, name=u'tree2', url=u'decor/grass/tree2.svg', height=100, width=100, theme=get_theme('grass'), pk=2), (u'bush', u'grass'): Decor(z_index=3, name=u'bush', url=u'decor/grass/bush.svg', height=50, width=50, theme=get_theme('grass'), pk=3), (u'house', u'grass'): Decor(z_index=1, name=u'house', url=u'decor/grass/house.svg', height=50, width=50, theme=get_theme('grass'), pk=4), (u'cfc', u'grass'): Decor(z_index=1, name=u'cfc', url=u'decor/grass/cfc.svg', height=107, width=100, theme=get_theme('grass'), pk=5), (u'pond', u'grass'): Decor(z_index=2, name=u'pond', url=u'decor/grass/pond.svg', height=100, width=150, theme=get_theme('grass'), pk=6), (u'tree1', u'snow'): Decor(z_index=4, name=u'tree1', url=u'decor/snow/tree1.svg', height=100, width=100, theme=get_theme('snow'), pk=7), (u'tree2', u'snow'): Decor(z_index=4, name=u'tree2', url=u'decor/snow/tree2.svg', height=100, width=100, theme=get_theme('snow'), pk=8), (u'bush', u'snow'): Decor(z_index=3, name=u'bush', url=u'decor/snow/bush.svg', height=50, width=50, theme=get_theme('snow'), pk=9), (u'house', u'snow'): Decor(z_index=1, name=u'house', url=u'decor/snow/house.svg', height=50, width=50, theme=get_theme('snow'), pk=10), (u'cfc', u'snow'): Decor(z_index=1, name=u'cfc', url=u'decor/snow/cfc.svg', height=107, width=100, theme=get_theme('snow'), pk=11), (u'pond', u'snow'): Decor(z_index=2, name=u'pond', url=u'decor/snow/pond.svg', height=100, width=150, theme=get_theme('snow'), pk=12), (u'tile1', u'grass'): Decor(z_index=0, name=u'tile1', url=u'decor/grass/tile1.svg', height=100, width=100, theme=get_theme('grass'), pk=13), (u'tile1', u'snow'): Decor(z_index=0, name=u'tile1', url=u'decor/snow/tile1.svg', height=100, width=100, theme=get_theme('snow'), pk=14), (u'tile2', u'snow'): Decor(z_index=0, name=u'tile2', url=u'decor/snow/tile2.svg', height=100, width=100, theme=get_theme('snow'), pk=15), (u'house', u'farm'): Decor(z_index=1, name=u'house', url=u'decor/farm/house1.svg', height=224, width=184, theme=get_theme('farm'), pk=16),
def get_theme(self, obj): pk = get_theme(obj.theme_name).pk return get_themes_url(pk, self.context.get('request', None))
self.url = url self.width = width self.height = height self.theme = theme self.z_index = z_index DECOR_DATA = { (u"tree1", u"grass"): Decor( z_index=4, name=u"tree1", url=u"decor/grass/tree1.svg", height=100, width=100, theme=get_theme("grass"), pk=1, ), (u"tree2", u"grass"): Decor( z_index=4, name=u"tree2", url=u"decor/grass/tree2.svg", height=100, width=100, theme=get_theme("grass"), pk=2, ), (u"bush", u"grass"): Decor( z_index=3,
self.name = name self.url = url self.width = width self.height = height self.theme = theme self.z_index = z_index DECOR_DATA = { (u'tree1', u'grass'): Decor(z_index=4, name=u'tree1', url=u'decor/grass/tree1.svg', height=100, width=100, theme=get_theme('grass'), pk=1), (u'tree2', u'grass'): Decor(z_index=4, name=u'tree2', url=u'decor/grass/tree2.svg', height=100, width=100, theme=get_theme('grass'), pk=2), (u'bush', u'grass'): Decor(z_index=3, name=u'bush', url=u'decor/grass/bush.svg', height=50, width=50,
self.name = name self.url = url self.width = width self.height = height self.theme = theme self.z_index = z_index DECOR_DATA = { (u"tree1", u"grass"): Decor( z_index=4, name=u"tree1", url=u"decor/grass/tree1.svg", height=100, width=100, theme=get_theme("grass"), pk=1, ), (u"tree2", u"grass"): Decor( z_index=4, name=u"tree2", url=u"decor/grass/tree2.svg", height=100, width=100, theme=get_theme("grass"), pk=2, ), (u"bush", u"grass"): Decor( z_index=3, name=u"bush", url=u"decor/grass/bush.svg",