import copy


def applyDamage(state, damage) :
    """Apply damage to the state by reducing the HP of the enemy by the damage
    received
    """
    newState = copy.deepcopy(state)
    # If the enemy does not have HP information, returns the same state
    if 'hp' not in state['enemy'] :
        return newState
    # Reduces HP by damage, min HP being 0
    newState['enemy']['hp'] = max(newState['enemy']['hp'] - damage, 0)
    return newState