Exemple #1
0
def construct_avatar(avatar_dict):
    '''
	:param avatar_dict:	dict containing avatar obj info
	:return: constructed avatar obj
	'''
    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 avatar
Exemple #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