def uncover_square(request, caller_context, container_user, chamber_character_name, grid_pos_x, grid_pos_y):
    ''' data only call, json response
    '''
    chamberController = ChamberController()
    chamber_character = Character.get_by_key_name(chamber_character_name)
    if not chamber_character:
        raise Exception('chamber owner character not found')
    
    uncover_square_result, info, air_level = chamberController.uncover_dig_square(caller_context.config, container_user, chamber_character, int(grid_pos_x), int(grid_pos_y))
    
    if uncover_square_result:
        square = info # if success, info contains the item to return
        response_square = {
                             'gridPosX' : square.position_x,
                             'gridPosY' : square.position_y,
                          }
        if square.item:
            response_square['item'] = { 
                                 'itemName' : square.item.item_name,
                                 'description' : square.item.description,
                                 'smallImageUrl' : caller_context.static_root + square.item.get_small_image_path(),
                                 'largeImageUrl' : caller_context.static_root + square.item.get_large_image_path()
                                 }
        else:
            response_square['item'] = None
        response =  { 'success' : True,
                      'airLevel' : air_level,
                      'square' : response_square
                    }
    else:
        response = { 'success' : False,
                     'reason' : info
                   }

    include_experience_data = False
    if uncover_square_result and square.item:
        characterController = CharacterController()
        characterController.add_character_reward(container_user.character, "found grid treasure", 'experience', 75)
        include_experience_data = True
        
    return json_response(caller_context, container_user, response, include_experience_data)
def join(request, caller_context, container_user, join_pyramid_id=None, join_brick_id=None, join_invite_key_name=None, action=None):
    ''' data only call, json response
    '''
    pyramidController = PyramidController()
    
    if join_invite_key_name:
        if action == 'accept':
            joinResult, joinInfo  = pyramidController.join_from_invite(caller_context.config, container_user, join_invite_key_name)
        elif action == 'decline':
            joinResult, joinInfo = pyramidController.decline_invite(container_user, join_invite_key_name)
    else:    
        joinResult, joinInfo  = pyramidController.join_pyramid(caller_context.config, int(join_pyramid_id), int(join_brick_id), container_user.character)
    
    joinResponse = { 'success' : joinResult, 
                      'result' : joinInfo}
    
    include_experience_data = False
    if joinResult:
        characterController = CharacterController()
        characterController.add_character_reward(container_user.character, "brick join", 'experience', 75)
        include_experience_data = True
    
    return json_response(caller_context, container_user, joinResponse, include_experience_data)