Example #1
0
def construct_tile(tile_dict):
    '''
	:param tile_dict: dict containing tile obj
	:return: constructed tile obj
	'''
    tile = Tile(tile_dict['idx'], None)
    if not tile_dict['position'] == None:
        tile.position = (tile_dict['position'][0], tile_dict['position'][1])
    tile.list_of_path = tile_dict['list_of_path']

    return tile
Example #2
0
def construct_obj(res):
    '''

    :param res: response received from client
    :return: constructed tile, and avatar object received from client
    '''
    tile_dict = res[0]
    avatar_dict = res[1]
    tile = Tile(tile_dict['idx'], None)
    if not tile_dict['position'] == None:
        tile.position = (tile_dict['position'][0], tile_dict['position'][1])
    tile.list_of_path = tile_dict['list_of_path']
    avatar = Avatar(avatar_dict['color'], None)
    if not avatar_dict['position'] == None:
        pos = avatar_dict['position'][0]
        port = avatar_dict['position'][1]
        avatar.position = ((pos[0], pos[1]), port)
    return tile, avatar