def cover_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 = chamberController.cover_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
                          }
        response =  { 'success' : True,
                      'square' : response_square
                    }
    else:
        response = { 'success' : False,
                     'reason' : info
                   }

    include_experience_data = False
    return json_response(caller_context, container_user, response, include_experience_data)
def chamber(request, caller_context, container_user, chamber_character_name=None):
    chamberController = ChamberController()
    if chamber_character_name:
        chamber_character = Character.get_by_key_name(chamber_character_name)
    else:
        chamber_character = container_user.character

    viewer_owns_chamber = False
    if chamber_character.key() == container_user.character.key():
        viewer_owns_chamber = True

    chamber_display = chamberController.get_chamber_display(caller_context.config, container_user.character, chamber_character)
    return render_to_response('chamber.html', locals())
def help(request, caller_context, container_user):
    ''' live
    '''
    chamberController = ChamberController()
    grid = container_user.character.get_hunt_grid()
    chamberController.populate_hunt_grid(grid)     #todo remove this, TESTING ONLY
    
    query = Inventory_item.all().ancestor(container_user.character)
    query.filter('position_y >', 0) # only pull items that are on display
    query.order('position_y').order('position_x')
    display_items = query.fetch(1000)
    
    db.delete(display_items)
    
    return render_to_response('help.html', locals())
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)